Skip to main content
FRAMES NO FRAMES

Macro IlcChooseIndex1

Definition file: ilcp/cpext.h
IlcChooseIndex1
Macro to define a new variable choice function.

This macro defines a new choice function (a criterion) in CP Optimizer for setting parameters on the search for a solution, you use this macro if you have one integer criterion.

This macro defines a choice function for constrained variables of type varType. The name of the function will be name. The second argument, criterion, should be a C++ expression of type IlcInt. In that expression, the constrained variable to evaluate must be denoted by var. The index of the variable in the array is varIndex. The function named name returns the index of the constrained variable of type varType that minimizes the expression criterion. If all the constrained variables have already been fixed, then this function returns -1.

Example

As an example of how to use IlcChooseIndex1, the predefined criteria for constrained integer variables could be defined in the following way with this macro:

 IlcChooseIndex1(IlcChooseMinSizeInt,  var.getSize(), IlcIntVar);
 IlcChooseIndex1(IlcChooseMaxSizeInt, -var.getSize(), IlcIntVar);
 IlcChooseIndex1(IlcChooseMinMinInt,   var.getMin(),  IlcIntVar);
 IlcChooseIndex1(IlcChooseMinMaxInt,   var.getMax(),  IlcIntVar);
 IlcChooseIndex1(IlcChooseMaxMinInt,  -var.getMin(),  IlcIntVar);
 IlcChooseIndex1(IlcChooseMaxMaxInt,  -var.getMax(),  IlcIntVar);

See Also: