Overview | Group | Tree | Graph | Index | Concepts |
Goals are the building blocks used to implement search algorithms in Solver. Both predefined search algorithms and user-defined search algorithms can be expressed in Solver through goals.
Like other Solver entities, a goal is implemented by two objects: a handle (an instance of the class IlcGoal) that contains a data member (the handle pointer) that points to an implementation object (an instance of the class IlcGoalI allocated on the Solver heap).
Among other member functions, the class IlcGoalI has a virtual member function,
execute
, without arguments, which implements the execution of
the goal. The execute
member function must return another goal:
the subgoal of the goal under execution. If the
execute
member function returns 0 (zero), then no subgoal has
to be executed.
A goal can either succeed or fail. A goal fails if a fail
member function (such as IlcGoalI::fail, for
example) is called during its execution. A goal succeeds if it does not
fail.
Goal execution is controlled by the member function IloSolver::next and implemented by a goal stack. The first
time this member function is called, it pushes all the goals that have been
added to the invoking solver onto the goal stack. Then it pops the top of
the stack, and if there is a goal there, it executes that goal. When the
execution of the current goal is complete, its subgoal is executed (if the
current goal has any subgoals). If there are no remaining subgoals, then the
next goal on top of the stack is popped. The member function
next
stops when the goal stack is empty.
See the concept Choice Point for more information.
See Also