|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jgap.Genotype
public class Genotype
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.
| Constructor Summary | |
|---|---|
Genotype(Configuration a_configuration)
Don't use this constructor, it's only for internal use. |
|
Genotype(Configuration a_configuration,
IChromosome[] a_initialChromosomes)
Deprecated. use Genotype(Configuration, Population) instead |
|
Genotype(Configuration a_configuration,
Population a_population)
Constructs a new Genotype instance with the given array of Chromosomes and the given active Configuration instance. |
|
| Method Summary | |
|---|---|
protected void |
applyGeneticOperator(GeneticOperator a_operator,
Population a_population,
java.util.List a_chromosomes)
Overwritable method that calls a GeneticOperator to operate on a given population and asks him to store the result in the list of chromosomes. |
void |
applyGeneticOperators()
Applies all GeneticOperators registered with the Configuration. |
protected void |
applyNaturalSelectors(boolean a_processBeforeGeneticOperators)
Applies all NaturalSelectors registered with the Configuration. |
boolean |
equals(java.lang.Object a_other)
Compares this Genotype against the specified object. |
void |
evolve()
Evolves the population of Chromosomes within this Genotype. |
java.util.List<java.lang.String> |
evolve(IEvolutionMonitor a_monitor)
Evolves this genotype until the given monitor asks to quit the evolution cycle. |
void |
evolve(int a_numberOfEvolutions)
Evolves this Genotype the specified number of times. |
void |
fillPopulation(int a_num)
Fills up the population with random chromosomes if necessary. |
IChromosome[] |
getChromosomes()
Deprecated. uses getPopulation() instead |
Configuration |
getConfiguration()
|
java.util.List<IEvolveJob> |
getEvolves(IPopulationSplitter a_splitter)
Splits a population into pieces that can be evolved independently. |
IChromosome |
getFittestChromosome()
Retrieves the Chromosome in the Population with the highest fitness value. |
IChromosome |
getFittestChromosome(int a_startIndex,
int a_endIndex)
Retrieves the Chromosome in the Population with the highest fitness value within the given indices. |
java.util.List |
getFittestChromosomes(int a_numberOfChromosomes)
Retrieves the top n Chromsomes in the population (the ones with the best fitness values). |
Population |
getPopulation()
|
static Configuration |
getStaticConfiguration()
|
int |
hashCode()
Hashcode function for the genotype, tries to create a unique hashcode for the chromosomes within the population. |
protected void |
keepPopSizeConstant(Population a_pop,
int a_maxSize)
Cares that the population size does not exceed the given maximum size. |
void |
mergeResults(IPopulationMerger a_merger,
EvolveResult[] a_results)
|
static Genotype |
randomInitialGenotype(Configuration a_configuration)
Convenience method that returns a newly constructed Genotype instance configured according to the given Configuration instance. |
void |
run()
If used in a Thread: runs the evolution forever. |
protected void |
setPopulation(Population a_pop)
|
static void |
setStaticConfiguration(Configuration a_configuration)
Sets the configuration to use with the Genetic Algorithm. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Genotype(Configuration a_configuration,
IChromosome[] a_initialChromosomes)
throws InvalidConfigurationException
a_configuration - the Configuration object to usea_initialChromosomes - the Chromosome population to be managed by
this Genotype instance
InvalidConfigurationException - if the given Configuration object is
in an invalid state
public Genotype(Configuration a_configuration,
Population a_population)
throws InvalidConfigurationException
a_configuration - the Configuration object to usea_population - the Chromosome population to be managed by this
Genotype instance
InvalidConfigurationException
public Genotype(Configuration a_configuration)
throws InvalidConfigurationException
a_configuration - not used here!
InvalidConfigurationException| Method Detail |
|---|
public IChromosome[] getChromosomes()
public Population getPopulation()
public IChromosome getFittestChromosome()
public IChromosome getFittestChromosome(int a_startIndex,
int a_endIndex)
a_startIndex - the index to start the determination witha_endIndex - the index to end the determination with
public java.util.List getFittestChromosomes(int a_numberOfChromosomes)
a_numberOfChromosomes - the number of chromosomes desired
public void evolve()
public void evolve(int a_numberOfEvolutions)
a_numberOfEvolutions - the number of times to evolve this Genotype
before returningpublic java.util.List<java.lang.String> evolve(IEvolutionMonitor a_monitor)
a_monitor - the monitor used to decide when to stop evolution
public java.lang.String toString()
toString in class java.lang.Object
public static Genotype randomInitialGenotype(Configuration a_configuration)
throws InvalidConfigurationException
a_configuration - the current active Configuration object
java.lang.IllegalArgumentException - if the given Configuration object is null
InvalidConfigurationException - if the given Configuration
instance is not in a valid state
public void fillPopulation(int a_num)
throws InvalidConfigurationException
a_num - the number of chromosomes to add
InvalidConfigurationExceptionpublic boolean equals(java.lang.Object a_other)
equals in class java.lang.Objecta_other - the object to compare against
protected void applyNaturalSelectors(boolean a_processBeforeGeneticOperators)
a_processBeforeGeneticOperators - true apply NaturalSelectors
applicable before GeneticOperators, false: apply the ones applicable
after GeneticOperatorspublic void applyGeneticOperators()
public static Configuration getStaticConfiguration()
public static void setStaticConfiguration(Configuration a_configuration)
a_configuration - the configuration to usepublic Configuration getConfiguration()
public int hashCode()
hashCode in class java.lang.Objectprotected void setPopulation(Population a_pop)
protected void applyGeneticOperator(GeneticOperator a_operator,
Population a_population,
java.util.List a_chromosomes)
a_operator - the GeneticOperator to calla_population - the population to usea_chromosomes - the list of Chromosome objects to return
protected void keepPopSizeConstant(Population a_pop,
int a_maxSize)
a_pop - the population to keep constant in sizea_maxSize - the maximum size allowed for the populationpublic void run()
run in interface java.lang.Runnable
public java.util.List<IEvolveJob> getEvolves(IPopulationSplitter a_splitter)
throws java.lang.Exception
a_splitter - splits the population
java.lang.Exception
public void mergeResults(IPopulationMerger a_merger,
EvolveResult[] a_results)
throws java.lang.Exception
java.lang.Exception
|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||