IBM ILOG Scheduler User's Manual > Local Search in Scheduler > Shuffling as Local Search in Scheduler > Solving the Problem > Using the Shuffle Neighborhood

Once the neighborhood is defined, we use it to define a single move using the IloSingeMove functionality of IBM ILOG Solver.

  IloNHood nhood = ShuffleNHood(env, makespan, 0.2);
  IloGoal reschedGoal = IloLimitSearch(env,
				       IloTextureSuccessorGoal(env) && 
				       IloInstantiate(env, makespan),
				       IloFailLimit(env, 100));
  IloGoal move = IloSingleMove(env, 
			       lsSolution,
			       nhood,
			       reschedGoal);

The fourth argument of the IloSingeMove specifies a goal that is executed at the search state representing the local search neighbor. In our case, we specify a constructive search goal based on texture measurements and using a fail bound of 100. We use a fail bound because we are in a local search framework and so we do not want to fall into a situation where we cannot quickly find a constructive search extension of partial solution generated by the ShuffleNHood.

Also note that the probability that we provide to ShuffleNHood is 0.2. This means that on average 20% of the edges on the critical path will be preserved from one solution to the next.

Finally, in the same way that the IloSingleMove goal is often used in Solver, we enclose the solving algorithm within a loop. In this case, we attempt to find 100 solutions each of which must be as good or better than the preceding solution. In some cases, due to the fail bound, we will not be able to find a solution and so another neighbor will be visited based on the most recently found solution.

  IloInt maxIter = 100;
  for(IloInt i = 0; i < maxIter; ++i) {
    lsSolver.out() << "Move: " << i << ":\t";
    if (!lsSolver.solve(move))
      lsSolver.out() << "no solution" << endl;     
    else {
      IloNum cost = lsSolution.getSolution().getObjectiveValue();
      lsSolver.out() << "solution at cost: " << cost;
      if (cost < best) {
	globalSolution.store(lsScheduler);
	best = cost;
	lsSolver.out() << " **";
      }
      lsSolver.out() << endl;
    }
  }

  env.out() << "Final solution Cost: " << best << endl;