本文整理汇总了C#中Plan.addConstraint方法的典型用法代码示例。如果您正苦于以下问题:C# Plan.addConstraint方法的具体用法?C# Plan.addConstraint怎么用?C# Plan.addConstraint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plan
的用法示例。
在下文中一共展示了Plan.addConstraint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: makePlan
// Extract a plan for resatisfaction starting from the given source
// constraints, usually a set of input constraints. This method
// assumes that stay optimization is desired; the plan will contain
// only constraints whose output variables are not stay. Constraints
// that do no computation, such as stay and edit constraints, are
// not included in the plan.
// Details: The outputs of a constraint are marked when it is added
// to the plan under construction. A constraint may be appended to
// the plan when all its input variables are known. A variable is
// known if either a) the variable is marked (indicating that has
// been computed by a constraint appearing earlier in the plan), b)
// the variable is 'stay' (i.e. it is a constant at plan execution
// time), or c) the variable is not determined by any
// constraint. The last provision is for past states of history
// variables, which are not stay but which are also not computed by
// any constraint.
// Assume: sources are all satisfied.
//
public Plan makePlan(ArrayList sources)
{
int mark = newMark();
Plan plan = new Plan();
ArrayList todo = sources;
while (!(todo.Count == 0))
{
#if USE_STACK
Constraint c = (Constraint)todo[todo.Count - 1];
todo.RemoveAt(todo.Count - 1);
#else
Constraint c= (Constraint)todo[todo.Count-1];
todo.RemoveAt(0);
#endif
if (c.output().mark != mark && c.inputsKnown(mark))
{
// not in plan already and eligible for inclusion
plan.addConstraint(c);
c.output().mark = mark;
addConstraintsConsumingTo(c.output(), todo);
}
}
return plan;
}