org.jgap
Interface IChromosome
-
- All Superinterfaces:
- java.lang.Cloneable, java.lang.Comparable, ICloneable, IUniqueKey, java.io.Serializable
- All Known Implementing Classes:
- BaseChromosome, Chromosome
public interface IChromosome extends java.lang.Comparable, ICloneable, java.io.Serializable, IUniqueKey
Interface for chromosomes. Normally, you would start using BaseChromosome which implements this interface to build your own chromosome classes.- Since:
- 2.6
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.StringCVS_REVISIONString containing the CVS revision.static java.lang.StringS_ALLELESstatic java.lang.StringS_APPLICATION_DATAstatic java.lang.StringS_FITNESS_VALUEConstants for toString()static java.lang.StringS_SIZE
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description voidcleanup()Invoked when this Chromosome is no longer needed and should perform any necessary cleanup.intgetAge()java.lang.ObjectgetApplicationData()Retrieves the application-specific data that is attached to this Chromosome.ConfigurationgetConfiguration()doublegetFitnessValue()Retrieves the fitness value of this Chromosome, as determined by the active fitness function.doublegetFitnessValueDirectly()GenegetGene(int a_desiredLocus)Returns the Gene at the given index (locus) within the Chromosome.Gene[]getGenes()Retrieves the set of genes that make up this Chromosome.voidincreaseAge()Increases the number of evolutionary rounds of chromosome in which it has not been changed by one.voidincreaseOperatedOn()Increase information of number of genetic operations performed on chromosome in current evolution round.booleanisSelectedForNextGeneration()Retrieves whether this Chromosome has been selected by the natural selector to continue to the next generation.intoperatedOn()voidresetAge()Reset age of chromosome because it has been changed.voidresetOperatedOn()Resets the information of how many genetic operators have been performed on the chromosome in the current round of evolution.voidsetAge(int a_age)voidsetApplicationData(java.lang.Object a_newData)This sets the application-specific data that is attached to this Chromosome.voidsetConstraintChecker(IGeneConstraintChecker a_constraintChecker)Sets the constraint checker to be used for this gene whenever method setAllele(Object) is called.voidsetFitnessValue(double a_newFitnessValue)Sets the fitness value of this Chromosome.voidsetFitnessValueDirectly(double a_newFitnessValue)Sets the fitness value of this Chromosome directly without any constraint checks, conversions or checks.voidsetGenes(Gene[] a_genes)Sets the genes for the chromosome.voidsetIsSelectedForNextGeneration(boolean a_isSelected)Sets whether this Chromosome has been selected by the natural selector to continue to the next generation or manually (e.g.intsize()Returns the size of this Chromosome (the number of genes it contains).-
Methods inherited from interface org.jgap.util.ICloneable
clone
-
Methods inherited from interface org.jgap.IUniqueKey
getUniqueID, getUniqueIDTemplate, setUniqueIDTemplate
-
-
-
-
Field Detail
-
CVS_REVISION
static final java.lang.String CVS_REVISION
String containing the CVS revision. Read out via reflection!- See Also:
- Constant Field Values
-
S_FITNESS_VALUE
static final java.lang.String S_FITNESS_VALUE
Constants for toString()- See Also:
- Constant Field Values
-
S_ALLELES
static final java.lang.String S_ALLELES
- See Also:
- Constant Field Values
-
S_APPLICATION_DATA
static final java.lang.String S_APPLICATION_DATA
- See Also:
- Constant Field Values
-
S_SIZE
static final java.lang.String S_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getGene
Gene getGene(int a_desiredLocus)
Returns the Gene at the given index (locus) within the Chromosome. The first gene is at index zero and the last gene is at the index equal to the size of this Chromosome - 1.- Parameters:
a_desiredLocus- index of the gene value to be returned- Returns:
- Gene at the given index
- Since:
- 2.6
-
getGenes
Gene[] getGenes()
Retrieves the set of genes that make up this Chromosome. This method exists primarily for the benefit of GeneticOperators that require the ability to manipulate Chromosomes at a low level.- Returns:
- an array of the Genes contained within this Chromosome
- Since:
- 2.6
-
setGenes
void setGenes(Gene[] a_genes) throws InvalidConfigurationException
Sets the genes for the chromosome.- Parameters:
a_genes- the genes to set for the chromosome- Throws:
InvalidConfigurationException- in case constraint checker is provided- Since:
- 2.6
-
size
int size()
Returns the size of this Chromosome (the number of genes it contains). A Chromosome's size is constant and will not change, until setGenes(...) is used.- Returns:
- number of genes contained within this Chromosome instance
- Since:
- 2.6
-
setFitnessValue
void setFitnessValue(double a_newFitnessValue)
Sets the fitness value of this Chromosome. This method is for use by bulk fitness functions and should not be invokved from anything else (except test cases).- Parameters:
a_newFitnessValue- a positive integer representing the fitness of this Chromosome- Since:
- 2.6
-
setFitnessValueDirectly
void setFitnessValueDirectly(double a_newFitnessValue)
Sets the fitness value of this Chromosome directly without any constraint checks, conversions or checks. Only use if you know what you do.- Parameters:
a_newFitnessValue- a positive integer representing the fitness of this Chromosome- Since:
- 2.6
-
getFitnessValue
double getFitnessValue()
Retrieves the fitness value of this Chromosome, as determined by the active fitness function. If a bulk fitness function is in use and has not yet assigned a fitness value to this Chromosome, then -1 is returned.Attention: should not be called from toString() as the fitness value would be computed if it was initial!
- Returns:
- a positive double value representing the fitness of this Chromosome, or -1 if a bulk fitness function is in use and has not yet assigned a fitness value to this Chromosome
- Since:
- 2.6
-
getFitnessValueDirectly
double getFitnessValueDirectly()
- Returns:
- the lastly computed fitness value, or FitnessFunction.NO_FITNESS_VALUE in case no value has been computed yet.
- Since:
- 2.6
-
setIsSelectedForNextGeneration
void setIsSelectedForNextGeneration(boolean a_isSelected)
Sets whether this Chromosome has been selected by the natural selector to continue to the next generation or manually (e.g. via an add-method).- Parameters:
a_isSelected- true if this Chromosome has been selected, false otherwise- Since:
- 2.6
-
isSelectedForNextGeneration
boolean isSelectedForNextGeneration()
Retrieves whether this Chromosome has been selected by the natural selector to continue to the next generation.- Returns:
- true if this Chromosome has been selected, false otherwise
- Since:
- 2.6
-
setConstraintChecker
void setConstraintChecker(IGeneConstraintChecker a_constraintChecker) throws InvalidConfigurationException
Sets the constraint checker to be used for this gene whenever method setAllele(Object) is called.- Parameters:
a_constraintChecker- the constraint checker to be set- Throws:
InvalidConfigurationException- Since:
- 2.6
-
setApplicationData
void setApplicationData(java.lang.Object a_newData)
This sets the application-specific data that is attached to this Chromosome. Attaching application-specific data may be useful for some applications when it comes time to evaluate this Chromosome in the fitness function.- Parameters:
a_newData- the new application-specific data to attach to this Chromosome. Should be an instance of IApplicationData- Since:
- 2.6
-
getApplicationData
java.lang.Object getApplicationData()
Retrieves the application-specific data that is attached to this Chromosome. Attaching application-specific data may be useful for some applications when it comes time to evaluate this Chromosome in the fitness function. JGAP ignores this data functionally.- Returns:
- the application-specific data previously attached to this Chromosome, or null if there is no data attached
- Since:
- 2.6
-
cleanup
void cleanup()
Invoked when this Chromosome is no longer needed and should perform any necessary cleanup. Note that this method will attempt to release this Chromosome instance to the active ChromosomePool, if any.- Since:
- 2.6
-
getConfiguration
Configuration getConfiguration()
- Returns:
- the configuration set
- Since:
- 3.0
-
increaseAge
void increaseAge()
Increases the number of evolutionary rounds of chromosome in which it has not been changed by one.- Since:
- 3.2
-
resetAge
void resetAge()
Reset age of chromosome because it has been changed.- Since:
- 3.2
-
setAge
void setAge(int a_age)
- Parameters:
a_age- set the age of the chromosome, see BestChromosomesSelector for a use-case- Since:
- 3.3.3
-
getAge
int getAge()
- Returns:
- 0: Chromosome newly created in this generation. This means it does not need being crossed over with another newly created one
- Since:
- 3.2
-
increaseOperatedOn
void increaseOperatedOn()
Increase information of number of genetic operations performed on chromosome in current evolution round.- Since:
- 3.2
-
resetOperatedOn
void resetOperatedOn()
Resets the information of how many genetic operators have been performed on the chromosome in the current round of evolution.- Since:
- 3.2
-
operatedOn
int operatedOn()
- Returns:
- number of genetic operations performed on chromosome in current evolution round
- Since:
- 3.2
-
-
DMelt 3.0 © DataMelt by jWork.ORG