FRAMES NO FRAMES

Class IloExplicitEvaluator<>

Definition file: ilsolver/iimmulti.h
Include file: <ilsolver/iim.h>
An evaluator whose evaluations are specified explicitly.

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:

Constructor Summary
public IloExplicitEvaluator(IloEnv env, IloComparator< IloObject > cmp=0)

Creates an instance of an explicit evaluator.

Method Summary
public IloNumgetEvaluation(IloObject obj) const

Retrieves the evaluation of an object.

public IloIntgetNumberOfEvaluations() const

Delivers the number of evaluations stored in the evaluator.

public IloBoolhasEvaluation(IloObject obj) const

Determines of an object has an evaluation.

public voidremoveAllEvaluations()

Removes all evaluations from the evaluator.

public voidremoveEvaluation(IloObject obj)

Removes an evaluation from the evaluator.

public voidsetEvaluation(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

IloExplicitEvaluator

public IloExplicitEvaluator(IloEnv env, IloComparator< IloObject > cmp=0)
Creates an instance of an explicit evaluator.

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:


Method Detail

getEvaluation

public IloNum getEvaluation(IloObject obj) const
Retrieves the evaluation of an object.

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.

Note
This function exists mostly for symmetry with the 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.

getNumberOfEvaluations

public IloInt getNumberOfEvaluations() const
Delivers the number of evaluations stored in the evaluator.

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.


hasEvaluation

public IloBool hasEvaluation(IloObject obj) const
Determines of an object has an evaluation.

This member function determines if a given object obj has had an evaluation set via IloExplicitEvaluator::setEvaluation.


removeAllEvaluations

public void removeAllEvaluations()
Removes all evaluations from the evaluator.

The member function removes all evaluations from the evaluation, and is particularly useful when you wish to start again with an empty evaluator.


removeEvaluation

public void removeEvaluation(IloObject obj)
Removes an evaluation from the 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.


setEvaluation

public void setEvaluation(IloObject obj, IloNum eval)
Sets the evaluation of an 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.