|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.math3.genetics.ListPopulation
public abstract class ListPopulation
Population of chromosomes represented by a List
.
Constructor Summary | |
---|---|
ListPopulation(int populationLimit)
Creates a new ListPopulation instance and initializes its inner chromosome list. |
|
ListPopulation(List<Chromosome> chromosomes,
int populationLimit)
Creates a new ListPopulation instance. |
Method Summary | |
---|---|
void |
addChromosome(Chromosome chromosome)
Add the given chromosome to the population. |
void |
addChromosomes(Collection<Chromosome> chromosomeColl)
Add a Collection of chromosomes to this Population . |
protected List<Chromosome> |
getChromosomeList()
Access the list of chromosomes. |
List<Chromosome> |
getChromosomes()
Returns an unmodifiable list of the chromosomes in this population. |
Chromosome |
getFittestChromosome()
Access the fittest chromosome in this population. |
int |
getPopulationLimit()
Access the maximum population size. |
int |
getPopulationSize()
Access the current population size. |
Iterator<Chromosome> |
iterator()
Returns an iterator over the unmodifiable list of chromosomes. |
void |
setChromosomes(List<Chromosome> chromosomes)
Deprecated. use addChromosomes(Collection) instead |
void |
setPopulationLimit(int populationLimit)
Sets the maximal population size. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.commons.math3.genetics.Population |
---|
nextGeneration |
Constructor Detail |
---|
public ListPopulation(int populationLimit) throws NotPositiveException
populationLimit
- maximal size of the population
NotPositiveException
- if the population limit is not a positive number (< 1)public ListPopulation(List<Chromosome> chromosomes, int populationLimit) throws NullArgumentException, NotPositiveException, NumberIsTooLargeException
Note: the chromosomes of the specified list are added to the population.
chromosomes
- list of chromosomes to be added to the populationpopulationLimit
- maximal size of the population
NullArgumentException
- if the list of chromosomes is null
NotPositiveException
- if the population limit is not a positive number (< 1)
NumberIsTooLargeException
- if the list of chromosomes exceeds the population limitMethod Detail |
---|
@Deprecated public void setChromosomes(List<Chromosome> chromosomes) throws NullArgumentException, NumberIsTooLargeException
addChromosomes(Collection)
instead
Note: this method removed all existing chromosomes in the population and adds all chromosomes of the specified list to the population.
chromosomes
- the list of chromosomes
NullArgumentException
- if the list of chromosomes is null
NumberIsTooLargeException
- if the list of chromosomes exceeds the population limitpublic void addChromosomes(Collection<Chromosome> chromosomeColl) throws NumberIsTooLargeException
Collection
of chromosomes to this Population
.
chromosomeColl
- a Collection
of chromosomes
NumberIsTooLargeException
- if the population would exceed the population limit when
adding this chromosomepublic List<Chromosome> getChromosomes()
protected List<Chromosome> getChromosomeList()
public void addChromosome(Chromosome chromosome) throws NumberIsTooLargeException
addChromosome
in interface Population
chromosome
- the chromosome to add.
NumberIsTooLargeException
- if the population would exceed the populationLimit
after
adding this chromosomepublic Chromosome getFittestChromosome()
getFittestChromosome
in interface Population
public int getPopulationLimit()
getPopulationLimit
in interface Population
public void setPopulationLimit(int populationLimit) throws NotPositiveException, NumberIsTooSmallException
populationLimit
- maximal population size.
NotPositiveException
- if the population limit is not a positive number (< 1)
NumberIsTooSmallException
- if the new population size is smaller than the current number
of chromosomes in the populationpublic int getPopulationSize()
getPopulationSize
in interface Population
public String toString()
toString
in class Object
public Iterator<Chromosome> iterator()
Any call to Iterator.remove()
will result in a UnsupportedOperationException
.
iterator
in interface Iterable<Chromosome>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |