|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jgap.Population
public class Population
Makes up the population of a generation during evolution. Represented by a list of chromosomes held in the Genotype.
| Field Summary | |
|---|---|
static java.lang.String |
CHROM_DELIMITER
|
static java.lang.String |
CHROM_DELIMITER_CLOSING
Represents the closing delimiter that is used to separate chromosomes in the persistent representation. |
static java.lang.String |
CHROM_DELIMITER_HEADING
Represents the heading delimiter that is used to separate chromosomes in the persistent representation. |
| Constructor Summary | |
|---|---|
Population()
|
|
Population(Configuration a_config)
|
|
Population(Configuration a_config,
IChromosome a_chromosome)
|
|
Population(Configuration a_config,
IChromosome[] a_chromosomes)
|
|
Population(Configuration a_config,
int a_size)
|
|
| Method Summary | |
|---|---|
void |
addChromosome(IChromosome a_toAdd)
Adds a Chromosome to this Population. |
void |
addChromosomes(Population a_population)
Adds all the Chromosomes in the given Population. |
void |
clear()
Clears the list of chromosomes. |
java.lang.Object |
clone()
|
int |
compareTo(java.lang.Object a_pop)
This method is not producing symmetric results as -1 is more often returned than 1 (see description of return value). |
boolean |
contains(IChromosome a_chromosome)
Determines whether the given chromosome is contained within the population. |
protected IChromosome |
createChromosome(java.lang.String a_chromClassName,
java.lang.String a_persistentRepresentation)
Creates a new Chromosome instance. |
IChromosome |
determineFittestChromosome()
Determines the fittest Chromosome in the Population (the one with the highest fitness value) and memorizes it. |
IChromosome |
determineFittestChromosome(int a_startIndex,
int a_endIndex)
Determines the fittest Chromosome in the population (the one with the highest fitness value) within the given indices and memorizes it. |
java.util.List |
determineFittestChromosomes(int a_numberOfChromosomes)
Sorts the Chromosome list and returns the fittest n Chromosomes in the population. |
boolean |
equals(java.lang.Object a_pop)
The equals-method. |
IChromosome |
getChromosome(int a_index)
|
java.util.List |
getChromosomes()
|
Configuration |
getConfiguration()
|
java.util.List |
getGenome(boolean a_resolveCompositeGenes)
Returns the genotype of the population, i.e. the list of genes in the Population. |
java.lang.String |
getPersistentRepresentation()
Returns a persistent representation of this chromosome, see interface Gene for description. |
boolean |
isChanged()
|
boolean |
isSorted()
|
java.util.Iterator |
iterator()
|
void |
keepPopSizeConstant()
Cares that the population size does not exceed the maximum size given in the configuration. |
protected void |
setChanged(boolean a_changed)
Mark that for the population the fittest chromosome may have changed. |
void |
setChromosome(int a_index,
IChromosome a_chromosome)
Sets in the given Chromosome on the given index in the list of chromosomes. |
void |
setChromosomes(java.util.List a_chromosomes)
Replaces all chromosomes in the population with the give list of chromosomes. |
protected void |
setSorted(boolean a_sorted)
Mark the population as sorted. |
void |
setValueFromPersistentRepresentation(java.lang.String a_representation)
Counterpart of getPersistentRepresentation. |
int |
size()
|
protected void |
sort(java.util.Comparator a_comparator)
Sorts the chromosomes within the population utilzing the given comparator. |
void |
sortByFitness()
Sorts the chromosomes within the population according to their fitness value using ChromosomFitnessComparator. |
protected static java.util.List |
split(java.lang.String a_string)
Splits the input a_string into individual chromosome representations. |
IChromosome[] |
toChromosomes()
|
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String CHROM_DELIMITER
public static final java.lang.String CHROM_DELIMITER_HEADING
public static final java.lang.String CHROM_DELIMITER_CLOSING
| Constructor Detail |
|---|
public Population(Configuration a_config)
throws InvalidConfigurationException
InvalidConfigurationException
public Population(Configuration a_config,
IChromosome[] a_chromosomes)
throws InvalidConfigurationException
InvalidConfigurationException
public Population(Configuration a_config,
IChromosome a_chromosome)
throws InvalidConfigurationException
InvalidConfigurationException
public Population(Configuration a_config,
int a_size)
throws InvalidConfigurationException
InvalidConfigurationException
public Population()
throws InvalidConfigurationException
InvalidConfigurationException| Method Detail |
|---|
public Configuration getConfiguration()
public void addChromosome(IChromosome a_toAdd)
a_toAdd - the Chromosome to addpublic void addChromosomes(Population a_population)
a_population - the Population to addpublic void setChromosomes(java.util.List a_chromosomes)
a_chromosomes - the chromosomes to make the population up from
public void setChromosome(int a_index,
IChromosome a_chromosome)
a_index - the index to set the Chromosome ina_chromosome - the Chromosome to be setpublic java.util.List getChromosomes()
public IChromosome getChromosome(int a_index)
a_index - the index of the Chromosome to be returned
public int size()
public java.util.Iterator iterator()
public IChromosome[] toChromosomes()
public IChromosome determineFittestChromosome()
public IChromosome determineFittestChromosome(int a_startIndex,
int a_endIndex)
a_startIndex - index to begin the evaluation witha_endIndex - index to end the evaluation with
protected void setChanged(boolean a_changed)
a_changed - true: population's fittest chromosome may have changed,
false: fittest chromosome evaluated earlier is still validpublic boolean isChanged()
protected void setSorted(boolean a_sorted)
a_sorted - true: mark population as sortedpublic boolean contains(IChromosome a_chromosome)
a_chromosome - the chromosome to check
public void keepPopSizeConstant()
throws InvalidConfigurationException
InvalidConfigurationExceptionpublic java.util.List determineFittestChromosomes(int a_numberOfChromosomes)
a_numberOfChromosomes - number of top performer chromosomes to be
returned
public void sortByFitness()
protected void sort(java.util.Comparator a_comparator)
a_comparator - the comparator to utilize for sortingpublic java.util.List getGenome(boolean a_resolveCompositeGenes)
a_resolveCompositeGenes - true: split encountered CompositeGenes
into their single (atomic) genes
public boolean isSorted()
public boolean equals(java.lang.Object a_pop)
equals in class java.lang.Objecta_pop - the population instance to compare with
public int compareTo(java.lang.Object a_pop)
a_pop - the other population to compare
public java.lang.Object clone()
clone in interface ICloneableclone in class java.lang.Objectpublic void clear()
public java.lang.String getPersistentRepresentation()
getPersistentRepresentation in interface IPersistentRepresentationjava.lang.UnsupportedOperationException
public void setValueFromPersistentRepresentation(java.lang.String a_representation)
throws UnsupportedRepresentationException
setValueFromPersistentRepresentation in interface IPersistentRepresentationa_representation - the string representation retrieved from a prior
call to the getPersistentRepresentation() method
UnsupportedRepresentationException
protected IChromosome createChromosome(java.lang.String a_chromClassName,
java.lang.String a_persistentRepresentation)
throws java.lang.Exception
Taken and adapted from CompositeGene.
a_chromClassName - name of the Chromosome classa_persistentRepresentation - persistent representation of the
Chromosome to create (could be obtained via getPersistentRepresentation)
java.lang.Exception
protected static final java.util.List split(java.lang.String a_string)
throws UnsupportedRepresentationException
Taken and adapted from CompositeGene.
a_string - the string to split
UnsupportedRepresentationException
|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||