跳至主内容
框架 无框架

IlcGenerate

public 'IlcGoal'IlcGenerate(const 'IlcIntVarArray'矩阵, 'IlcChooseIntIndex'选择变量=IlcChooseFirstNonFixedInt)
publicIlcGoal IlcGenerate(constIlcIntVarArray array,IlcChooseIntIndex chooseVariable,IlcIntSelect select)
定义文件: ilcp/cpext.h
包含文件: <ilcp/cpextilcp/cpext.h
为数组中的变量赋值的目标。

CP 优化器提供了一种枚举算法,可以设置参数来选择在寻找解决方案过程中尝试变量的顺序。

该目标将参数 "array中的每个受限变量绑定在一起,并为每个变量调用函数 "IlcInstantiate。 变量的固定顺序由函数 "chooseVariable控制。 如果提供了参数 "select,则每次调用 "IlcInstantiate时都会传递该参数。

实现

下面是我们为 "IlcIntVar定义目标的方法。

 ILCGOAL3(IlcIntGenerate,
          IlcIntVarArray,vars、
          IlcChooseIntIndex,   chooseIndex,
          IlcIntSelectI*,select){
   IlcIntindex =chooseIndex(vars);
   if(index ==-1)返回 0;
   返回IlcAnd(IlcIntInstantiate(getCPEngine()、
                                      vars[index]、
                                      选择)、
                 this);
 }

 IlcGoal IlcGenerate(const IlcIntVarArrayarray、
                     IlcChooseIntIndex chooseIndex){
   返回IlcIntGenerate(array.getCPEngine()、
                         阵列
                         chooseIndex,
                         0);
 }

 IlcGoal IlcGenerate(const IlcIntVarArrayarray、
                     IlcChooseIntIndex chooseIndex,
                     IlcIntSelectselect){
   返回IlcIntGenerate(array.getCPEngine()、
                         阵列
                         chooseIndex,
                         select.getImpl());
 }
 

另请参阅: