Overview | Group | Tree | Graph | Index | Concepts |
This macro allows you to create an evaluator that performs
an evaluation of all objects within a container.
The macro defines a function which creates an instance of
IloMultipleEvaluator
, whose purpose is to
keep an evaluation of each object in a specified container.
Normally, you would create an instance of IloEvaluator
to evaluate each object in a container. However,
sometimes you need to know all the objects at once in order to
perform the evaluation, which is when you should use this macro.
For example, an evaluator which produces as evaluation the
rank of an object according to its quality compared to
the other solutions requires this type of evaluation.
The four mandatory arguments of this macro are:
Depending on the exact version of the macro you use, you
may then add arguments, which will be present in the
generated function, using pairs of argument-type,argument-name
in the macro.
The function, setEvaluation
is available to you in the
macro, with the same semantics as
IloExplicitEvaluator::setEvaluation
. You should call
this function as many times as necessary to fill up the evaluator
with evaluations from the pool.
The following code shows a multiple evaluator which takes two additional parameters: another evaluator and a power parameter. The user-defined method raises values obtained from the given evaluator to the given power:
// Raise the result of an evaluator to a given power, and normalizes ILOMULTIPLEEVALUATOR2(PowerEvaluator, IloSolution, IloSolutionPool, pool, IloSolutionPoolEvaluator, eval, IloNum, power) { eval.update(pool); IloNum sum = 0.0; for (IloSolutionPool::Iterator it1(pool); it1.ok(); ++it1) sum += pow(eval(*it1), power); for (IloSolutionPool::Iterator it2(pool); it2.ok(); ++it2) setEvaluation(*it2, pow(eval(*it2), power) / sum); }
Notice that in this code sample, a subordinate multiple evaluator on solutions is passed as parameter. Here, the subordinate evaluator is updated to make sure its values are up to date before using them. This structure is relatively common practice.
See Also:
IloEvaluator, IloMultipleEvaluator, IloSolutionPoolEvaluator