evolve

fun <V, F> CellularConfigScope<V, F>.evolve(evolution: suspend CellularEvolveScope<V, F>.() -> Unit)

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 N cell evolutionary strategies, where N - usually equal to CellularPopulation.size. Each of these strategies is applied to the corresponding cell chromosome within their neighborhood and can be separated into stages: selectioncrossovermutationevaluation like evolutionary 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.

// 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.

See also