IBM ILOG Solver User's Manual > Local Search > Combining Complete and Local Search: Locating Warehouses > Solve > Create the solution object

We create two solution objects. The first, sol, holds only the variables open, and is used to perform a local search over which warehouses are open (built) and which are closed (not built). The second solution whole maintains the assignment of a warehouse to each customer and so represents a proper solution to the problem. It is only used to store solutions as they are found and not used actively in the local search process. As mentioned previously, local search decides which warehouses will be open or closed, but the assignment of warehouses to customers is performed by a complete search goal, executed after each move.

    // Set up two solutions.
    // sol: Holds only the 0-1 variables which defining the open warehouses
    // whole: Holds the variables which assign a warehouse to each client
    // NOTE: whole defines a solution, whereas sol only defines which
    //       warehouses will be used.  The clients must be then be assigned
    //       a specific warehouse each for a complete solution.
    //       We perform local search over the openness of warehouses,
    //       and at each move assign the customers to warehouses.
    IloSolution sol(env);
    IloObjective obj = IloMinimize(env, cost);
    sol.add(obj);
    for (i = 0; i < nbWhouses; i++) {
      char name[10];
      sprintf(name, "O-%ld", i);
      open[i].setName(name);
      sol.add(open[i]);
    }
    IloSolution whole(env);
    whole.add(obj);
    whole.add(offer);