Goals

Engine goals are used in the search.

Goals are the building blocks used to implement search algorithms in CP Optimizer. Both predefined search algorithms and user-defined search algorithms can be expressed in CP Optimizer through goals.

Like other CP Optimizer 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 CP Optimizer heap).

Among other member functions, the class IlcGoalI has a virtual member function, execute, 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 functions IloCP::next or IloCP::solve 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 optimizer 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.