IloSolver solver(model);
IloGoal goal = IloGenerate(env, cars, IloChooseMinSizeInt);
IloInt counter=0;
IloSearchLimit limit = IloMyLimit(env, counter, 2);
IloGoal finalGoal = IloLimitSearch(env, goal, limit);
solver.startNewSearch(finalGoal);
while (solver.next())
{
solver.out() << solver.getStatus() << " Solution" << endl;
if (solver.getValue(cars[5]) == 0) { // Car 6 is green
for (i = 0; i < nbCars; i++) {
solver.out() << "Car " << i+1 << " color: "
<< Names[(IloInt)solver.getValue(cars[i])]
<< endl;
}
counter++;
}
}
solver.endSearch();
|