public abstract class ListPopulation extends Object implements Population
List.| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitnextGenerationpublic ListPopulation(int populationLimit)
throws NotPositiveException
populationLimit - maximal size of the populationNotPositiveException - 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 populationNullArgumentException - if the list of chromosomes is nullNotPositiveException - if the population limit is not a positive number (< 1)NumberIsTooLargeException - if the list of chromosomes exceeds the population limit@Deprecated public void setChromosomes(List<Chromosome> chromosomes) throws NullArgumentException, NumberIsTooLargeException
addChromosomes(Collection) insteadNote: this method removes all existing chromosomes in the population and adds all chromosomes of the specified list to the population.
chromosomes - the list of chromosomesNullArgumentException - if the list of chromosomes is nullNumberIsTooLargeException - 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 chromosomesNumberIsTooLargeException - 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 Populationchromosome - the chromosome to add.NumberIsTooLargeException - if the population would exceed the populationLimit after
adding this chromosomepublic Chromosome getFittestChromosome()
getFittestChromosome in interface Populationpublic int getPopulationLimit()
getPopulationLimit in interface Populationpublic 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 Populationpublic Iterator<Chromosome> iterator()
Any call to Iterator.remove() will result in a UnsupportedOperationException.
iterator in interface Iterable<Chromosome>Copyright © 2003–2016 The Apache Software Foundation. All rights reserved.