Package org.apache.commons.math.genetics
Class ListPopulation
java.lang.Object
org.apache.commons.math.genetics.ListPopulation
- All Implemented Interfaces:
Iterable<Chromosome>,Population
- Direct Known Subclasses:
ElitisticListPopulation
Population of chromosomes represented by a
List.- Since:
- 2.0
-
Constructor Summary
ConstructorsConstructorDescriptionListPopulation(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
Modifier and TypeMethodDescriptionvoidaddChromosome(Chromosome chromosome) Add the given chromosome to the population.Access the list of chromosomes.Access the fittest chromosome in this population.intAccess the maximum population size.intAccess the current population size.iterator()Chromosome list iteratorvoidsetChromosomes(List<Chromosome> chromosomes) Sets the list of chromosomes.voidsetPopulationLimit(int populationLimit) Sets the maximal population size.toString()Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.apache.commons.math.genetics.Population
nextGeneration
-
Constructor Details
-
ListPopulation
Creates a new ListPopulation instance.- Parameters:
chromosomes- list of chromosomes in the populationpopulationLimit- maximal size of the population
-
ListPopulation
public ListPopulation(int populationLimit) Creates a new ListPopulation instance and initializes its inner chromosome list.- Parameters:
populationLimit- maximal size of the population
-
-
Method Details
-
setChromosomes
Sets the list of chromosomes.- Parameters:
chromosomes- the list of chromosomes
-
getChromosomes
Access the list of chromosomes.- Returns:
- the list of chromosomes
-
addChromosome
Add the given chromosome to the population.- Specified by:
addChromosomein interfacePopulation- Parameters:
chromosome- the chromosome to add.
-
getFittestChromosome
Access the fittest chromosome in this population.- Specified by:
getFittestChromosomein interfacePopulation- Returns:
- the fittest chromosome.
-
getPopulationLimit
public int getPopulationLimit()Access the maximum population size.- Specified by:
getPopulationLimitin interfacePopulation- Returns:
- the maximum population size.
-
setPopulationLimit
public void setPopulationLimit(int populationLimit) Sets the maximal population size.- Parameters:
populationLimit- maximal population size.
-
getPopulationSize
public int getPopulationSize()Access the current population size.- Specified by:
getPopulationSizein interfacePopulation- Returns:
- the current population size.
-
toString
-
iterator
Chromosome list iterator- Specified by:
iteratorin interfaceIterable<Chromosome>- Returns:
- chromosome iterator
-