Class Configuration
- java.lang.Object
-
- org.jgap.Configuration
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, Configurable, ICloneable
- Direct Known Subclasses:
- DefaultConfiguration, GPConfiguration, PermutingConfiguration
public class Configuration extends java.lang.Object implements Configurable, java.io.Serializable, ICloneable, java.lang.Comparable
The Configuration class represents the current configuration of plugins and parameters 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.
- Since:
- 1.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description classConfiguration.ConfigurationConfigurable
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.StringPROPERTY_BFITFNC_INSTstatic java.lang.StringPROPERTY_EVENT_MGR_INSTstatic java.lang.StringPROPERTY_FITEVAL_INSTstatic java.lang.StringPROPERTY_FITFUNC_INSTstatic java.lang.StringPROPERTY_JGAPFACTORY_CLASSConstant for class name of JGAP Factory to use.static java.lang.StringPROPERTY_SAMPLE_CHROM_INSTstatic java.lang.StringS_CHROMOSOME_SIZEstatic java.lang.StringS_CONFIGURATIONConstants for toString()static java.lang.StringS_CONFIGURATION_HANDLERstatic java.lang.StringS_CONFIGURATION_NAMEstatic java.lang.StringS_EVENT_MANAGERstatic java.lang.StringS_FITNESS_EVALUATORstatic java.lang.StringS_FITNESS_FUNCTIONstatic java.lang.StringS_GENETIC_OPERATORSstatic java.lang.StringS_MINPOPSIZEstatic java.lang.StringS_NATURAL_SELECTORSstatic java.lang.StringS_NONEstatic java.lang.StringS_POPULATION_SIZEstatic java.lang.StringS_POSTstatic java.lang.StringS_PREstatic java.lang.StringS_RANDOM_GENERATORstatic java.lang.StringS_SAMPLE_CHROMstatic java.lang.StringS_SIZEstatic java.lang.StringS_TOSTRING
-
Constructor Summary
Constructors Constructor and Description Configuration()Configuration(java.lang.String a_name)Constructs a configuration with an informative name but without a unique ID.Configuration(java.lang.String a_configFileName, boolean a_ignore)Reads in the configuration from the given file.Configuration(java.lang.String a_id, java.lang.String a_name)Initialize with default values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description voidaddGeneticOperator(GeneticOperator a_operatorToAdd)Adds a genetic operator for use in this algorithm.voidaddNaturalSelector(NaturalSelector a_selector, boolean a_processBeforeGeneticOperators)Adds a NaturalSelector to the ordered chain of registered NaturalSelector's.java.lang.Objectclone()intcompareTo(java.lang.Object a_other)The compareTo-method.booleanequals(java.lang.Object a_other)The equals-method.IBreedergetBreeder()BulkFitnessFunctiongetBulkFitnessFunction()Retrieves the bulk fitness function previously setup in this Configuration object.IChromosomePoolgetChromosomePool()Retrieves the ChromosomePool instance, if any, that is associated with this configuration.intgetChromosomeSize()Retrieves the chromosome size being used by this genetic algorithm.ConfigurationHandlergetConfigurationHandler()Implementation of the Configurable interface.IEventManagergetEventManager()Retrieves the event manager associated with this configuration.FitnessEvaluatorgetFitnessEvaluator()FitnessFunctiongetFitnessFunction()Retrieves the fitness function previously setup in this Configuration object.intgetGenerationNr()java.util.ListgetGeneticOperators()Retrieves the genetic operators setup in this Configuration instance.java.lang.StringgetId()IJGAPFactorygetJGAPFactory()intgetMinimumPopSizePercent()IEvolutionMonitorgetMonitor()java.lang.StringgetName()NaturalSelectorgetNaturalSelector()Deprecated.use getNaturalSelectors(true) or getNaturalSelectors(false) to obtain the relevant chain of NaturalSelector's and then call the chain's get(index) methodNaturalSelectorgetNaturalSelector(boolean a_processBeforeGeneticOperators, int a_index)ChainOfSelectorsgetNaturalSelectors(boolean a_processBeforeGeneticOperators)Only use for read-only access! Especially don't call clear() for the returned ChainOfSelectors object!intgetNaturalSelectorsSize(boolean a_processBeforeGeneticOperators)intgetPopulationSize()Retrieves the population size setup in this Configuration instance.RandomGeneratorgetRandomGenerator()Retrieves the random generator setup in this Configuration instance.IChromosomegetSampleChromosome()Retrieves the sample Chromosome that contains the desired Gene setup for each respective gene position (locus).doublegetSelectFromPrevGen()voidincrementGenerationNr()booleanisAlwaysCalculateFitness()booleanisKeepPopulationSizeConstant()See setKeepPopulationSizeConstant and GABreeder#evolve(Population, Configuration) for detailled explanation.booleanisLocked()Retrieves the lock status of this object.booleanisPreserveFittestIndividual()booleanisUniqueKeysActive()voidlockSettings()Locks all of the settings in this configuration object.ConfigurationnewInstance(java.lang.String a_id, java.lang.String a_name)Creates a new Configuration instance by cloning.voidremoveNaturalSelectors(boolean a_processBeforeGeneticOperators)Removes all natural selectors (either pre or post ones).static voidreset()SHOULD NOT BE NECESSARY TO CALL UNDER NORMAL CIRCUMSTANCES.static voidreset(java.lang.String a_id)Reset the configuration so that re-setting parameters such as fitness function is possible (without calling this method, an overwriting of a previously set fitness function results in a RuntimeException).static voidresetProperty(java.lang.String a_propName)See Configuration.reset().static voidresetProperty(java.lang.String a_propName, java.lang.String a_id)voidsetAlwaysCaculateFitness(boolean a_alwaysCalculate)voidsetBreeder(IBreeder a_breeder)voidsetBulkFitnessFunction(BulkFitnessFunction a_functionToSet)Sets the bulk fitness function to be used for this genetic algorithm.voidsetChromosomePool(IChromosomePool a_chromosomePoolToSet)Sets the ChromosomePool that is to be associated with this configuration.voidsetEventManager(IEventManager a_eventManagerToSet)Sets the event manager that is to be associated with this configuration.voidsetFitnessEvaluator(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).voidsetFitnessFunction(FitnessFunction a_functionToSet)Sets the fitness function to be used for this genetic algorithm.voidsetJGAPFactory(IJGAPFactory a_factory)voidsetKeepPopulationSizeConstant(boolean a_keepPopSizeConstant)Allows to keep the population size constant during one evolution, even if there is no appropriate instance of NaturalSelector (such as WeightedRouletteSelector) registered with the Configuration.voidsetMinimumPopSizePercent(int a_minimumSizeGuaranteedPercent)Minimum size guaranteed for population.voidsetMonitor(IEvolutionMonitor a_monitor)Sets a monitor for auditing evolution progress.voidsetName(java.lang.String a_name)voidsetNaturalSelector(NaturalSelector a_selectorToSet)Deprecated.use addNaturalSelector(false) insteadvoidsetPopulationSize(int a_sizeOfPopulation)Sets the population size to be used for this genetic algorithm.voidsetPreservFittestIndividual(boolean a_preserveFittest)Determines whether to save (keep) the fittest individual.voidsetRandomGenerator(RandomGenerator a_generatorToSet)Sets the random generator to be used for this genetic algorithm.voidsetSampleChromosome(IChromosome a_sampleChromosomeToSet)Sets the sample Chromosome that is to be used as a guide for the construction of other Chromosomes.voidsetSelectFromPrevGen(double a_percentage)voidsetUniqueKeysActive(boolean a_active)java.lang.StringtoString()voidverifyStateIsValid()Tests the state of this Configuration object to make sure it's valid.
-
-
-
Field Detail
-
PROPERTY_JGAPFACTORY_CLASS
public static final java.lang.String PROPERTY_JGAPFACTORY_CLASS
Constant for class name of JGAP Factory to use. Use as: System.setProperty(PROPERTY_JGAPFACTORY_CLASS, "myJGAPFactory"); If none such property set, class JGAPFactory will be used.- See Also:
- Constant Field Values
-
PROPERTY_FITFUNC_INST
public static final java.lang.String PROPERTY_FITFUNC_INST
- See Also:
- Constant Field Values
-
PROPERTY_BFITFNC_INST
public static final java.lang.String PROPERTY_BFITFNC_INST
- See Also:
- Constant Field Values
-
PROPERTY_FITEVAL_INST
public static final java.lang.String PROPERTY_FITEVAL_INST
- See Also:
- Constant Field Values
-
PROPERTY_SAMPLE_CHROM_INST
public static final java.lang.String PROPERTY_SAMPLE_CHROM_INST
- See Also:
- Constant Field Values
-
PROPERTY_EVENT_MGR_INST
public static final java.lang.String PROPERTY_EVENT_MGR_INST
- See Also:
- Constant Field Values
-
S_CONFIGURATION
public static final java.lang.String S_CONFIGURATION
Constants for toString()- See Also:
- Constant Field Values
-
S_CONFIGURATION_NAME
public static final java.lang.String S_CONFIGURATION_NAME
- See Also:
- Constant Field Values
-
S_POPULATION_SIZE
public static final java.lang.String S_POPULATION_SIZE
- See Also:
- Constant Field Values
-
S_MINPOPSIZE
public static final java.lang.String S_MINPOPSIZE
- See Also:
- Constant Field Values
-
S_CHROMOSOME_SIZE
public static final java.lang.String S_CHROMOSOME_SIZE
- See Also:
- Constant Field Values
-
S_SAMPLE_CHROM
public static final java.lang.String S_SAMPLE_CHROM
- See Also:
- Constant Field Values
-
S_SIZE
public static final java.lang.String S_SIZE
- See Also:
- Constant Field Values
-
S_TOSTRING
public static final java.lang.String S_TOSTRING
- See Also:
- Constant Field Values
-
S_RANDOM_GENERATOR
public static final java.lang.String S_RANDOM_GENERATOR
- See Also:
- Constant Field Values
-
S_EVENT_MANAGER
public static final java.lang.String S_EVENT_MANAGER
- See Also:
- Constant Field Values
-
S_NONE
public static final java.lang.String S_NONE
- See Also:
- Constant Field Values
-
S_CONFIGURATION_HANDLER
public static final java.lang.String S_CONFIGURATION_HANDLER
- See Also:
- Constant Field Values
-
S_FITNESS_FUNCTION
public static final java.lang.String S_FITNESS_FUNCTION
- See Also:
- Constant Field Values
-
S_FITNESS_EVALUATOR
public static final java.lang.String S_FITNESS_EVALUATOR
- See Also:
- Constant Field Values
-
S_GENETIC_OPERATORS
public static final java.lang.String S_GENETIC_OPERATORS
- See Also:
- Constant Field Values
-
S_NATURAL_SELECTORS
public static final java.lang.String S_NATURAL_SELECTORS
- See Also:
- Constant Field Values
-
S_PRE
public static final java.lang.String S_PRE
- See Also:
- Constant Field Values
-
S_POST
public static final java.lang.String S_POST
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Configuration
public Configuration()
-
Configuration
public Configuration(java.lang.String a_id, java.lang.String a_name)Initialize with default values.- Parameters:
a_id- unique id for the configuration within the current threada_name- informative name of the configuration, may be null- Since:
- 1.0
-
Configuration
public Configuration(java.lang.String a_name)
Constructs a configuration with an informative name but without a unique ID. This practically prevents more than one configurations to be instantiated within the same thread.- Parameters:
a_name- informative name of the configuration, may be null
-
Configuration
public Configuration(java.lang.String a_configFileName, boolean a_ignore) throws ConfigException, InvalidConfigurationExceptionReads in the configuration from the given file.- Parameters:
a_configFileName- the config file from which to load the configurationa_ignore- just there to create distinct signatures :-(- Throws:
ConfigExceptionInvalidConfigurationException- Since:
- 2.3
-
-
Method Detail
-
reset
public static void reset()
SHOULD NOT BE NECESSARY TO CALL UNDER NORMAL CIRCUMSTANCES. May be useful for unit tests.Reset the configuration so that re-setting parameters such as fitness function is possible (without calling this method, an overwriting of a previously set fitness function results in a RuntimeException).
- Since:
- 3.0
-
reset
public static void reset(java.lang.String a_id)
Reset the configuration so that re-setting parameters such as fitness function is possible (without calling this method, an overwriting of a previously set fitness function results in a RuntimeException).- Parameters:
a_id- a hopefully unique id of the configuration- Since:
- 3.0
-
resetProperty
public static void resetProperty(java.lang.String a_propName)
See Configuration.reset().- Parameters:
a_propName- the property to reset- Since:
- 3.0
-
resetProperty
public static void resetProperty(java.lang.String a_propName, java.lang.String a_id)
-
setName
public void setName(java.lang.String a_name)
- Parameters:
a_name- informative name of the configuration- Since:
- 2.3
-
getName
public java.lang.String getName()
- Returns:
- informative name of the configuration
- Since:
- 2.3
-
setFitnessFunction
public void setFitnessFunction(FitnessFunction a_functionToSet) throws InvalidConfigurationException
Sets the fitness function to be used for this genetic algorithm. The fitness function is responsible for evaluating a given Chromosome and returning a positive integer that represents its worth as a candidate solution. These values are used as a guide by the natural to determine which Chromosome instances will be allowed to move on to the next round of evolution, and which will instead be eliminated. 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.- Parameters:
a_functionToSet- fitness function to be used- Throws:
InvalidConfigurationException- if the fitness function is null, a bulk fitness function has already been set, or if this Configuration object is locked.- Since:
- 1.1
-
getFitnessFunction
public FitnessFunction getFitnessFunction()
Retrieves the fitness function previously setup in this Configuration object.- Returns:
- the fitness function
- Since:
- 1.0
-
setBulkFitnessFunction
public void setBulkFitnessFunction(BulkFitnessFunction a_functionToSet) throws InvalidConfigurationException
Sets the bulk fitness function to be used for this genetic algorithm. The bulk fitness function may be used to evaluate and assign fitness values to the entire group of candidate Chromosomes in a single batch. This can be useful in cases where it's difficult to assign fitness values to a Chromosome in isolation from the other candidate Chromosomes.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.
- Parameters:
a_functionToSet- bulk fitness function to be used- Throws:
InvalidConfigurationException- if the bulk fitness function is null, the normal fitness function has already been set, or if this Configuration object is locked- Since:
- 1.0
-
getBulkFitnessFunction
public BulkFitnessFunction getBulkFitnessFunction()
Retrieves the bulk fitness function previously setup in this Configuration object.- Returns:
- the bulk fitness function
- Since:
- 1.0
-
setSampleChromosome
public void setSampleChromosome(IChromosome a_sampleChromosomeToSet) throws InvalidConfigurationException
Sets the sample Chromosome that is to be used as a guide for the construction of other Chromosomes. The Chromosome should be setup with each gene represented by the desired concrete Gene implementation for that gene position (locus). Anytime a new Chromosome is created, it will be constructed with the same Gene setup as that provided in this sample Chromosome.- Parameters:
a_sampleChromosomeToSet- Chromosome to be used as the sample- Throws:
InvalidConfigurationException- if the given Chromosome is null or this Configuration object is locked- Since:
- 1.0
-
getSampleChromosome
public IChromosome getSampleChromosome()
Retrieves the sample Chromosome that contains the desired Gene setup for each respective gene position (locus).- Returns:
- sample Chromosome instance
- Since:
- 1.0
-
getChromosomeSize
public int getChromosomeSize()
Retrieves the chromosome size being used by this genetic algorithm. This value is set automatically when the sample chromosome is provided.- Returns:
- chromosome size used in this configuration
- Since:
- 1.0
-
setNaturalSelector
public void setNaturalSelector(NaturalSelector a_selectorToSet) throws InvalidConfigurationException
Deprecated. use addNaturalSelector(false) insteadSets the natural selector to be used for this genetic algorithm. The natural selector is responsible for actually selecting which Chromosome instances are allowed to move on to the next round of evolution (usually guided by the fitness values provided by the fitness function). This setting is required.- Parameters:
a_selectorToSet- the natural selector to be used- Throws:
InvalidConfigurationException- if the natural selector is null or this Configuration object is locked- Since:
- 1.0
-
getNaturalSelector
public 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) methodRetrieves the natural selector setup in this Configuration instance.- Returns:
- the natural selector
- Since:
- 1.0
-
getNaturalSelector
public NaturalSelector getNaturalSelector(boolean a_processBeforeGeneticOperators, int a_index)
- Parameters:
a_processBeforeGeneticOperators- true: retrieve selector that is registered to be executed before genetic operators, false: get the one that is registered to be executed after genetic operatorsa_index- index of the selector to get- Returns:
- NaturalSelector
- Since:
- 1.1
-
getNaturalSelectors
public ChainOfSelectors getNaturalSelectors(boolean a_processBeforeGeneticOperators)
Only use for read-only access! Especially don't call clear() for the returned ChainOfSelectors object!- Parameters:
a_processBeforeGeneticOperators- true: retrieve selector that is registered to be executed before genetic operators, false: get the one that is registered to be executed after genetic operators- Returns:
- ChainOfSelectors
- Since:
- 1.1
-
getNaturalSelectorsSize
public int getNaturalSelectorsSize(boolean a_processBeforeGeneticOperators)
- Parameters:
a_processBeforeGeneticOperators- true: retrieve selector that is registered to be executed before genetic operators, false: get the one that is registered to be executed after genetic operators- Returns:
- size of selector list (distinct by a_processBeforeGeneticOperators)
- Since:
- 1.1
-
removeNaturalSelectors
public void removeNaturalSelectors(boolean a_processBeforeGeneticOperators)
Removes all natural selectors (either pre or post ones).- Parameters:
a_processBeforeGeneticOperators- true: remove all selectors processed before genetic operators, false: remove the ones processed afterwards- Since:
- 2.3
-
setRandomGenerator
public void setRandomGenerator(RandomGenerator a_generatorToSet) throws InvalidConfigurationException
Sets the random generator to be used for this genetic algorithm. The random generator is responsible for generating random numbers, which are used throughout the process of genetic evolution and selection. This setting is required.- Parameters:
a_generatorToSet- random generator to be used- Throws:
InvalidConfigurationException- if the random generator is null or this object is locked- Since:
- 1.0
-
getRandomGenerator
public RandomGenerator getRandomGenerator()
Retrieves the random generator setup in this Configuration instance.- Returns:
- the random generator
- Since:
- 1.0
-
addGeneticOperator
public void addGeneticOperator(GeneticOperator a_operatorToAdd) throws InvalidConfigurationException
Adds a genetic operator for use in this algorithm. Genetic operators represent evolutionary steps that, when combined, make up the evolutionary process. Examples of genetic operators are reproduction, crossover, and mutation. During the evolution process, all of the genetic operators added via this method are invoked in the order they were added. At least one genetic operator must be provided.- Parameters:
a_operatorToAdd- the genetic operator to add.- Throws:
InvalidConfigurationException- if the genetic operator is null or if this Configuration object is locked- Since:
- 1.0
-
getGeneticOperators
public java.util.List getGeneticOperators()
Retrieves the genetic operators setup in this Configuration instance. Note that once this Configuration instance is locked, a new, immutable list of operators is used and any lists previously retrieved with this method will no longer reflect the actual list in use.- Returns:
- the list of genetic operators
- Since:
- 1.0
-
setPopulationSize
public void setPopulationSize(int a_sizeOfPopulation) throws InvalidConfigurationExceptionSets the population size to be used for this genetic algorithm. The population size is a fixed value that represents the number of Chromosomes contained within the Genotype (population). This setting is required.- Parameters:
a_sizeOfPopulation- population size to be used- Throws:
InvalidConfigurationException- if the population size is not positive or this object is locked- Since:
- 1.0
-
getPopulationSize
public int getPopulationSize()
Retrieves the population size setup in this Configuration instance.- Returns:
- population size
-
setEventManager
public void setEventManager(IEventManager a_eventManagerToSet) throws InvalidConfigurationException
Sets the event manager that is to be associated with this configuration. The event manager is responsible for the management of event subscribers and event notifications.- Parameters:
a_eventManagerToSet- the EventManager instance to use in this configuration- Throws:
InvalidConfigurationException- if the event manager is null or this Configuration object is locked- Since:
- 1.0
-
getEventManager
public IEventManager getEventManager()
Retrieves the event manager associated with this configuration. The event manager is responsible for the management of event subscribers and event notifications.- Returns:
- the actively configured event manager instance
- Since:
- 1.0
-
setChromosomePool
public void setChromosomePool(IChromosomePool a_chromosomePoolToSet) throws InvalidConfigurationException
Sets the ChromosomePool that is to be associated with this configuration. The ChromosomePool is used to pool discarded Chromosome instances so that they may be recycled later, thereby saving memory and the time to construct them from scratch. The presence of a ChromosomePool is optional. If none exists, then a new Chromosome will be constructed each time one is needed.- Parameters:
a_chromosomePoolToSet- the ChromosomePool instance to use- Throws:
InvalidConfigurationException- if this object is locked- Since:
- 1.0
-
getChromosomePool
public IChromosomePool getChromosomePool()
Retrieves the ChromosomePool instance, if any, that is associated with this configuration. The ChromosomePool is used to pool discarded Chromosome instances so that they may be recycled later, thereby saving memory and the time to construct them from scratch. The presence of a ChromosomePool instance is optional. If none exists, then new Chromosomes should be constructed each time one is needed.- Returns:
- the ChromosomePool instance associated this configuration, or null if none has been provided
- Since:
- 1.0
-
lockSettings
public void lockSettings() throws InvalidConfigurationExceptionLocks all of the settings in this configuration object. Once this method is successfully invoked, none of the settings may be changed. There is no way to unlock this object once it is locked.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 this 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.
- Throws:
InvalidConfigurationException- if this Configuration object is in an invalid state at the time of invocation- Since:
- 1.0
-
isLocked
public boolean isLocked()
Retrieves the lock status of this object.- Returns:
- true if this object has been locked by a previous successful call to the lockSettings() method, false otherwise
- Since:
- 1.0
-
verifyStateIsValid
public void verifyStateIsValid() throws InvalidConfigurationExceptionTests the state of this Configuration object to make sure it's valid. This generally consists of verifying that required settings have, in fact, been set. If this object is not in a valid state, then an exception will be thrown detailing the reason the state is not valid.- Throws:
InvalidConfigurationException- if the state of this Configuration is not valid. The error message in the exception will detail the reason for invalidity- Since:
- 1.0
-
addNaturalSelector
public void addNaturalSelector(NaturalSelector a_selector, boolean a_processBeforeGeneticOperators) throws InvalidConfigurationException
Adds a NaturalSelector to the ordered chain of registered NaturalSelector's. It's possible to execute the NaturalSelector before or after (registered) genetic operations have been applied. Normally, you would add a selector that is applied after the genetic operators are processed (a_processBeforeGeneticOperators = false).- Parameters:
a_selector- the selector to be added to the chaina_processBeforeGeneticOperators- true: execute NaturalSelector before any genetic operator will be applied, false: .. after..- Throws:
InvalidConfigurationException- Since:
- 1.1
-
setMinimumPopSizePercent
public void setMinimumPopSizePercent(int a_minimumSizeGuaranteedPercent)
Minimum size guaranteed for population. This is significant during evolution as natural selectors could select fewer chromosomes for the next generation than the initial population size was.- Parameters:
a_minimumSizeGuaranteedPercent- if zero or below then no ensurance for size given, see Genotype.evolve()
-
getMinimumPopSizePercent
public int getMinimumPopSizePercent()
-
getFitnessEvaluator
public FitnessEvaluator getFitnessEvaluator()
- Returns:
- the assigned FitnessEvaluator
- Since:
- 2.0
-
setFitnessEvaluator
public 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).- Parameters:
a_fitnessEvaluator- the FitnessEvaluator to be used- Since:
- 2.0
-
isPreserveFittestIndividual
public boolean isPreserveFittestIndividual()
- Returns:
- true: fittest chromosome should always be transferred to next generation
- Since:
- 2.1
-
setPreservFittestIndividual
public void setPreservFittestIndividual(boolean a_preserveFittest)
Determines whether to save (keep) the fittest individual.- Parameters:
a_preserveFittest- true: always transfer fittest chromosome to next generation- Since:
- 2.1
-
incrementGenerationNr
public void incrementGenerationNr()
-
getGenerationNr
public int getGenerationNr()
-
getConfigurationHandler
public ConfigurationHandler getConfigurationHandler()
Implementation of the Configurable interface.- Returns:
- ConfigurationHandler
- Throws:
ConfigException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
- string representation of the configuration containing all configurable elements
- Since:
- 2.3
-
isKeepPopulationSizeConstant
public boolean isKeepPopulationSizeConstant()
See setKeepPopulationSizeConstant and GABreeder#evolve(Population, Configuration) for detailled explanation.- Returns:
- true: population size will always be the same size (as given with Configuration.setPopulationSize(int)
- Since:
- 2.4
-
setKeepPopulationSizeConstant
public void setKeepPopulationSizeConstant(boolean a_keepPopSizeConstant)
Allows to keep the population size constant during one evolution, even if there is no appropriate instance of NaturalSelector (such as WeightedRouletteSelector) registered with the Configuration.See setKeepPopulationSizeConstant and GABreeder#evolve(Population, Configuration) for detailled explanation.
- Parameters:
a_keepPopSizeConstant- true: population size will always be the same size (as given with Configuration.setPopulationSize(int)- Since:
- 2.4
-
setSelectFromPrevGen
public void setSelectFromPrevGen(double a_percentage)
-
getSelectFromPrevGen
public double getSelectFromPrevGen()
-
getJGAPFactory
public IJGAPFactory getJGAPFactory()
- Returns:
- the JGAP factory registered
-
setJGAPFactory
public void setJGAPFactory(IJGAPFactory a_factory)
- Parameters:
a_factory- the IJGAPFactory to use- Since:
- 3.01
-
setBreeder
public void setBreeder(IBreeder a_breeder)
- Parameters:
a_breeder- the breeder to use- Since:
- 3.2
-
getBreeder
public IBreeder getBreeder()
- Returns:
- the breeder set or new standard breeder instance in case no breeder was set before.
- Since:
- 3.2
-
setAlwaysCaculateFitness
public void setAlwaysCaculateFitness(boolean a_alwaysCalculate)
- Parameters:
a_alwaysCalculate- true: Chromosome.getFitnessValue() will always (re-)calculate the fitness value. This may be necessary in case of environments where the state changes without the chromosome to notice.- Since:
- 3.2.2
-
isAlwaysCalculateFitness
public boolean isAlwaysCalculateFitness()
- Returns:
- true: Chromosome.getFitnessValue() will always (re-)calculate the fitness value. This may be necessary in case of environments where the state changes without the chromosome to notice.
- Since:
- 3.2.2
-
getId
public java.lang.String getId()
- Returns:
- the id of the configuration set
- Since:
- 3.1
-
clone
public java.lang.Object clone()
- Specified by:
clonein interfaceICloneable- Overrides:
clonein classjava.lang.Object- Returns:
- deep clone of this instance
- Since:
- 3.2
-
newInstance
public Configuration newInstance(java.lang.String a_id, java.lang.String a_name)
Creates a new Configuration instance by cloning. Allows to preset the ID and the name.- Parameters:
a_id- new ID for clonea_name- new name for clone- Returns:
- deep clone of this instance
- Since:
- 3.2
-
equals
public boolean equals(java.lang.Object a_other)
The equals-method.- Overrides:
equalsin classjava.lang.Object- Parameters:
a_other- the other object to compare- Returns:
- true if seen as equal
- Since:
- 3.2
-
compareTo
public int compareTo(java.lang.Object a_other)
The compareTo-method.- Specified by:
compareToin interfacejava.lang.Comparable- Parameters:
a_other- the other object to compare- Returns:
- -1, 0, 1
- Since:
- 3.2
-
setMonitor
public void setMonitor(IEvolutionMonitor a_monitor)
Sets a monitor for auditing evolution progress.- Parameters:
a_monitor- the monitor to use- Since:
- 3.5
-
getMonitor
public IEvolutionMonitor getMonitor()
- Returns:
- the monitor uses for auditing the evolution progress.
- Since:
- 3.5
-
setUniqueKeysActive
public void setUniqueKeysActive(boolean a_active)
- Parameters:
a_active- true: use unique keys to allow tracking and monitoring- Since:
- 3.5
-
isUniqueKeysActive
public boolean isUniqueKeysActive()
- Returns:
- true: use unique keys to allow tracking and monitoring
- Since:
- 3.5
-
-
DMelt 3.0 © DataMelt by jWork.ORG