IBM ILOG Solver User's Manual > More on Modeling > Reducing Symmetry: Configuring Racks > Solve

To search for a solution, you instantiate the type of each rack using IloInstantiate and generate the counters of each rack using IloGenerate. Counters with the smallest domain are bound first. The function Generate searches for a solution.

    IloGoal goal = IloGoalTrue(env);
    for(i=0;i<nbRack;i++){
      goal = goal && IloInstantiate(env, racks[i]->_type);
      goal = goal && IloGenerate(env, racks[i]->_counters);
    }

This goal is used in the main function like this:

    IloSolver solver(model);

    if (solver.solve(goal)) {
      solver.out() << endl
                   << "Found an " << solver.getStatus()<< " solution at cost "
                   << solver.getValue(objective) << endl << endl;
      for(i = 0; i < nbRack; i++) {
        if (solver.getValue(racks[i]->_type) !=0) {
          solver.out() << "Rack " << i << endl
                       << "Type : " << solver.getValue(racks[i]->_type)
                       << endl << "Price : "
                       << solver.getValue(racks[i]->_price) << endl
                       << "Counters : ";
          for (j = 0; j < nbCardTypes; j++)
            solver.out() << solver.getValue(racks[i]->_counters[j]) << " ";
          solver.out() << endl << endl;
        }
      }
    }
    else
      solver.out() << "No solution" << endl;