FRAMES NO FRAMES

Class IloComparator<>

Definition file: ilsolver/iloselector.h
Include file: <ilsolver/iloselector.h>

A comparator is a class that implements a comparison between two objects. IloComparator is a template class, meaning that it can be instantiated to define a comparator for user-defined classes.

A comparator can be constructed from a single evaluator (see member functions IloEvaluator::makeLessThanComparator, IloEvaluator::makeGreaterThanComparator), from a composition of evaluators (IloLexicographicComparator, IloParetoComparator), or by using macros (ILOCOMPARATOR0 and ILOCLIKECOMPARATOR0).

There are two main comparison functions of a comparator: operator() and isBetterThan.

The function operator() takes two objects, o1 and o2, and by default returns -1, 0, or 1 depending on whether o1 is respectively better, equal or worse than o2. The optional argument nu is a context that can be used for the comparison:

 IloInt operator()(IloObject o1, IloObject o2, IloAny nu = 0) const;
 

The function isBetterThan takes two objects, o1 and o2, and returns IloTrue if and only if o1 is preferred to o2. The optional argument nu is a context that can be used for the comparison:

 IloBool isBetterThan(IloObject o1, IloObject o2, IloAny nu = 0) const;
 

It is possible to combine comparators and evaluators into more complicated comparators. See IloLexicographicComparator and IloParetoComparator.

For more information, see Selectors.

See Also:

Method Summary
public IloBoolisBetterOrEqual(IloObject left, IloObject right, IloAny nu=0) const

Returns IloTrue when the left-hand side is better than or equal to the right-hand side.

public IloBoolisBetterThan(IloObject left, IloObject right, IloAny nu=0) const

Returns IloTrue when the left-hand side is better than the right-hand side.

public IloBoolisEqual(IloObject left, IloObject right, IloAny nu=0) const

Returns IloTrue if and only if the left-hand side is of equal quality to the right-hand side.

public IloBoolisWorseOrEqual(IloObject left, IloObject right, IloAny nu=0) const

Returns IloTrue when the left-hand side is worse than or equal to the right-hand side.

public IloBoolisWorseThan(IloObject left, IloObject right, IloAny nu=0) const

Returns IloTrue when the left-hand side is worse than the right-hand side.

public IloComparator< IloObject >makeInverse() const

Inverts the sense of a comparator. The returned comparator compares as the invoking comparator, but with the objects being compared interchanged.

public IloIntoperator()(IloObject left, IloObject right, IloAny nu=0) const
Method Detail

isBetterOrEqual

public IloBool isBetterOrEqual(IloObject left, IloObject right, IloAny nu=0) const
Returns IloTrue when the left-hand side is better than or equal to the right-hand side.

This member function returns IloTrue if and only if the the left-hand side object left is better than or equal to the right-hand side object right. The parameter nu is a context that will be passed to the evaluator(s) of the comparator.

the comparator

isBetterThan

public IloBool isBetterThan(IloObject left, IloObject right, IloAny nu=0) const
Returns IloTrue when the left-hand side is better than the right-hand side.

This member function returns IloTrue if and only if the the left-hand side object left is better than the right-hand side object right. The parameter nu is a context that will be passed to the evaluator(s) of the comparator.

the comparator

isEqual

public IloBool isEqual(IloObject left, IloObject right, IloAny nu=0) const
Returns IloTrue if and only if the left-hand side is of equal quality to the right-hand side.

This member function returns IloTrue if and only if the the left-hand side object left is equal to the right-hand side object right. The parameter nu is a context that will be passed to the evaluator(s) of the comparator.

the comparator

isWorseOrEqual

public IloBool isWorseOrEqual(IloObject left, IloObject right, IloAny nu=0) const
Returns IloTrue when the left-hand side is worse than or equal to the right-hand side.

This member function returns IloTrue if and only if the the left-hand side object left is worse than or equal to the right-hand side object right. The parameter nu is a context that will be passed to the evaluator(s) of the comparator.

the comparator

isWorseThan

public IloBool isWorseThan(IloObject left, IloObject right, IloAny nu=0) const
Returns IloTrue when the left-hand side is worse than the right-hand side.

This member function returns IloTrue if and only if the the left-hand side object left is worse than the right-hand side object right. The parameter nu is a context that will be passed to the evaluator(s) of the comparator.

the comparator

makeInverse

public IloComparator< IloObject > makeInverse() const
Inverts the sense of a comparator. The returned comparator compares as the invoking comparator, but with the objects being compared interchanged.

This member function returns a comparator that inverts the sense of the invoking comparator. The returned comparator interchanges the objects to be compared.


operator()

public IloInt operator()(IloObject left, IloObject right, IloAny nu=0) const

This member function implements the comparison of two objects based on the evaluator with which the invoking comparator was created and based on the sense of comparison of the invoking comparator. This member function returns -1, 0, or 1 depending on whether object left is considered to be better, equal, or worse than object right. The parameter nu is a context that will be passed to the evaluator(s) of the comparator.

the comparator