Overview | Group | Tree | Graph | Index | Concepts |
The ILOSELECTORi
macros define several functions named
name
that create and return an instance of selector
of objects of class tx
with a selection function using
i extra fields of type td1...td
i.
The signatures of these functions are:
IloSelector<tx,tc> name(IloEnv)
, that returns a selector allocated on the environment; andIloSelector<tx,tc> name(IloSolver)
, that returns a selector allocated on the solverThe user-written code specifies which element of the given
collection of type tc
is selected by invoking the
select(tx)
method.
Example
The following code defines a selector which randomly selects a variable in an array:
ILOSELECTOR0(RandomVariableInArraySelector, IlcIntVar, IlcIntVarArray, array) { IlcInt index = array[0].getManager().getRandom().getInt(array.getSize()-1); select(array[index]); }
This macro defines the following function:
IloSelector<IlcIntVar,IlcIntVarArray> RandomVariableInArraySelector(IloSolver);
For example, the following code defines an instance of a selector to
select a random variable in an IlcIntVarArray
:
IloSolver solver = ...; IloSelector<IlcIntVar,IlcIntVarArray> randomVariableInArraySelector = RandomVariableInArraySelector(solver); IlcIntVarArray array = ...; IlcIntVar selected; IlcBool isSelected = randomVariableInArraySelector.select(selected, array);
For more information, see Selectors.