| java.lang.Object org.jgap.Genotype
All known Subclasses: org.jgap.distr.DistributedGenotype,
Genotype | public class Genotype implements Serializable,Runnable(Code) | | Genotypes are fixed-length populations of chromosomes. As an instance of
a Genotype is evolved, all of its Chromosomes are also evolved. A Genotype
may be constructed normally via constructor, or the static
randomInitialGenotype() method can be used to generate a Genotype with a
randomized Chromosome population.
Please note that among all created Genotype instances there may only be one
configuration, used by all Genotype instances.
author: Neil Rotstan author: Klaus Meffert since: 1.0 |
Constructor Summary | |
public | Genotype(Configuration a_configuration, IChromosome[] a_initialChromosomes) Constructs a new Genotype instance with the given array of Chromosomes and
the given active Configuration instance. | public | Genotype(Configuration a_configuration, Population a_population) Constructs a new Genotype instance with the given array of
Chromosomes and the given active Configuration instance. | public | Genotype(Configuration a_configuration) Don't use this constructor, it's only for internal use. |
Genotype | public Genotype(Configuration a_configuration, IChromosome[] a_initialChromosomes) throws InvalidConfigurationException(Code) | | Constructs a new Genotype instance with the given array of Chromosomes and
the given active Configuration instance. Note that the Configuration object
must be in a valid state when this method is invoked, or a
InvalidConfigurationException will be thrown.
Parameters: a_configuration - the Configuration object to use Parameters: a_initialChromosomes - the Chromosome population to be managed bythis Genotype instance throws: InvalidConfigurationException - if the given Configuration object isin an invalid state author: Neil Rotstan author: Klaus Meffert since: 1.0 |
Genotype | public Genotype(Configuration a_configuration, Population a_population) throws InvalidConfigurationException(Code) | | Constructs a new Genotype instance with the given array of
Chromosomes and the given active Configuration instance. Note
that the Configuration object must be in a valid state
when this method is invoked, or a InvalidconfigurationException
will be thrown.
Parameters: a_configuration - the Configuration object to use Parameters: a_population - the Chromosome population to be managed by thisGenotype instance throws: InvalidConfigurationException - author: Neil Rotstan author: Klaus Meffert since: 2.0 |
applyGeneticOperator | protected void applyGeneticOperator(GeneticOperator a_operator, Population a_population, List a_chromosomes)(Code) | | Overwritable method that calls a GeneticOperator to operate on a given
population and asks him to store the result in the list of chromosomes.
Override this method if you want to ensure that a_chromosomes is not
part of a_population resp. if you want to use a different list.
Parameters: a_operator - the GeneticOperator to call Parameters: a_population - the population to use Parameters: a_chromosomes - the list of Chromosome objects to return author: Klaus Meffert since: 2.4 |
applyGeneticOperators | public void applyGeneticOperators()(Code) | | Applies all GeneticOperators registered with the Configuration.
author: Klaus Meffert since: 3.0 |
applyNaturalSelectors | protected void applyNaturalSelectors(boolean a_processBeforeGeneticOperators)(Code) | | Applies all NaturalSelectors registered with the Configuration.
Parameters: a_processBeforeGeneticOperators - true apply NaturalSelectorsapplicable before GeneticOperators, false: apply the ones applicableafter GeneticOperators author: Klaus Meffert since: 2.0 |
equals | public boolean equals(Object a_other)(Code) | | Compares this Genotype against the specified object. The result is true
if the argument is an instance of the Genotype class, has exactly the
same number of chromosomes as the given Genotype, and, for each
Chromosome in this Genotype, there is an equal chromosome in the
given Genotype. The chromosomes do not need to appear in the same order
within the population.
Parameters: a_other - the object to compare against true if the objects are the same, false otherwise author: Neil Rotstan author: Klaus Meffert since: 1.0 |
evolve | public synchronized void evolve()(Code) | | Evolves the population of Chromosomes within this Genotype. This will
execute all of the genetic operators added to the present active
configuration and then invoke the natural selector to choose which
chromosomes will be included in the next generation population. Note
that the population size not always remains constant (dependent on the
NaturalSelectors used!).
To consecutively call this method, use evolve(int)!!!
author: Neil Rotstan author: Klaus Meffert since: 1.0 |
evolve | public void evolve(int a_numberOfEvolutions)(Code) | | Evolves this Genotype the specified number of times. This is
equivalent to invoking the standard evolve() method the given number
of times in a row.
Parameters: a_numberOfEvolutions - the number of times to evolve this Genotypebefore returning author: Klaus Meffert since: 1.1 |
getChromosomes | public synchronized IChromosome[] getChromosomes()(Code) | | Retrieves the array of Chromosomes that make up the population of this
Genotype instance.
the Population of Chromosomes author: Neil Rotstan author: Klaus Meffert since: 1.0 |
getFittestChromosome | public synchronized IChromosome getFittestChromosome()(Code) | | Retrieves the Chromosome in the Population with the highest fitness
value.
the Chromosome with the highest fitness value, or null if thereare no chromosomes in this Genotype author: Neil Rotstan author: Klaus Meffert since: 1.0 |
getFittestChromosome | public synchronized IChromosome getFittestChromosome(int a_startIndex, int a_endIndex)(Code) | | Retrieves the Chromosome in the Population with the highest fitness
value within the given indices.
Parameters: a_startIndex - the index to start the determination with Parameters: a_endIndex - the index to end the determination with the Chromosome with the highest fitness value within the givenindices, or null if there are no chromosomes in this Genotype author: Klaus Meffert since: 3.0 |
getFittestChromosomes | public synchronized List getFittestChromosomes(int a_numberOfChromosomes)(Code) | | Retrieves the top n Chromsomes in the population (the ones with the best
fitness values).
Parameters: a_numberOfChromosomes - the number of chromosomes desired the list of Chromosomes with the highest fitness values, or nullif there are no chromosomes in this Genotype author: Charles Kevin Hill since: 2.4 |
getPopulation | public Population getPopulation()(Code) | | the current population of chromosomes author: Klaus Meffert since: 2.1 |
getStaticConfiguration | public static Configuration getStaticConfiguration()(Code) | | the configuration to use with the Genetic Algorithm author: Klaus Meffert since: 2.0 |
hashCode | public int hashCode()(Code) | | Hashcode function for the genotype, tries to create a unique hashcode for
the chromosomes within the population. The logic for the hashcode is
Step Result
---- ------
1 31*0 + hashcode_0 = y(1)
2 31*y(1) + hashcode_1 = y(2)
3 31*y(2) + hashcode_2 = y(3)
n 31*y(n-1) + hashcode_n-1 = y(n)
Each hashcode is a number and the binary equivalent is computed and
returned.
the computed hashcode author: vamsi since: 2.1 |
keepPopSizeConstant | protected void keepPopSizeConstant(Population a_pop, int a_maxSize)(Code) | | Cares that the population size does not exceed the given maximum size.
Parameters: a_pop - the population to keep constant in size Parameters: a_maxSize - the maximum size allowed for the population author: Klaus Meffert since: 2.5 |
randomInitialGenotype | public static Genotype randomInitialGenotype(Configuration a_configuration) throws InvalidConfigurationException(Code) | | Convenience method that returns a newly constructed Genotype
instance configured according to the given Configuration instance.
The population of Chromosomes will be created according to the setup of
the sample Chromosome in the Configuration object, but the gene values
(alleles) will be set to random legal values.
Parameters: a_configuration - the current active Configuration object a newly constructed Genotype instance throws: IllegalArgumentException - if the given Configuration object is null throws: InvalidConfigurationException - if the given Configurationinstance is not in a valid state author: Neil Rotstan author: Klaus Meffert since: 2.3 |
run | public void run()(Code) | | If used in a Thread: runs the evolution forever.
You have to implement a listener to stop computation sometime. See
examples.simpleBooleanThreaded for a possible implementation of such a
listener.
author: Klaus Meffert since: 3.01 |
setStaticConfiguration | public static void setStaticConfiguration(Configuration a_configuration)(Code) | | Sets the configuration to use with the Genetic Algorithm.
Parameters: a_configuration - the configuration to use author: Klaus Meffert since: 2.0 |
toString | public String toString()(Code) | | string representation of this Genotype instance, useful for displaypurposes author: Neil Rotstan since: 1.0 |
|
|