evolve
Applies evolutionary strategy
for CellularGA (Cellular Genetic Algorithm) as evolution function in CellularEvolveScope that includes the process of changing the population for one iteration.
evolutionary strategy
of CellularGA is to separate chromosomes and their neighborhoods into Ncell evolutionary strategies
, where N - usually equal to CellularPopulation.size. Each of these strategies is applied to the correspondingcell
chromosome within theirneighborhood
and can be separated into stages:selection
→crossover
→mutation
→evaluation
likeevolutionary strategy
of PanmicticGA.
Example for Von Neumann neighborhood with radius = 1
:
X X X X X
X X N X X
X N C N X
X X N X X
X X X X X
Where C
- target cell chromosome, N
- neighbors for current target chromosomes, X
- other chromosomes in population. cell evolutionary strategy
is to obtain the child chromosome from C
chromosome (first parent) and second parent (can be only chosen among N
chromosomes), the resulting child can replace C
chromosome in population.
To create an
cell evolutionary strategy
, declare the evolveCells operator inside the evolve function and specify the evolution function in CellEvolveScope for CellEvolveScope.cell and its CellEvolveScope.neighbors. evolveCells operator will execute CellularPopulation.size cell-evolutions what will create a new generation, see example below:
// init CellularGA
cGA(
// configure population and fitnessFunction
) {
// set ga's configuration here
evolve {
// actual population here
evolveCells {
selTournament(size = 3)
cxOnePoint(chance = 0.9)
mutFlipBit(chance = 0.2, flipBitChance = 0.02)
evaluation()
}
// offspring here (new generation)
println("Iteration $iteration: best fitness = $bestFitness")
stopBy(maxIteration = 50) { bestFitness == 100 }
}
}
Where C
- target chromosome, N
- neighbors for current target chromosomes, X
- other chromosomes in population.