The interface ISearchPhase is used to define instantiation strategies to help the embedded CP search.

Namespace: ILOG.CP
Assembly: ILOG.CP (in ILOG.CP.dll)

Syntax

C#
public interface ISearchPhase
Visual Basic
Public Interface ISearchPhase

Remarks

A search phase is composed of:

  • an array of integer variables (IIntVar[]) to instantiate,
  • a variable chooser (IIntVarChooser) that defines how the next variable to instantiate is chosen, and
  • a value chooser (IIntValueChooser) that defines how values are chosen when instantiating variables.

A search phase is given to a CP instance by invoking one of the methods:

Examples

void CP.Solve(ILOG.CP.ISearchPhase phase); void CP.StartNewSearch(ILOG.CP.ISearchPhase phase);

The embedded search strategy, determined by the value of the parameter CP.IntParam.SearchType, uses the search phases to instantiate the variables for which a search phase is specified.

Several search phases can be given to an CP instance by way of an ISearchPhase[]. The methods that need to be invoked for that purpose are:

Examples

void CP.Solve(ILOG.CP.ISearchPhase[] phases); void CP.StartNewSearch(ILOG.CP.ISearchPhase[] phases);

The order of the search phases in the array is important. In the CP search strategy, the variables will be instantiated phase by phase starting with the first phase of the array. It is not necessary that the variables in the search phases cover all the variables of the problem. It can be assumed that a search phase containing all the problem variables is implicitly added to the end of the given array of search phases.

For instance, assume we have a model over three arrays of variables x, y and z. In the following search phase array

Examples

ISearchPhase[] phases = new ISearchPhase[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. There are some models which have particularly well-understood structure where giving such an order can have a dramatic impact on the solving time.

It is important to note that for constructing a search phase, not all the three parameters above are required. A search phase can be created with an array of variables only. The embedded search will then choose an instantiation strategy automatically. For instance, assuming that x and y are arrays of integer variables, the following code:

Examples

CP cp = new CP(); ISearchPhase[] phases = new ISearchPhase[2]; phases[0] = cp.SearchPhase(x); phases[1] = cp.SearchPhase(y); cp.Solve(phases);

indicates to CP search that variables from the array x must be instantiated before those from the array y. The way to instantate them will be choosen by CP search.

Similarly, it is not necessary to specify an array of variables to a search phase. A search phase defined this way will be applied to every integer variable extracted from the model.

See Also