FRAMES NO FRAMES

Macro ILOEVALUATOR0

Definition file: ilsolver/iloselector.h
ILOEVALUATOR0(name, tx, nx)
ILOEVALUATOR1(name, tx, nx, td, nd)
ILOEVALUATOR2(name, tx, nx, td1, nd1, td2, nd2)
ILOEVALUATOR3(name, tx, nx, td1, nd1, td2, nd2, td3, nd3)
ILOEVALUATOR4(name, tx, nx, td1, nd1, td2, nd2, td3, nd3, td4, nd4)
ILOEVALUATOR5(name, tx, nx, td1, nd1, td2, nd2, td3, nd3, td4, nd4, td5, nd5)
ILOEVALUATOR6(name, tx, nx, td1, nd1, td2, nd2, td3, nd3, td4, nd4, td5, nd5, td6, nd6)
ILOEVALUATOR7(name, tx, nx, td1, nd1, td2, nd2, td3, nd3, td4, nd4, td5, nd5, td6, nd6, td7, nd7)
ILOCTXEVALUATOR0(name, tx, nx, tu, nu)
ILOCTXEVALUATOR1(name, tx, nx, tu, nu, td, nd)
ILOCTXEVALUATOR2(name, tx, nx, tu, nu, td1, nd1, td2, nd2)
ILOCTXEVALUATOR3(name, tx, nx, tu, nu, td1, nd1, td2, nd2, td3, nd3)
ILOCTXEVALUATOR4(name, tx, nx, tu, nu, td1, nd1, td2, nd2, td3, nd3, td4, nd4)
ILOCTXEVALUATOR5(name, tx, nx, tu, nu, td1, nd1, td2, nd2, td3, nd3, td4, nd4, td5, nd5)
ILOCTXEVALUATOR6(name, tx, nx, tu, nu, td1, nd1, td2, nd2, td3, nd3, td4, nd4, td5, nd5, td6, nd6)
ILOCTXEVALUATOR7(name, tx, nx, tu, nu, td1, nd1, td2, nd2, td3, nd3, td4, nd4, td5, nd5, td6, nd6, td7, nd7)

The macros ILOEVALUATORi and ILOCTXEVALUATORi define one function named name that creates and returns an instance of an evaluator of objects of class tx with i data members of type td1...tdi. ILOCTXEVALUATORi allows an additional dynamic evaluation context to be passed to be used inside the user-defined evaluation function.

This function's signature returns an evaluator allocated on an environment or on a solver heap:

 IloEvaluator<tx> name(IloEnv, td1, ..., tdi);
 IloEvaluator<tx> name(IloSolver, td1, ..., tdi);
 

Note the important difference between data members and contexts. For a given instance of evaluator, data members represent a unique instance of object linked with the evaluator and given at construction time, whereas the context is given in the evaluation function at evaluation time and thus may change depending on the instance of object that is evaluated:

 IloEvaluator<tx>::operator()(tx nx, IloAny nu)
 

The two following examples show how to define an evaluator that evaluates the value of an instance of IloNumVar in a solution.

Example 1

In the first case, it is assumed that you may have to evaluate variables in different instances of solution so that the solution must be given as a context to the evaluation function:

 ILOCTXEVALUATOR0(ValueInContextualSolution,
                  IloNumVar, v,
                  IloSolution, solution) {
   assert(solution.isBound(v));
   return solution.getValue(v);
 }
 

The macro above defines the following function:

 IloEvaluator<IloNumVar> ValueInContextualSolution(IloEnv);

The evaluation function must be given the address of a solution handle as context:

 IloEnv env;
 IloNumVar v = ...;
 IloSolution solution = ...;
 IloEvaluator<IloNumVar> eval1 = ValueInContextualSolution(env);
 IloNum val = eval1(v, &solution);

Example 2

In the second case, it is assumed that you only have one instance of solution in the problem and that all the evaluations will use this solution so that the solution can be represented as a data member of the evaluator.

 ILOEVALUATOR1(ValueInTheSolution,
               IloFloatVar, v,
               IloSolution, solution) {
   assert(solution.isBound(v));
   return solution.getValue(v);
 }

The macro above defines the following function:

 IloEvaluator<IloNumVar> ValueInTheSolution(IloEnv, IloSolution);

The evaluation function does not use any context:

 IloEnv env;
 IloNumVar v = ...;
 IloSolution solution = ...;
 IloEvaluator<IloNumVar> eval2 = ValueInTheSolution(env, solution);
 IloNum val = eval2(v);

For more information, see Selectors.