be.optiloading
Class Population

java.lang.Object
  extended by be.optiloading.Population

public class Population
extends java.lang.Object

Population class stores Chromosomes and selects them.

Author:
Tim Pintens, info@optiloading.be, www.optiloading.be

Constructor Summary
Population()
          Construtor initializes the Arraylist
 
Method Summary
 void addChromosome(Chromosome chrom)
          addChromosome method adds a new Chromosome to the population.
 void createInitialPopulation()
          creatInitialPopulation method creates the initial population
 Population elitism(int rate)
          Creates a new population; keeping into account the elitism rate.
 Chromosome getBestchromosome()
          getBestchromosome method for getting the best Chromosome.
 java.util.ArrayList<Chromosome> getChromList()
          getChromList method for getting the list of Chromosome.
 float getTotalfitness()
          getTotalfitness method for getting the total fitness.
 Chromosome selectRankChromosome()
          selectRankChromosome method uses the rank selection for selecting a Chromosome.
 Chromosome selectRouletteChromosome()
          selectRouletteChromosome method uses the roulette selection for selecting a Chromosome.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Population

public Population()
Construtor initializes the Arraylist

Method Detail

elitism

public Population elitism(int rate)
Creates a new population; keeping into account the elitism rate.

Parameters:
rate - Integer value indicating how many chromosomes to copy from original population.

createInitialPopulation

public void createInitialPopulation()
creatInitialPopulation method creates the initial population


addChromosome

public void addChromosome(Chromosome chrom)
addChromosome method adds a new Chromosome to the population.

Parameters:
chrom - Chromosome object that is to be added.

getTotalfitness

public float getTotalfitness()
getTotalfitness method for getting the total fitness.

Returns:
Floating point value containing the total fitness.

getBestchromosome

public Chromosome getBestchromosome()
getBestchromosome method for getting the best Chromosome.

Returns:
Chromosome object which is the best of its population

getChromList

public java.util.ArrayList<Chromosome> getChromList()
getChromList method for getting the list of Chromosome.

Returns:
ArrayList containing the Chromosome objects.

selectRouletteChromosome

public Chromosome selectRouletteChromosome()
selectRouletteChromosome method uses the roulette selection for selecting a Chromosome.

Returns:
Chromosome object that is chosen.

selectRankChromosome

public Chromosome selectRankChromosome()
selectRankChromosome method uses the rank selection for selecting a Chromosome. Chromosomes are order according to their fitness value from small to large. The index number of each Chromosome is used to select the Chromosome.

Returns:
Chromosome object that is chosen.