FRAMES NO FRAMES

IloReplaceSolutions

public IloPoolProc IloReplaceSolutions(IloEnv env, IloSolutionPool target, IloSolutionPoolSelector selector=0)
Definition file: ilsolver/iimproc.h
Include file: <ilsolver/iim.h>
Returns a processor that will replace elements from a supplied pool with elements of the input pool.

This function creates a processor from an environment env, a solution pool target and a selector of solutions selector. The idea of the processor is to replace some of the solutions in target by those which are the input of the processor, such as to keep the size of target constant. The (optional) selector selector decides which solutions should be replaced. If none is specified, a selector selecting the worst solutions is used. The solutions identified by the selector are removed from the target and output by the processor.

The processor works as follows:

  1. Let n be the number of solutions in the input pool.
  2. selector is asked n times to select a solution from target.
  3. Each solution selected is removed from target and added to the processor's output pool.
  4. All solutions in the input pool are added to target.

The following code creates a processor which will replace some members of the population by offspring. The choice of population members to remove is made by a tournament selector, with a tournament size of 3. The tournament selector favors worse solutions so that poorer members of the population are replaced. Replaced solutions (dead ones) are supplied to the IloDestroyAll processor which will destroy them and reclaim the memory used:

    IloSolutionPool offspring(env, "offspring");
    IloTournamentSelector<IloSolution,IloSolutionPool> deadSelector(
      env, 3, IloWorstSolutionComparator(env)
    );
    IloGoal replacementGoal = IloExecuteProcessor(env,
      offspring >>
      IloReplaceSolutions(env, population, deadSelector) >>
      IloDestroyAll(env)
    );