c GA
inline fun <V, F> DistributedConfig<V, F>.cGA(population: CellularPopulation<V, F>, noinline fitnessFunction: (V) -> F? = null, config: CellularConfigScope<V, F>.() -> Unit): CellularGA<V, F>
Creates CellularGA as child for DistributedGA using Distributed Inheritance
(see DistributedConfig) with Kotlin DSL.
CellularGA.random will be auto inherited from DistributedGA.random.
Example for OneMax task:
// init DistributedGA
dGA(
// configure common factory, fitnessFunction, population name and children (if already exist)
) {
// add Cellular GA as child to Distributed GA
+cGA(
population = population(dimens = Dimens.cube(length = 6)) {
booleans(size = 100)
},
) {
elitism = true
cellularType = CellularType.Synchronous
neighborhood = Moore(radius = 1)
evolve {
evolveCells {
selTournament(size = 3)
cxOnePoint(chance = 0.8)
mutFlipBit(chance = 0.2, flipBitChance = 0.01)
evaluation()
}
stopBy(maxIteration = 20) { bestFitness == 100 }
}
}
// set evolutionary strategy with evolve
evolve { (this = DistributedEvolveScope)
...
}
}
Content copied to clipboard
Parameters
population
population of CellularGA
fitness Function
fitness function for evaluation step, default value DistributedGA.fitnessFunction
config
scope function to initialize CellularGA