9.2.1. Objectives and Constraints

An optimisation problem is defined by an objective (may be more for multi-objective problems) and eventually some constraints (objectives can as well be called criteria in various literature). An item evaluation may return many values. Some of them may be used as objectives or constraints, while the others are left unused by the solver. The master methods addObjective, addConstraint and addEquality may be used to declare the corresponding values. The last method is only available in local solver. All these methods have a first argument, the output variable (a pointer to its corresponding TAttribute object), and a second optional argument (a pointer to a modifier object).

Modifiers are used to overwrite the default solver behaviour: objectives have to be minimised, constraints are satisfied when their values are lesser than zero, and equality when their value is zero. Once this is settled and when the returned value does not fit with these defaults, a modifier have to be used. Existing modifier classes are:

  • TMaximizeFit objective modifier: value has to be maximised.

  • TTargetFit objective modifier: value has to be closed to a target value.

  • TLesserFit constraint modifier: value has to be lesser than a threshold value.

  • TGreaterFit constraint modifier: value has to be greater than a threshold value.

  • TInsideFit constraint modifier: value has to be inside a domain.

The chosen threshold value(s) are passed in the constructor.

Warning

In the current implementation, it is not allowed to use an input variable as an objective or a constraint.