|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.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, mutation rate, 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)
Add a genetic operator for use in this algorithm. |
ChromosomePool |
getChromosomePool()
Retrieves the ChromosomePool instance, if any, that is associated with this configuration. |
int |
getChromosomeSize()
Retrieve the chromosome size being used by this genetic algorithm. |
EventManager |
getEventManager()
Retrieves the EventManager associated with this configuration. |
FitnessFunction |
getFitnessFunction()
Retrieve the fitness function being used by this genetic algorithm. |
java.util.List |
getGeneticOperators()
Retrieve the genetic operators added for this genetic algorithm. |
NaturalSelector |
getNaturalSelector()
Retrieve the natural selector being used by this genetic algorithm. |
int |
getPopulationSize()
Retrieve the population size being used by this genetic algorithm. |
RandomGenerator |
getRandomGenerator()
Retrieve the random generator being used by this genetic algorithm. |
Chromosome |
getSampleChromosome()
Retrieves the sample Chromosome that contains the desired Allele types at each respective gene location (locus). |
boolean |
isLocked()
Retrieve the lock status of this object. |
void |
lockSettings()
Lock all of the settings in this configuration object. |
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 |
setFitnessFunction(FitnessFunction a_functionToSet)
Set the fitness function to be used for this genetic algorithm. |
void |
setNaturalSelector(NaturalSelector a_selectorToSet)
Set the natural selector to be used for this genetic algorithm. |
void |
setPopulationSize(int a_sizeOfPopulation)
Set the population size to be used for this genetic algorithm. |
void |
setRandomGenerator(RandomGenerator a_generatorToSet)
Set 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. |
protected void |
verifyChangesAllowed()
Makes sure that this object isn't locked. |
void |
verifyStateIsValid()
Test the state of this object to make sure it's valid. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Configuration()
| Method Detail |
public void setFitnessFunction(FitnessFunction a_functionToSet)
throws InvalidConfigurationException
InvalidConfigurationException - if the fitness function
is not satisfactory or if this object is locked.public FitnessFunction getFitnessFunction()
public void setSampleChromosome(Chromosome a_sampleChromosomeToSet)
throws InvalidConfigurationException
a_sampleChromosomeToSet - The Chromosome to be used as the sample.
InvalidConfigurationException - if the given Chromosome is not
satisfactory, this Configuration is locked, or the sample
Allele has already been set.public Chromosome getSampleChromosome()
public void setNaturalSelector(NaturalSelector a_selectorToSet)
throws InvalidConfigurationException
a_selectorToSet - The natural selector to be used.
InvalidConfigurationException - if the natural selector
is not satisfactory or this object is locked.public NaturalSelector getNaturalSelector()
public void setRandomGenerator(RandomGenerator a_generatorToSet)
throws InvalidConfigurationException
a_generatorToSet - The random generator to be used.
InvalidConfigurationException - if the random generator
is not satisfactory or this object is locked.public RandomGenerator getRandomGenerator()
public void addGeneticOperator(GeneticOperator a_operatorToAdd)
throws InvalidConfigurationException
a_operatorToAdd - The genetic operator to be added.
InvalidConfigurationException - if the genetic operator
is null a_operatorToAdd this robject is locked.public java.util.List getGeneticOperators()
public int getChromosomeSize()
public void setPopulationSize(int a_sizeOfPopulation)
throws InvalidConfigurationException
a_sizeOfPopulation - The population size to be used.
InvalidConfigurationException - if the population size
is not satisfactory 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 population size
is not satisfactory or this 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 this case, this method does nothing and simply returns.
InvalidConfigurationException - if the 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.
protected void verifyChangesAllowed()
throws InvalidConfigurationException
InvalidConfigurationException - if this object is locked.
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||