IBM ILOG Solver User's Manual > Evolutionary Algorithms > Introduction and Basic Concepts > Features of the library > Solution pool processors

Solution pool processors are objects which perform quite a general role, and form the umbrella under which the various selection, replacement, and genetic operators reside. Solution pool processors are objects which take a solution pool as input and produce another solution pool as output. This quite general mechanism can be used to select solutions from the input pool to place on the output pool, or produce entirely new solutions on the output pool.

Processors can be chained so that the output of one processor becomes the input of another using the >> operator. Thus, pipelines of processors can be built up which embody quite complex algorithms. Below is a code which creates a processor which proc takes a solution pool, population, selects the three best solutions according to the value of the variable profit, then one solution randomly amongst those. The resulting solution is then placed in the pool selected.

IloSolutionPool selected(env);
IloEvaluator<IloSolution> evalProfit = IloSolutionEvaluator(env, profit);
IloComparator<IloSolution> cmpProfit = evalProfit.makeGreaterThanComparator();

IloBestSelector<IloSolution,IloSolutionPool> selBest(cmpProfit);
IloPoolProc selBestProc = IloSelectSolutions(env, selBest);

IloRandomSelector<IloSolution,IloSolutionPool> selRnd(env);
IloPoolProc selRndProc = IloSelectSolutions(env, selRnd);

IloPoolProc proc = population >> selBestProc(3) >> selRndProc >> selected;

Note that in the context of the >> operator, solution pools (in this case population and selected) can be used as processors. If the pool has no processors supplying it with solutions (population), it produces the specified pool on its output. If the pool appears elsewhere, then it passes on the solutions it receives (if there is another processor to the right) as well as placing them in the pool.

If a processor performs a genetic operation to produce a new solution, Solver's search and propagation is used to do this. One example of a processor which performs selection, then mutation, might be described as follows:

IloPoolProc select = IloSelectSolutions(
  env, IloRandomSelector<IloSolution,IloSolutionPool>(env)
);
IloEAOperatorFactory factory(env, vars);
IloPoolProc mutate = factory.mutate(probability);
IloPoolProc produce = population >> select >> mutate;

Note the use of the class IloEAOperatorFactory used to produce processors which perform genetic operations. This class will be fully introduced later.

Processors are executed by an instance of IloSolver using the IloExecuteProcessor goal. When executed, a process similar to extraction transforms the processors into Solver-based Ilc objects which perform the actual calculations. The operation of the processors is demand-based. To execute a pool processor, you ask the processor to produce a number of solutions, which is not specified will default to the natural number for the processor (usually one). When processors are in a chain, this request goes directly to the right-most processor of the chain. This processor in turn will calculate the number of solutions it needs as input to fulfill the request. The processor then asks the processor to its left in the chain for the number of solutions it needs before carrying out its work and producing the solutions required. If any processor fails to provide the number of solutions desired, it is repeatedly invoked until the number of solutions desired is attained. The number of solutions to supply can be specified using the parenthesis operator:

IloPoolProc select = IloSelectSolutions(
  env, IloRandomSelector<IloSolution,IloSolutionPool>(env)
);
IloEAOperatorFactory factory(env, vars);
IloPoolProc mutate = factory.mutate(probability);
IloPoolProc produce = population >> select >> mutate;
IloSolutionPool offspring(env);
solver.solve(IloExecuteProcessor(env, produce(30) >> offspring));

Here, the processor produce is asked to produce 30 solutions; the result is placed in the offspring solution pool.