Skip to main content
FRAMES NO FRAMES

IlcGenerate

public IlcGoal IlcGenerate(const IlcIntVarArray array, IlcChooseIntIndex chooseVariable=IlcChooseFirstNonFixedInt)
public IlcGoal IlcGenerate(const IlcIntVarArray array, IlcChooseIntIndex chooseVariable, IlcIntSelect select)
Definition file: ilcp/cpext.h
Include file: <ilcp/cpext.h>
A goal to assign values to the variables in an array.

CP Optimizer provides an enumeration algorithm with parameters that can be set for choosing the order in which variables are tried during the search for a solution.

This goal binds each constrained variable in its argument array; it does so by calling the function IlcInstantiate for each of them. The order in which the variables are fixed is controlled by the function chooseVariable. The argument select is passed to each call to IlcInstantiate, if that argument is provided.

Implementation

Here's how we could define that goal for IlcIntVar.

 ILCGOAL3(IlcIntGenerate,
          IlcIntVarArray, vars,
          IlcChooseIntIndex,   chooseIndex,
          IlcIntSelectI*, select){
   IlcInt index = chooseIndex(vars);
   if(index == -1) return 0;
   return IlcAnd(IlcIntInstantiate(getCPEngine(),
                                      vars[index],
                                      select),
                 this);
 }

 IlcGoal IlcGenerate(const IlcIntVarArray array,
                     IlcChooseIntIndex chooseIndex){
   return IlcIntGenerate(array.getCPEngine(),
                         array,
                         chooseIndex,
                         0);
 }

 IlcGoal IlcGenerate(const IlcIntVarArray array,
                     IlcChooseIntIndex chooseIndex,
                     IlcIntSelect select){
   return IlcIntGenerate(array.getCPEngine(),
                         array,
                         chooseIndex,
                         select.getImpl());
 }
 

See Also: