public abstract class ListPopulation extends Object implements Population
List
.Constructor and Description |
---|
ListPopulation(int populationLimitIn)
Creates a new ListPopulation instance and initializes its inner chromosome list.
|
ListPopulation(List<Chromosome> chromosomesIn,
int populationLimitIn)
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 populationLimitIn)
Sets the maximal population size.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
nextGeneration
forEach, spliterator
public ListPopulation(int populationLimitIn)
populationLimitIn
- maximal size of the populationNotPositiveException
- if the population limit is not a positive number (< 1)public ListPopulation(List<Chromosome> chromosomesIn, int populationLimitIn)
Note: the chromosomes of the specified list are added to the population.
chromosomesIn
- list of chromosomes to be added to the populationpopulationLimitIn
- maximal size of the populationNullArgumentException
- 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 limitpublic void addChromosomes(Collection<Chromosome> chromosomeColl)
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)
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 populationLimitIn)
populationLimitIn
- 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 Iterator<Chromosome> iterator()
Any call to Iterator.remove()
will result in a UnsupportedOperationException
.
iterator
in interface Iterable<Chromosome>
Copyright © 2019 CNES. All rights reserved.