IBM ILOG Solver User's Manual > Local Search > Combining Complete and Local Search: Locating Warehouses > Solve > Use local search

We create a goal to generate an initial solution, using the goal IloSetOffer. After execution of this goal we store the initial solution in both our solution instances.

    IloGoal g;
    IloInt upperBound = IloIntMax;
    IloSolver solver(env);
  
    // Inital solution
    // Complete search goal to assign clients to warehouses
    IloGoal generateOffer =
            IloSetOffer(env, offer, open, serveCosts, buildCosts);
    g = generateOffer &&
        IloStoreSolution(env, sol) &&
        IloStoreSolution(env, whole);
    solver.extract(m);
    if (solver.solve(g)) {
      DisplaySolution(solver, "Initial Solution", cost, offer);
    }
    else {
      solver.out() << "No initial solution" << endl;
      env.end();
      return 0;
    }

We perform the local search if desired. We build the subgoal to pass to the TabuSearch function. This subgoal is an instance of IloSetOffer and will open warehouses to customers at each move. When local search is complete, we take the value of the best solution as an upper bound and store it.

    if (local) {
      // Local Search
     
      // The sub-goal to assign clients to open warehouses, at minimum cost
      IloGoal subGoal = IloSelectSearch(env, generateOffer,
                                        IloMinimizeVar(env, cost, 1));
  
      // Run the tabu search
      TabuSearch(solver, open, sol, whole, subGoal, 30);
    }
    // Get the upper bound
    upperBound = (IloInt)whole.getObjectiveValue();