Goal stack

The goal stack determines the order of execution of the goals.

The member functions IloCP::solve and IloCP::next control the execution of goals. The first time one of these member functions is called, it creates a stack of goals, called the goal stack.

Note:

Goals must be called by IloCP::solve, a IloCP::startNewSearch/IloCP::next pair, or by other goals. Otherwise, they are not executed.

At the Concert Technology level, an instance of an IloGoal is passed as an argument to the member functions IloCP::solve or IloCP::startNewSearch. The function IloCP::solve pushes the corresponding search layer goal onto the goal stack of the invoking IloCP optimizer object and then executes the subgoal at the top of the stack. The function IloCP::startNewSearch pushes the corresponding search layer goal onto the goal stack of the invoking IloCP optimizer object, but does not execute it immediately. The member function IloCP::next pops the goal which is on top of the goal stack, if any, and executes it. In both cases, when the current goal execution is finished, the goal at the top of the stack is popped and executed. Thus goals are executed in the order first in, last out. If the goal stack is empty, the call to solve or next terminates and returns IloTrue.

Note:

For goals composed of conjunctions (subgoals joined with IlcAnd or operator&&), they subgoals are pushed onto the goal stack starting with the rightmost goal in the sequence.