cGAs

inline fun <V, F> DistributedConfig<V, F>.cGAs(count: Int, crossinline population: DistributedPopulationMultiFactory.() -> CellularPopulation<V, F>, crossinline fitnessFunction: (index: Int) -> (V) -> F = { this.fitnessFunction }, config: CellularConfigScope<V, F>.(index: Int) -> Unit): List<CellularGA<V, F>>

Creates CellularGAs as children for DistributedGA using Distributed Inheritance (see DistributedConfig) with Kotlin DSL.

CellularGA.random for each child 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 GAs as children 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)
...
}
}

Parameters

count

number of children will be created

population

factory of population of CellularGA

fitnessFunction

factory of fitness function for evaluation step, default value DistributedGA.fitnessFunction

config

scope function to initialize CellularGA