Overview | Group | Tree | Graph | Index | Concepts |
There are various situations in which the evaluations on which some decisions are based do not change throughout a whole program or stage of a program. In this instance, it can be useful (for reasons of efficiency) to store object evaluations explicitly, rather than recalculate them each time. This class is a special type of evaluator which, when asked to evaluate an object, returns the evaluation from its store.
See Also:
IloComparator, ILODEFAULTCOMPARATOR
Constructor Summary | |
---|---|
public | IloExplicitEvaluator(IloEnv env, IloComparator< IloObject > cmp=0) Creates an instance of an explicit evaluator. |
Method Summary | |
---|---|
public IloNum | getEvaluation(IloObject obj) const Retrieves the evaluation of an object. |
public IloInt | getNumberOfEvaluations() const Delivers the number of evaluations stored in the evaluator. |
public IloBool | hasEvaluation(IloObject obj) const Determines of an object has an evaluation. |
public void | removeAllEvaluations() Removes all evaluations from the evaluator. |
public void | removeEvaluation(IloObject obj) Removes an evaluation from the evaluator. |
public void | setEvaluation(IloObject obj, IloNum eval) Sets the evaluation of an object. |
Inherited Methods from IloEvaluator |
---|
makeGreaterThanComparator, makeLessThanComparator, operator() |
Inner Class | |
---|---|
IloExplicitEvaluator::Iterator | An iterator which will iterate over all evaluated objects in an explicit evaluator. |
Constructor Detail |
---|
This constructor creates an instance of an explicit evaluator
from an environment env
and an optional
comparator cmp
. In order
to correctly retrieve object evaluations, this class needs
to know how to compare the objects being evaluated, so that
when you ask for an evaluation of an object, the evaluator
can look up this object in its store. To do this, you may
pass a comparator cmp
which can make this comparison.
Note that this comparator is not used to determine if one object is
more favorable than another (for example see
IloBestSolutionComparator
),
but should compare the objects themselves.
If no comparator is passed, the evaluator tries to find one by
looking for those defined using ILODEFAULTCOMPARATOR
.
If such a comparator has been defined, it
will be used for object comparison.
The Solver IIM library has default comparators pre-defined for classes
IloSolution
and
IloPoolProc
. The
code for the default comparator for an
IloPoolOperator
could
be defined as follows:
ILODEFAULTCOMPARATOR(IloPoolOperator, a, b) { return a.getImpl() < b.getImpl(); }
See Also:
IloComparator, IloSolution, IloPoolProc, IloBestSolutionComparator, ILODEFAULTCOMPARATOR
Method Detail |
---|
This member function retieves the valuation of an object obj
previously set using IloExplicitEvaluator::setEvaluation
. If the
object in question has no evaluation associated with it
in the invoking object, and exception (of type IloException
)
is raised.
IloExplicitEvaluator::setEvaluation
member function. Normally
the evaluation of an object will be retieved via the
paranthesis operator on the evaluator. That is, for
an evaluator of type IloExplicitEvaluator
,
evaluator.getEvaluation(obj)
and
evaluator(obj)
are equivalent.
This member function returns the number of evaluations which have been added to the evaluator. It can be useful for dimensioning arrays and so forth before iterating over the evaluations.
This member function determines if a given object obj
has
had an evaluation set via IloExplicitEvaluator::setEvaluation
.
The member function removes all evaluations from the evaluation, and is particularly useful when you wish to start again with an empty evaluator.
The member function removes the evaluation of
a particular object obj
from the evaluator. This
does not mean that the evaluation is set to a
particular value (for example zero), but that
after the call, the invoking evaluator will have
no evaluation at all for the specified object.
This member function is used to set the evaluation of an object
obj
to value eval
. If the given object
has no evaluation in
the invoking evaluation, that object is added together with its
new evaluation. Otherwise, the evaluation of the specified
object is changed to the newly specified value.