IBM ILOG Scheduler User's Manual > Local Search in Scheduler > Tabu Search for the Jobshop Problem > Solving the Problem > Hill-climbing with the N1 Neighborhood

It is often the case at the beginning of a local search that improvements to the current solution can be made simply by greedy hill-climbing without using a metaheuristic. We define a local search goal move (using IloSingleMove as in the previous chapter), that scans the neighbors until it finds one that has a lower cost than the current solution. It immediately accepts that solution.

Because we are only scanning the neighbors until we find an improvement and because we have no metaheuristic, performing a single move during the hill-climbing phase is typically much faster that during the tabu phase. For move information about the IloSingleMove goal, see the IBM ILOG Solver User's Manual and IBM ILOG Solver Reference Manual.

  CriticalPath cp(env);
  IloNHood nhood = N1NHood(env, &cp);
  IloGoal greedyMove = IloSingleMove(env, 
                                     lsSolution, 
                                     nhood,
                                     IloImprove(env), 
                                     IloFirstSolution(env),
                                     IloInstantiate(env, makespan));

  IloInt maxIter = 100;
  IloInt movesDone = 0;
  while((movesDone < maxIter) && lsSolver.solve(greedyMove)) {
    IloNum cost = lsSolution.getSolution().getObjectiveValue();
    lsSolver.out() << "Move: " << movesDone << ":\t";
    ++movesDone;
    lsSolver.out() << "solution at cost: " << cost 
                   << " ** HC\n";
    best = cost;
    globalSolution.store(lsScheduler);
  }