|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jgap.Configuration
The Configuration class represents the current configuration of plugins and flags necessary to execute the genetic algorithm (such as fitness function, natural selector, genetic operators, and so on).
Note that, while during setup, the settings, flags, and other values may be set multiple times. But once the lockSettings() method is invoked, they cannot be changed. The default behavior of the Genotype constructor is to invoke this method, meaning that once a Configuration object is passed to a Genotype, it cannot be subsequently modified. There is no mechanism for unlocking the settings once they are locked.
Not all configuration options are required. See the documentation for each of the respective mutator methods to determine whether it is required to provide a value for that setting, and what the setting will default to if not.
| Constructor Summary | |
Configuration()
|
|
| Method Summary | |
void |
addGeneticOperator(GeneticOperator a_operatorToAdd)
Adds a genetic operator for use in this algorithm. |
void |
addNaturalSelector(NaturalSelector a_selector,
boolean processBeforeGeneticOperators)
Adds a NaturalSelector to the ordered chain of registered NaturalSelector's. |
BulkFitnessFunction |
getBulkFitnessFunction()
Retrieves the bulk fitness function previously setup in this Configuration object. |
ChromosomePool |
getChromosomePool()
Retrieves the ChromosomePool instance, if any, that is associated with this configuration. |
int |
getChromosomeSize()
Retrieves the chromosome size being used by this genetic algorithm. |
EventManager |
getEventManager()
Retrieves the EventManager associated with this configuration. |
FitnessEvaluator |
getFitnessEvaluator()
|
FitnessFunction |
getFitnessFunction()
Retrieves the fitness function previously setup in this Configuration object. |
java.util.List |
getGeneticOperators()
Retrieves the genetic operators setup in this Configuration instance. |
int |
getMinimumPopSizePercent()
|
NaturalSelector |
getNaturalSelector()
Deprecated. use getNaturalSelectors(true) or getNaturalSelectors(false) to obtain the relevant chain of NaturalSelector's and then call the chain's get(index) method |
NaturalSelector |
getNaturalSelector(boolean processBeforeGeneticOperators,
int index)
|
ChainOfSelectors |
getNaturalSelectors(boolean processBeforeGeneticOperators)
|
int |
getNaturalSelectorsSize(boolean processBeforeGeneticOperators)
|
int |
getPopulationSize()
Retrieves the population size setup in this Configuration instance. |
RandomGenerator |
getRandomGenerator()
Retrieves the random generator setup in this Configuration instance. |
Chromosome |
getSampleChromosome()
Retrieves the sample Chromosome that contains the desired Gene setup for each respective gene position (locus). |
boolean |
isLocked()
Retrieves the lock status of this object. |
void |
lockSettings()
Locks all of the settings in this configuration object. |
void |
setBulkFitnessFunction(BulkFitnessFunction a_functionToSet)
Sets the bulk fitness function to be used for this genetic algorithm. |
void |
setChromosomePool(ChromosomePool a_chromosomePoolToSet)
Sets the ChromosomePool that is to be associated with this configuration. |
void |
setEventManager(EventManager a_eventManagerToSet)
Sets the EventManager that is to be associated with this configuration. |
void |
setFitnessEvaluator(FitnessEvaluator a_fitnessEvaluator)
Set the fitness evaluator (deciding if a given fitness value is better when it's higher or better when it's lower). |
void |
setFitnessFunction(FitnessFunction a_functionToSet)
Sets the fitness function to be used for this genetic algorithm. |
void |
setMinimumPopSizePercent(int a_minimumSizeGuaranteedPercent)
|
void |
setNaturalSelector(NaturalSelector a_selectorToSet)
Deprecated. use addNaturalSelector(false) instead |
void |
setPopulationSize(int a_sizeOfPopulation)
Sets the population size to be used for this genetic algorithm. |
void |
setRandomGenerator(RandomGenerator a_generatorToSet)
Sets the random generator to be used for this genetic algorithm. |
void |
setSampleChromosome(Chromosome a_sampleChromosomeToSet)
Sets the sample Chromosome that is to be used as a guide for the construction of other Chromosomes. |
void |
verifyStateIsValid()
Tests the state of this Configuration object to make sure it's valid. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Configuration()
| Method Detail |
public void setFitnessFunction(FitnessFunction a_functionToSet)
throws InvalidConfigurationException
Note that it is illegal to set both this fitness function and a bulk fitness function. Although one or the other must be set, the two are mutually exclusive.
a_functionToSet - The fitness function to be used.
InvalidConfigurationException - if the fitness function
is null, a bulk fitness function has already been set,
or if this Configuration object is locked.public FitnessFunction getFitnessFunction()
public void setBulkFitnessFunction(BulkFitnessFunction a_functionToSet)
throws InvalidConfigurationException
Note that it is illegal to set both a bulk fitness function and a normal fitness function. Although one or the other is required, the two are mutually exclusive.
a_functionToSet - The bulk fitness function to be used.
InvalidConfigurationException - if the bulk fitness function
is null, the normal fitness function has already been set,
or if this Configuration object is locked.public BulkFitnessFunction getBulkFitnessFunction()
public void setSampleChromosome(Chromosome a_sampleChromosomeToSet)
throws InvalidConfigurationException
a_sampleChromosomeToSet - The Chromosome to be used as the sample.
InvalidConfigurationException - if the given Chromosome is null
or this Configuration object is locked.public Chromosome getSampleChromosome()
public int getChromosomeSize()
public void setNaturalSelector(NaturalSelector a_selectorToSet)
throws InvalidConfigurationException
a_selectorToSet - The natural selector to be used.
InvalidConfigurationException - if the natural selector
is null or this Configuration object is locked.public NaturalSelector getNaturalSelector()
public NaturalSelector getNaturalSelector(boolean processBeforeGeneticOperators,
int index)
processBeforeGeneticOperators - booleanindex - int
public ChainOfSelectors getNaturalSelectors(boolean processBeforeGeneticOperators)
processBeforeGeneticOperators - boolean
public int getNaturalSelectorsSize(boolean processBeforeGeneticOperators)
processBeforeGeneticOperators - boolean
public void setRandomGenerator(RandomGenerator a_generatorToSet)
throws InvalidConfigurationException
a_generatorToSet - The random generator to be used.
InvalidConfigurationException - if the random generator
is null or this object is locked.public RandomGenerator getRandomGenerator()
public void addGeneticOperator(GeneticOperator a_operatorToAdd)
throws InvalidConfigurationException
a_operatorToAdd - The genetic operator to add.
InvalidConfigurationException - if the genetic operator
is null of if this Configuration object is locked.public java.util.List getGeneticOperators()
public void setPopulationSize(int a_sizeOfPopulation)
throws InvalidConfigurationException
a_sizeOfPopulation - The population size to be used.
InvalidConfigurationException - if the population size
is not positive or this object is locked.public int getPopulationSize()
public void setEventManager(EventManager a_eventManagerToSet)
throws InvalidConfigurationException
a_eventManagerToSet - the EventManager instance to use in this
configuration.
InvalidConfigurationException - if the event manager is null
or this Configuration object is locked.public EventManager getEventManager()
public void setChromosomePool(ChromosomePool a_chromosomePoolToSet)
throws InvalidConfigurationException
a_chromosomePoolToSet - The ChromosomePool instance to use.
InvalidConfigurationException - if this object is locked.public ChromosomePool getChromosomePool()
public void lockSettings()
throws InvalidConfigurationException
Prior to returning successfully, this method will first invoke the verifyStateIsValid() method to make sure that any required configuration options have been properly set. If it detects a problem, it will throw an InvalidConfigurationException and leave the object unlocked.
It's possible to test whether is object is locked through the isLocked() method.
It is ok to lock an object more than once. In that case, this method does nothing and simply returns.
InvalidConfigurationException - if this Configuration object is
in an invalid state at the time of invocation.public boolean isLocked()
public void verifyStateIsValid()
throws InvalidConfigurationException
InvalidConfigurationException - if the state of this Configuration
is not valid. The error message in the exception will detail
the reason for invalidity.
public void addNaturalSelector(NaturalSelector a_selector,
boolean processBeforeGeneticOperators)
throws InvalidConfigurationException
a_selector - the selector to be added to the chainprocessBeforeGeneticOperators - true: execute NaturalSelector before
any genetic operator will be applied, false: .. after..
InvalidConfigurationExceptionpublic void setMinimumPopSizePercent(int a_minimumSizeGuaranteedPercent)
public int getMinimumPopSizePercent()
public FitnessEvaluator getFitnessEvaluator()
public void setFitnessEvaluator(FitnessEvaluator a_fitnessEvaluator)
a_fitnessEvaluator - the FitnessEvaluator to be used
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||