|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.math3.genetics.GeneticAlgorithm
public class GeneticAlgorithm
Implementation of a genetic algorithm. All factors that govern the operation of the algorithm can be configured for a specific problem.
Constructor Summary | |
---|---|
GeneticAlgorithm(CrossoverPolicy crossoverPolicy,
double crossoverRate,
MutationPolicy mutationPolicy,
double mutationRate,
SelectionPolicy selectionPolicy)
Create a new genetic algorithm. |
Method Summary | |
---|---|
Population |
evolve(Population initial,
StoppingCondition condition)
Evolve the given population. |
CrossoverPolicy |
getCrossoverPolicy()
Returns the crossover policy. |
double |
getCrossoverRate()
Returns the crossover rate. |
int |
getGenerationsEvolved()
Returns the number of generations evolved to reach StoppingCondition in the last run. |
MutationPolicy |
getMutationPolicy()
Returns the mutation policy. |
double |
getMutationRate()
Returns the mutation rate. |
static RandomGenerator |
getRandomGenerator()
Returns the (static) random generator. |
SelectionPolicy |
getSelectionPolicy()
Returns the selection policy. |
Population |
nextGeneration(Population current)
Evolve the given population into the next generation. |
static void |
setRandomGenerator(RandomGenerator random)
Set the (static) random generator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GeneticAlgorithm(CrossoverPolicy crossoverPolicy, double crossoverRate, MutationPolicy mutationPolicy, double mutationRate, SelectionPolicy selectionPolicy) throws OutOfRangeException
crossoverPolicy
- The CrossoverPolicy
crossoverRate
- The crossover rate as a percentage (0-1 inclusive)mutationPolicy
- The MutationPolicy
mutationRate
- The mutation rate as a percentage (0-1 inclusive)selectionPolicy
- The SelectionPolicy
OutOfRangeException
- if the crossover or mutation rate is outside the [0, 1] rangeMethod Detail |
---|
public static void setRandomGenerator(RandomGenerator random)
random
- random generatorpublic static RandomGenerator getRandomGenerator()
public Population evolve(Population initial, StoppingCondition condition)
generationsEvolved
property with the number of generations evolved before the StoppingCondition
is satisfied.
initial
- the initial, seed population.condition
- the stopping condition used to stop evolution.
public Population nextGeneration(Population current)
current
generation, using its nextGeneration methodcurrent
getCrossoverRate()
, apply
configured CrossoverPolicy
to parentsgetMutationRate()
, apply
configured MutationPolicy
to each of the offspring
current
- the current population.
public CrossoverPolicy getCrossoverPolicy()
public double getCrossoverRate()
public MutationPolicy getMutationPolicy()
public double getMutationRate()
public SelectionPolicy getSelectionPolicy()
public int getGenerationsEvolved()
StoppingCondition
in the last run.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |