IBM ILOG Solver User's Manual > Evolutionary Algorithms > Bin Packing Using EA > Problem solving: Putting it together |
Problem solving: Putting it together |
INDEX
![]() |
Nearly everything is in place to create a genetic algorithm; there is an initial population, and a processor to produce offspring based on a combination of improvement, mutation or crossover, and solution completion via decreasing first fit. All that remains is to decide on a parent selection strategy, a replacement strategy whereby new offspring will replace current population members, and to create a goal that will perform one complete generation of the genetic algorithm.
Here, a random parent selection strategy is chosen, together with a full replacement strategy. The latter produces as many offspring as there are population members, and completely replaces the population by the offspring.
Step 7 - | Create the single generation goal |
All this is done fairly concisely by the following code which you add after the comment // Single generation goal
A pool to contain the offspring is created, as is a random selector for selection of parents. Then a processor is constructed which performs selection and breeding and places the result in the offspring pool. The breeding operator is instructed to produce popSize
solutions via the function call operator. The goal to run a generation of the genetic algorithm is then constructed by chaining IloExecuteProcessor
functions. First, gen
is executed which produces the offspring, the current population is destroyed, and finally the offspring are placed in the population pool.
The code of the genetic algorithm loop and display of the resulting solution is provided for you.
© Copyright IBM Corp. 1987, 2009. Legal terms. | PREVIOUS NEXT |