FRAMES NO FRAMES

Macro ILOSELECTOR0

Definition file: ilsolver/iloselector.h
ILOSELECTOR0(name, tx, tc, nc)
ILOSELECTOR1(name, tx, tc, nc, td, nd)
ILOSELECTOR2(name, tx, tc, nc, td1, nd1, td2, nd2)
ILOSELECTOR3(name, tx, tc, nc, td1, nd1, td2, nd2, td3, nd3)
ILOSELECTOR4(name, tx, tc, nc, td1, nd1, td2, nd2, td3, nd3, td4, nd4)
ILOSELECTOR5(name, tx, tc, nc, td1, nd1, td2, nd2, td3, nd3, td4, nd4, td5, nd5)
ILOSELECTOR6(name, tx, tc, nc, td1, nd1, td2, nd2, td3, nd3, td4, nd4, td5, nd5, td6, nd6)
ILOSELECTOR7(name, tx, tc, nc, td1, nd1, td2, nd2, td3, nd3, td4, nd4, td5, nd5, td6, nd6, td7, nd7)

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...tdi.

The signatures of these functions are:

The 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.