| 概述 | 组 | 树 | 图形 | 不推荐 | 索引 | 概念 |
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());
}
另请参阅:
IlcBestGenerate, IlcBestInstantiate, IlcDichotomize, IlcGoal, IlcInstantiate, IlcIntVarArray