|
|||||||||||
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 |
addMutationOperator(MutationOperator a_operatorToAdd)
Add a mutation operator for use in this algorithm. |
void |
addReproductionOperator(ReproductionOperator a_operatorToAdd)
Add a reproduction operator for use in this algorithm. |
BulkFitnessFunction |
getBulkFitnessFunction()
Retrieves the bulk fitness function previously setup in this Configuration object. |
EventManager |
getEventManager()
Retrieves the EventManager associated with this configuration. |
FitnessFunction |
getFitnessFunction()
Retrieves the fitness function previously setup in this Configuration object. |
IdFactory |
getIdFactory()
|
java.util.List |
getMutationOperators()
Retrieve the mutation operators added for this genetic algorithm. |
NaturalSelector |
getNaturalSelector()
|
int |
getPopulationSize()
Retrieves the population size setup in this Configuration instance. |
java.util.Random |
getRandomGenerator()
Retrieves the random generator setup in this Configuration instance. |
java.util.List |
getReproductionOperators()
Retrieve the reproduction operators added for this genetic algorithm. |
ChromosomeMaterial |
getSampleChromosomeMaterial()
Retrieves sample ChromosomeMaterial that contains the desired Gene setup for each respective gene position (locus). |
SpeciationParms |
getSpeciationParms()
|
boolean |
isLocked()
Retrieves the lock status of this object. |
void |
lockSettings()
Locks all of the settings in this configuration object. |
java.lang.Long |
nextChromosomeId()
|
java.lang.Long |
nextInnovationId()
|
void |
setBulkFitnessFunction(BulkFitnessFunction a_functionToSet)
Sets the bulk fitness function to be used for this genetic algorithm. |
void |
setEventManager(EventManager a_eventManagerToSet)
Sets the EventManager that is to be associated with this configuration. |
void |
setFitnessFunction(FitnessFunction a_functionToSet)
Sets the fitness function to be used for this genetic algorithm. |
void |
setIdFactory(IdFactory factory)
|
void |
setNaturalSelector(NaturalSelector selector)
set selector |
void |
setPopulationSize(int a_sizeOfPopulation)
Sets the population size to be used for this genetic algorithm. |
void |
setRandomGenerator(java.util.Random a_generatorToSet)
Sets the random generator to be used for this genetic algorithm. |
void |
setSampleChromosomeMaterial(ChromosomeMaterial a_sampleChromosomeMaterial)
Sets sample ChromosomeMaterial that is to be used as a guide for the construction of other Chromosomes. |
protected void |
verifyChangesAllowed()
Makes sure that this Configuration object isn't locked. |
void |
verifyStateIsValid()
Tests the state of this Configuration 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 java.lang.Long nextChromosomeId()
public java.lang.Long nextInnovationId()
public void setNaturalSelector(NaturalSelector selector) throws InvalidConfigurationException
selector
-
InvalidConfigurationException
public NaturalSelector getNaturalSelector()
public void addReproductionOperator(ReproductionOperator a_operatorToAdd) throws InvalidConfigurationException
a_operatorToAdd
- The reproduction operator to be added.
InvalidConfigurationException
- if the reproduction operator is null a_operatorToAdd
this object is locked.public java.util.List getReproductionOperators()
public void addMutationOperator(MutationOperator a_operatorToAdd) throws InvalidConfigurationException
a_operatorToAdd
- The mutation operator to be added.
InvalidConfigurationException
- if the mutation operator is null a_operatorToAdd this
object is locked.public java.util.List getMutationOperators()
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 setSampleChromosomeMaterial(ChromosomeMaterial a_sampleChromosomeMaterial) throws InvalidConfigurationException
a_sampleChromosomeMaterial
- ChromosomeMaterial to be used as the sample.
InvalidConfigurationException
- if the given Chromosome is null or this Configuration
object is locked.public ChromosomeMaterial getSampleChromosomeMaterial()
public void setRandomGenerator(java.util.Random 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 java.util.Random getRandomGenerator()
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 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.protected void verifyChangesAllowed() throws InvalidConfigurationException
InvalidConfigurationException
- if this Configuration object is locked.public IdFactory getIdFactory()
public void setIdFactory(IdFactory factory)
factory
- factory for generating unique IDspublic SpeciationParms getSpeciationParms()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |