H - The hypothesis class to use.public class GeneticAlgorithm<H extends AbstractHypothesis<H>> extends Object
| Constructor and Description |
|---|
GeneticAlgorithm(double crossOverRate,
double mutationRate,
int generationSize)
Constructs a new genetic algorithm.
|
| Modifier and Type | Method and Description |
|---|---|
Optional<H> |
findMaximum(java.util.function.Function<H,Boolean> loopCondition,
java.util.function.Supplier<H> hypothesisSupplier)
Perform the genetic operation.
|
public GeneticAlgorithm(double crossOverRate,
double mutationRate,
int generationSize)
crossOverRate - the fraction at which the cross over operator is applied to the population, between 0 and 1.mutationRate - the fraction at which the mutation operator is applied to the population, between 0 and 1.generationSize - the number of individual hypothesis in the population for each generation, greater than 1.IllegalArgumentException - if the parameters are illegal.public Optional<H> findMaximum(java.util.function.Function<H,Boolean> loopCondition, java.util.function.Supplier<H> hypothesisSupplier)
loopCondition - the abort condition that stays true while the maximum is not yet reached. Gets presented the best hypothesis as input.hypothesisSupplier - creation function for new hypothesis.Copyright © 2017. All rights reserved.