Package evo.search
Class Evolution
- java.lang.Object
-
- evo.search.Evolution
-
- All Implemented Interfaces:
Serializable,Cloneable,Runnable
public class Evolution extends Object implements Runnable, Serializable, Cloneable
This class holds a configuration and executes a corresponding evolution.- Author:
- jotoh
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEvolution.EvolutionBuilderstatic classEvolution.FitnessFitness method enum.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Evolution.EvolutionBuilderbuilder()Evolutionclone()Clones the evolution shallow.doubleevalFitness(List<DiscreteGene> chromosome)Evaluate fitness method.doublefitnessMulti(List<DiscreteGene> chromosome)Compute the fitness of aDiscreteGenechromosome based on all treasures.doublefitnessSingular(List<DiscreteGene> chromosome)Compute the fitness of aDiscreteGenechromosome based on the single first treasureDiscreteGene.ConfigurationgetConfiguration()Configuration to use during the evolution.List<io.jenetics.engine.EvolutionResult<DiscreteGene,Double>>getHistory()History of individuals with the best phenotype in each generation.voidrun()Execute an evolution Works with theConfigurationheld by this instance.voidsetAborted(boolean aborted)Evolution abort flag.voidsetConfiguration(Configuration configuration)Configuration to use during the evolution.voidsetHistory(List<io.jenetics.engine.EvolutionResult<DiscreteGene,Double>> history)History of individuals with the best phenotype in each generation.
-
-
-
Method Detail
-
run
public void run()
Execute an evolution Works with theConfigurationheld by this instance. Clears out the history and the last result.Stores the history of the generations in
history.
-
fitnessSingular
public double fitnessSingular(List<DiscreteGene> chromosome)
Compute the fitness of aDiscreteGenechromosome based on the single first treasureDiscreteGene. This is the trace length of the individual visiting it'sDiscreteGenes until the treasure is found.- Parameters:
chromosome- chromosome to evaluate- Returns:
- chromosome fitness based on single treasure
- See Also:
AnalysisUtils.traceLength(List, DiscreteGene)
-
fitnessMulti
public double fitnessMulti(List<DiscreteGene> chromosome)
Compute the fitness of aDiscreteGenechromosome based on all treasures.The fitness of the chromosome is the sum of all singular fitnesses divided by the amount of treasures.
- Parameters:
chromosome- chromosome to evaluate- Returns:
- chromosome fitness based on multiple treasures
- See Also:
AnalysisUtils.traceLength(List, DiscreteGene)
-
evalFitness
public double evalFitness(List<DiscreteGene> chromosome)
Evaluate fitness method.- Parameters:
chromosome- chromosome to evaluate- Returns:
- evaluated fitness
-
clone
public Evolution clone()
Clones the evolution shallow.
-
builder
public static Evolution.EvolutionBuilder builder()
-
getConfiguration
public Configuration getConfiguration()
Configuration to use during the evolution.
-
setConfiguration
public void setConfiguration(Configuration configuration)
Configuration to use during the evolution.
-
getHistory
public List<io.jenetics.engine.EvolutionResult<DiscreteGene,Double>> getHistory()
History of individuals with the best phenotype in each generation.
-
setHistory
public void setHistory(List<io.jenetics.engine.EvolutionResult<DiscreteGene,Double>> history)
History of individuals with the best phenotype in each generation.
-
setAborted
public void setAborted(boolean aborted)
Evolution abort flag.
-
-