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 class
Evolution.EvolutionBuilder
static class
Evolution.Fitness
Fitness method enum.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Evolution.EvolutionBuilder
builder()
Evolution
clone()
Clones the evolution shallow.double
evalFitness(List<DiscreteGene> chromosome)
Evaluate fitness method.double
fitnessMulti(List<DiscreteGene> chromosome)
Compute the fitness of aDiscreteGene
chromosome based on all treasures.double
fitnessSingular(List<DiscreteGene> chromosome)
Compute the fitness of aDiscreteGene
chromosome based on the single first treasureDiscreteGene
.Configuration
getConfiguration()
Configuration to use during the evolution.List<io.jenetics.engine.EvolutionResult<DiscreteGene,Double>>
getHistory()
History of individuals with the best phenotype in each generation.void
run()
Execute an evolution Works with theConfiguration
held by this instance.void
setAborted(boolean aborted)
Evolution abort flag.void
setConfiguration(Configuration configuration)
Configuration to use during the evolution.void
setHistory(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 theConfiguration
held 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 aDiscreteGene
chromosome based on the single first treasureDiscreteGene
. This is the trace length of the individual visiting it'sDiscreteGene
s 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 aDiscreteGene
chromosome 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.
-
-