Skip to main content
FRAMES NO FRAMES

Class IloIntVarChooser

Definition file: ilcp/cp.h
Map of IloIntVarChooserIloIntVarChooserIloIntVarChooser
The handle class for a variable chooser in a search strategy.

This class is a handle class for IloIntVarChooserI and its sub-classes. A variable chooser is applied to an array of IloIntVar in a search strategy. It selects a single variable or no variable at all in the case where every variable in the array is fixed to a value.

In addition to the regular handle constructors, an instance of this handle class can also be created with a selector of variables or an array of such selectors.

When created with a sub-class of IloIntVarChooserI, the variable selected is the one whose index in the array is returned by the function IloInt IloIntVarChooserI::choose(IloCPEngine cp, IloIntVarArray x) .

An instance of IloIntVarChooser should be used in conjunction with the class IloSearchPhase or IloGoal which determine over which set of variables the chooser will be applied.

When created with a array of selectors (IloVarSelectorArray), the variable will be selected in the following way: the first selector in the array selects a set of variables from the considered variables (see IloSearchPhase and IloGoal). If more that one variable is selected at this stage, the next selector in the array is applied to the remaining variables and so on until only one variable remains or all selectors have been processed. If, at the end of this process, more than one variable remains, the one chosen will be the one with the smallest index in the array passed to the IloGoal or IloSearchPhase instance driving this chooser.

For instance the following code creates a variable chooser that selects the variable having the smallest domain size and break ties randomly:

     IloVarSelectorArray varSelArray(env);
     varSelArray.add(IloSelectSmallest(IloDomainSize(env)));
     varSelArray.add(IloSelectRandomVar(env));
     IloIntVarChooser varChooser(env, varSelArray);
 
Method Summary
public voidend()
public IloIntVarChooserI *getImpl() const
public IloIntVarChooser(IloIntVarChooserI * impl=0)
public IloIntVarChooser(IloEnv env, IloVarSelector varSel)
public IloIntVarChooser(IloEnv env, IloVarSelectorArray varSelArray)
Method Detail

IloIntVarChooser

public IloIntVarChooser(IloIntVarChooserI * impl=0)

This constructor creates a handle object from a pointer to an implementation object. If the implementation object is zero, you must initialize the handle before using it.


IloIntVarChooser

public IloIntVarChooser(IloEnv env, IloVarSelector varSel)

This constructor creates a variable chooser with an environment and a single variable selector.


IloIntVarChooser

public IloIntVarChooser(IloEnv env, IloVarSelectorArray varSelArray)

This constructor creates a variable chooser with an environment and an array of variable selectors.


end

public void end()

This member function ends the instance and returns the memory to the environment.


getImpl

public IloIntVarChooserI * getImpl() const

This member function returns a pointer to the implementation object of the invoking handle.