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 |
setPopulationLimit(int populationLimit)
Sets the maximal population size.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
nextGeneration
forEach, spliterator
public ListPopulation(int populationLimit) throws MathIllegalArgumentException
populationLimit
- maximal size of the populationMathIllegalArgumentException
- if the population limit is not a positive number (< 1)public ListPopulation(List<Chromosome> chromosomes, int populationLimit) throws MathIllegalArgumentException, NullArgumentException
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 null
MathIllegalArgumentException
- if the population limit is not a positive number (< 1)MathIllegalArgumentException
- if the list of chromosomes exceeds the population limitpublic void addChromosomes(Collection<Chromosome> chromosomeColl) throws MathIllegalArgumentException
Collection
of chromosomes to this Population
.chromosomeColl
- a Collection
of chromosomesMathIllegalArgumentException
- 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 MathIllegalArgumentException
addChromosome
in interface Population
chromosome
- the chromosome to add.MathIllegalArgumentException
- 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 MathIllegalArgumentException
populationLimit
- maximal population size.MathIllegalArgumentException
- if the population limit is not a positive number (< 1)MathIllegalArgumentException
- if the new population size is smaller than the current number
of chromosomes in the populationpublic int getPopulationSize()
getPopulationSize
in interface Population
public Iterator<Chromosome> iterator()
Any call to Iterator.remove()
will result in a UnsupportedOperationException
.
iterator
in interface Iterable<Chromosome>
Copyright © 2016 Hipparchus.org. All rights reserved.