Overview | Group | Tree | Graph | Index | Concepts |
A goal can be defined as a choice between other goals. The function
IlcOr
implements a goal as a choice between subgoals (between
two and five subgoals). When this goal is executed, the state of Solver,
including the state of the goal stack, is saved. This activity is called
setting a choice point. Then all the subgoals are saved as untried
subgoals of the choice point. Then the first untried subgoal is removed from
the set of untried subgoals of the choice point and is called. If it fails,
the state of Solver is restored and the next untried subgoal is called, and so on,
until either a subgoal succeeds or until no more untried subgoals remain. In the
latter case, the choice point itself fails. If the optional argument,
label
, is given, the choice point is labeled with it. The apparent
limitation to five subgoals can be overcome by several calls to IlcOr
since it is associative.
If a goal is null (that is, if its implementation is null), it will be silently transformed into a goal that always succeeds.
Examples:
For example, the following goal has three choices:
ILCGOAL0(PrintOne) { IloSolver s = getSolver(); s.out() << ?print one? << endl; return IlcOr(PrintX(s, 1), PrintX(s, 2), PrintX(s, 3))); }
Here is how to define a choice point with eight subgoals:
IlcOr(IlcOr(g1, g2, g3, g4, g5), IlcOr(g6, g7, g8));
For more information, see the concepts Goal and Choice Point.
See Also: