Internal solve

An internal solve can be performed inside a goal.

When defining a custom goal, it may be useful to launch a sub-search with its own goal. In CP Optimizer, an internal solve can be performed inside a goal. To this aim, IloCPEngine provides the function:


 IlcBool solve(const IlcGoal goal, IlcBool restore = IlcFalse) const;

The parameter restore indicates whether or not at the end of the search the invoking engine should restore the state that it was in prior to the search.

IloCPEngine also provides the more general functions startNewSearch(const IlcGoal goal), next(), and endSearch().

Inside a goal you may write:


   ILCGOAL1(MyIlcGoal, IlcIntVarArray, x){
   IlcCPEngine cp = getCPEngine();
   IlcBool success = cp.solve(MySubIlcGoal(cp,...));
   if (success)
     ...
   else 
     ...
   }