org.encog.ml.ea.train.basic
public class BasicEA extends Object implements EvolutionaryAlgorithm, MultiThreadable, EncogShutdownTask, Serializable
Constructor and Description |
---|
BasicEA(Population thePopulation,
CalculateScore theScoreFunction)
Construct an EA.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addChild(Genome genome)
Add a child to the next iteration.
|
void |
addOperation(double probability,
EvolutionaryOperator opp)
Add an operation.
|
void |
addScoreAdjuster(AdjustScore scoreAdjust)
Add a score adjuster.
|
void |
calculateScore(Genome g)
Calculate the score for a genome.
|
static void |
calculateScoreAdjustment(Genome genome,
List<AdjustScore> adjusters)
Calculate the score adjustment, based on adjusters.
|
void |
finishTraining()
Called when training is finished.
|
GenomeComparator |
getBestComparator()
Get the comparator that is used to choose the "true best" genome.
|
Genome |
getBestGenome() |
EvolutionaryOperator |
getChampMutation() |
GeneticCODEC |
getCODEC() |
double |
getEliteRate() |
double |
getError() |
int |
getIteration() |
int |
getMaxIndividualSize() |
int |
getMaxOperationErrors() |
int |
getMaxTries() |
Genome |
getOldBestGenome() |
OperationList |
getOperators() |
Population |
getPopulation() |
RandomFactory |
getRandomNumberFactory() |
RuleHolder |
getRules() |
List<AdjustScore> |
getScoreAdjusters() |
CalculateScore |
getScoreFunction() |
SelectionOperator |
getSelection() |
GenomeComparator |
getSelectionComparator()
Get the comparator that is used to choose the "best" genome for
selection, as opposed to the "true best".
|
boolean |
getShouldIgnoreExceptions() |
Speciation |
getSpeciation() |
int |
getThreadCount() |
boolean |
isValidationMode() |
void |
iteration()
Perform a training iteration.
|
void |
performShutdownTask() |
void |
reportError(Throwable t)
Called by a thread to report an error.
|
void |
setBestComparator(GenomeComparator theComparator)
Set the comparator.
|
void |
setChampMutation(EvolutionaryOperator champMutation) |
void |
setCODEC(GeneticCODEC theCodec)
Set the CODEC to use.
|
void |
setEliteRate(double eliteRate) |
void |
setIteration(int iteration)
Set the current iteration number.
|
void |
setMaxOperationErrors(int maxOperationErrors) |
void |
setMaxTries(int maxTries) |
void |
setPopulation(Population thePopulation)
Set the population.
|
void |
setRandomNumberFactory(RandomFactory randomNumberFactory) |
void |
setRules(RuleHolder rules)
Set the rules holder to use.
|
void |
setSelection(SelectionOperator selection)
Set the selection operator.
|
void |
setSelectionComparator(GenomeComparator theComparator)
Set the comparator that is used to choose the "best" genome for
selection, as opposed to the "true best".
|
void |
setShouldIgnoreExceptions(boolean b)
Determines if genetic operator exceptions should be ignored.
|
void |
setSpeciation(Speciation speciation)
Set the speciation method.
|
void |
setThreadCount(int numThreads)
Set the number of threads to use.
|
void |
setValidationMode(boolean validationMode)
Determine if the genomes should be validated.
|
public BasicEA(Population thePopulation, CalculateScore theScoreFunction)
thePopulation
- The population.theScoreFunction
- The score function.public static void calculateScoreAdjustment(Genome genome, List<AdjustScore> adjusters)
genome
- The genome to adjust.adjusters
- The score adjusters.public boolean addChild(Genome genome)
genome
- The child.public void addOperation(double probability, EvolutionaryOperator opp)
addOperation
in interface EvolutionaryAlgorithm
probability
- The probability of using this operator.opp
- The operator to add.public void addScoreAdjuster(AdjustScore scoreAdjust)
addScoreAdjuster
in interface EvolutionaryAlgorithm
scoreAdjust
- The score adjustor to add.public void calculateScore(Genome g)
calculateScore
in interface EvolutionaryAlgorithm
g
- The genome to calculate the score for.public void finishTraining()
finishTraining
in interface EvolutionaryAlgorithm
public GenomeComparator getBestComparator()
getBestComparator
in interface EvolutionaryAlgorithm
public Genome getBestGenome()
getBestGenome
in interface EvolutionaryAlgorithm
public EvolutionaryOperator getChampMutation()
public GeneticCODEC getCODEC()
getCODEC
in interface EvolutionaryAlgorithm
public double getEliteRate()
public double getError()
getError
in interface EvolutionaryAlgorithm
public int getIteration()
getIteration
in interface EvolutionaryAlgorithm
public int getMaxIndividualSize()
getMaxIndividualSize
in interface EvolutionaryAlgorithm
public int getMaxTries()
getMaxTries
in interface EvolutionaryAlgorithm
public Genome getOldBestGenome()
public OperationList getOperators()
getOperators
in interface EvolutionaryAlgorithm
public Population getPopulation()
getPopulation
in interface EvolutionaryAlgorithm
public RandomFactory getRandomNumberFactory()
public RuleHolder getRules()
getRules
in interface EvolutionaryAlgorithm
public List<AdjustScore> getScoreAdjusters()
getScoreAdjusters
in interface EvolutionaryAlgorithm
public CalculateScore getScoreFunction()
getScoreFunction
in interface EvolutionaryAlgorithm
public SelectionOperator getSelection()
getSelection
in interface EvolutionaryAlgorithm
public GenomeComparator getSelectionComparator()
getSelectionComparator
in interface EvolutionaryAlgorithm
public boolean getShouldIgnoreExceptions()
getShouldIgnoreExceptions
in interface EvolutionaryAlgorithm
public Speciation getSpeciation()
getSpeciation
in interface EvolutionaryAlgorithm
public int getThreadCount()
getThreadCount
in interface MultiThreadable
public boolean isValidationMode()
isValidationMode
in interface EvolutionaryAlgorithm
public void iteration()
iteration
in interface EvolutionaryAlgorithm
public void performShutdownTask()
performShutdownTask
in interface EncogShutdownTask
public void reportError(Throwable t)
t
- The error reported.public void setBestComparator(GenomeComparator theComparator)
setBestComparator
in interface EvolutionaryAlgorithm
theComparator
- The comparator.public void setChampMutation(EvolutionaryOperator champMutation)
champMutation
- the champMutation to setpublic void setCODEC(GeneticCODEC theCodec)
theCodec
- The CODEC to use.public void setEliteRate(double eliteRate)
eliteRate
- the eliteRate to setpublic void setIteration(int iteration)
iteration
- The iteration number.public void setMaxTries(int maxTries)
maxTries
- the maxTries to setpublic void setPopulation(Population thePopulation)
setPopulation
in interface EvolutionaryAlgorithm
thePopulation
- The population.public void setRandomNumberFactory(RandomFactory randomNumberFactory)
randomNumberFactory
- the randomNumberFactory to setpublic void setRules(RuleHolder rules)
EvolutionaryAlgorithm
setRules
in interface EvolutionaryAlgorithm
rules
- the rules to setpublic void setSelection(SelectionOperator selection)
setSelection
in interface EvolutionaryAlgorithm
selection
- The selection operator.public void setSelectionComparator(GenomeComparator theComparator)
setSelectionComparator
in interface EvolutionaryAlgorithm
theComparator
- The selection comparator.public void setShouldIgnoreExceptions(boolean b)
setShouldIgnoreExceptions
in interface EvolutionaryAlgorithm
b
- True if exceptions should be ignored.public void setSpeciation(Speciation speciation)
setSpeciation
in interface EvolutionaryAlgorithm
speciation
- The speciation method.public void setThreadCount(int numThreads)
setThreadCount
in interface MultiThreadable
numThreads
- The number of threads to use, or zero to
automatically determine based on core count.public void setValidationMode(boolean validationMode)
setValidationMode
in interface EvolutionaryAlgorithm
validationMode
- True, if validation mode is enabled.public int getMaxOperationErrors()
public void setMaxOperationErrors(int maxOperationErrors)
maxOperationErrors
- the maxOperationErrors to setCopyright © 2014. All Rights Reserved.