p GAs
inline fun <V, F> DistributedConfig<V, F>.pGAs(count: Int, crossinline population: DistributedPopulationMultiFactory.() -> PanmicticPopulation<V, F>, crossinline fitnessFunction: (index: Int) -> (V) -> F = { this.fitnessFunction }, config: PanmicticConfigScope<V, F>.(index: Int) -> Unit): List<PanmicticGA<V, F>>
Creates PanmicticGAs as children for DistributedGA using Distributed Inheritance
(see DistributedConfig) with Kotlin DSL.
PanmicticGA.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 Panmictic GAs as children to Distributed GA
+pGAs(
count = 5,
population = { population(size = 50) },
) {
elitism = 5
evolve {
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
count
number of children will be created
population
factory of population of PanmicticGA
fitness Function
factory of fitness function for evaluation step, default value DistributedGA.fitnessFunction
config
scope function to initialize PanmicticGA