公共接口IloSearchPhase
接口 "IloSearchPhase用于定义实例化策略,以帮助嵌入式 CP 优化器进行搜索。 搜索阶段包括
IloIntVar[])、IloIntVarChooser),用于定义如何选择下一个要实例化的变量IloIntValueChooser),用于定义变量实例化时如何选择值。通过调用其中一个方法,"IloCP实例将进入搜索阶段:
voidIloCP.solveIloSearchPhasephase); voidIloCP.startNewSearch(IloSearchPhasephase);
嵌入式搜索策略由参数 "IloCP.IntParam.SearchType的值决定,将使用搜索阶段对指定了搜索阶段的变量进行实例化。
Several search phases can be given to an IloCP instance by way of an IloSearchPhase[]. 为此需要调用的方法有
voidIloCP.solveIloSearchPhase[] phases); voidIloCP.startNewSearch(IloSearchPhase[] phases);
阵列中搜索阶段的顺序很重要。 在 CP 搜索策略中,变量将从数组的第一阶段开始逐阶段实例化。 搜索阶段中的变量不必涵盖问题的所有变量。 可以假定,包含所有问题变量的搜索阶段会隐含地添加到给定搜索阶段数组的末尾。
例如,假设我们有一个包含 x、y 和 z 三个变量数组的模型。 在接下来的搜索阶段,阵列
IloSearchPhase[] phases = newIloSearchPhase[2]; phases[0] =cp.searchPhase(x,..., ...); phases[1] =cp.searchPhase(y,..., ...);
the variables x will be instantiated before the variables y and once x and y are instantiated, variables in z will be instantiated. 有些模型的结构特别容易理解,下达这样的指令会对解题时间产生巨大影响。
需要注意的是,在构建搜索阶段时,并非上述三个参数都是必需的。 搜索阶段只能用变量数组创建。 然后,嵌入式搜索将自动选择实例化策略。 例如,假设 "x和 "y是整数变量数组,下面的代码
IloCP cp = new IloCP(); IloSearchPhase[] phases = newIloSearchPhase[2]; phases[0] =cp.searchPhase(x); phases[1] =cp.searchPhase(y); cp.solve(phases);
表示 CP 搜索必须先实例化数组 "x中的变量,然后再实例化数组 "y中的变量。 CP 搜索将选择将它们实例化的方式。
同样,在搜索阶段也无需指定变量数组。 这样定义的搜索阶段将应用于从模型中提取的每个整数变量。
| 修饰符和类型 | 方法和说明 |
|---|---|
void |
end() |