Skip to main content
FRAMES NO FRAMES

Class IloSearchPhase

Definition file: ilcp/cp.h
Map of IloSearchPhaseIloSearchPhaseIloSearchPhase
The class for defining search strategies in CP Optimizer.

The class IloSearchPhase is an object that is used to define instantiation strategies to help the embedded CP Optimizer search. A search phase is composed of:

A search phase is given to an IloCP instance by invoking the method:

  void IloCP::setSearchPhases(const IloSearchPhase phase) const;
 

The embedded search strategy - that is determined by the value of the parameter IloCP::SearchType - will use the search phases to instantiate the variables for which a search phase is specified.

Several search phases can be given to an IloCP instance by way of an IloSearchPhaseArray. The member function that needs to be invoked for that purpose is:

   void IloCP::setSearchPhases(const IloSearchPhaseArray phaseArray) const;
 

The order of the search phases in the array is important. In the CP Optimizer search strategy, the variables will be instantiated phase by phase starting by 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:

   IloSearchPhaseArray phaseArray(env);
   phaseArray.add(IloSearchPhase(env, x, ..., ...));
   phaseArray.add(IloSearchPhase(env, 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:

   IloCP cp(env);
   IloSearchPhaseArray phaseArray(env);
   phaseArray.add(IloSearchPhase(env, x));
   phaseArray.add(IloSearchPhase(env, y));
   cp.setSearchPhases(phaseArray);
   cp.solve();
 

indicates to CP Optimizer search that variables from the array x must be instantiated before those from the array y. The way to instantiate them will be chosen by the CP Optimizer 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 decision variable of the appropriate type extracted from the model.

See Also:

Method Summary
public voidend()
public IloSearchPhase(IloEnv env, IloIntVarArray vars, IloIntVarChooser varChooser, IloIntValueChooser valueChooser)
public IloSearchPhase(IloEnv env, IloIntVarArray vars)
public IloSearchPhase(IloEnv env, IloIntVarChooser varChooser, IloIntValueChooser valueChooser)
public IloSearchPhase(IloEnv env, IloIntervalVarArray intervalVars)
public IloSearchPhase(IloEnv env, IloIntervalSequenceVarArray sequenceVars)
Method Detail

IloSearchPhase

public IloSearchPhase(IloEnv env, IloIntVarArray vars, IloIntVarChooser varChooser, IloIntValueChooser valueChooser)

This constructor creates a search phase with an array of variables and value choosers. The phase will use varChooser and valueChooser to determine how to instantiate variables in vars.


IloSearchPhase

public IloSearchPhase(IloEnv env, IloIntVarArray vars)

This constructor creates a search phase with an array of variables only. The variable and value choosers for these variables will be chosen by CP Optimizer search automatically.


IloSearchPhase

public IloSearchPhase(IloEnv env, IloIntVarChooser varChooser, IloIntValueChooser valueChooser)

This constructor creates a search phase with a variable and a value chooser. The variables instantiated by this phase are those extracted to the IloCP instance.


IloSearchPhase

public IloSearchPhase(IloEnv env, IloIntervalVarArray intervalVars)

This constructor creates a search phase with an array of interval variables. During this phase CP Optimizer fixes the value of interval variables specified in the array intervalVars: each interval variable in the array will be assigned a presence status and for each present interval, a start and an end value.

Note
This search phase fixes the start and end values of interval variables in an unidirectional manner, fixing first the intervals that will be assigned a small start or end value.

For more information on interval variables, see the concept Interval variables in CP Optimizer.


IloSearchPhase

public IloSearchPhase(IloEnv env, IloIntervalSequenceVarArray sequenceVars)

This constructor creates a search phase with an array of interval sequence variables. During this phase CP Optimizer fixes the value of interval sequence variables specified in the array sequenceVars: each sequence variable in the array will be assigned a totally ordered sequence of present interval variables. Note that this search phase also fixes the presence statuses of the intervals involved in the sequence variables. This phase does not fix the start and end values of interval variables.

Note
It is recommended to use this search phase only if the possible range for start and end values of all interval variables is limited (for example by some known horizon that limits their maximal values).

For more information on interval sequence variables see the concept Interval variable sequencing in CP Optimizer.


end

public void end()

This function releases all the memory allocated internally to create an instance.