IBM ILOG Solver User's Manual > Extending the Library > Writing a Constraint: Allocating Frequencies > Writing a constraint: Frequency allocation > Search strategy: Algorithm

It is now possible to generate the different solutions. As explained before, the instantiation goal first tries the most used frequency, while the generation goal chooses the variable with the smallest domain and the least cardinality for a cell. The following code makes those choices.

ILCGOAL1(MyGenerate, IlcIntVarArray, vars) {
  IloSolver solver = getSolver();
  IlcInt chosen = IlcChooseClusterFreq(vars);
  if(chosen == -1)
    return 0;
  return IlcAnd(Instantiate(solver, vars[chosen]),this);
}

ILOCPGOALWRAPPER1(MyIloGenerate, solver, IloIntVarArray, vars) {
  return MyGenerate(solver, solver.getIntVarArray(vars));
}