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
public abstract class ListPopulation extends Object implements Population
Population of chromosomes represented by aList.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChromosome(Chromosome chromosome)Add the given chromosome to the population.List<Chromosome>getChromosomes()Access the list of chromosomes.ChromosomegetFittestChromosome()Access the fittest chromosome in this population.intgetPopulationLimit()Access the maximum population size.intgetPopulationSize()Access the current population size.Iterator<Chromosome>iterator()Chromosome list iteratorvoidsetChromosomes(List<Chromosome> chromosomes)Sets the list of chromosomes.voidsetPopulationLimit(int populationLimit)Sets the maximal population size.StringtoString()-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.apache.commons.math.genetics.Population
nextGeneration
-
-
-
-
Constructor Detail
-
ListPopulation
public ListPopulation(List<Chromosome> chromosomes, int populationLimit)
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 Detail
-
setChromosomes
public void setChromosomes(List<Chromosome> chromosomes)
Sets the list of chromosomes.- Parameters:
chromosomes- the list of chromosomes
-
getChromosomes
public List<Chromosome> getChromosomes()
Access the list of chromosomes.- Returns:
- the list of chromosomes
-
addChromosome
public void addChromosome(Chromosome chromosome)
Add the given chromosome to the population.- Specified by:
addChromosomein interfacePopulation- Parameters:
chromosome- the chromosome to add.
-
getFittestChromosome
public Chromosome 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.
-
iterator
public Iterator<Chromosome> iterator()
Chromosome list iterator- Specified by:
iteratorin interfaceIterable<Chromosome>- Returns:
- chromosome iterator
-
-