IBM ILOG Solver User's Manual > More on Solving > Searching for Optimal Solutions: Replanning Warehouses > Finding feasible solutions

Before discussing optimal solutions in greater depth, let's review how Solver finds feasible solutions. There are two basic ways to do this. The member function IloSolver::solve, when used in a model without an objective, will simply find the first feasible solution. For example, in Chapter 2, Modeling and Solving a Simple Problem: Map Coloring, you used IloSolver::solve in an if statement to find the first feasible solution to the problem:

    if (solver.solve()) 

The member functions IloSolver::startNewSearch, IloSolver::next, and IloSolver::endSearch can be used in a while loop to find all feasible solutions to a problem. For example, in Chapter 3, Using Arrays and Basic Search: Changing Money, you used these three member functions to search for all feasible solutions to the problem:

    solver.startNewSearch();
    IloInt solutionCounter = 0;
    while(solver.next()) {
      solver.out() << "solution  " << ++solutionCounter << ":\t";
      for (IloInt i = 0; i < nCoins; i++)
        solver.out() << solver.getValue(coins[i]) << " ";
      solver.out() << endl;
    }
    solver.endSearch();