Class Population

java.lang.Object
  extended by Population

public class Population
extends java.lang.Object


Field Summary
static int DEFAULT_POPULATION_SIZE
          A constant that will be used as the default size of the population
 
Constructor Summary
Population(int initialSize, java.lang.String chain)
          A constructor of arity 2 to initialize the Population.
Population(java.lang.String chain)
          A constructor of arity 1 to initialize the Population.
 
Method Summary
 void evolve()
          The method evolve selects parent chromosomes.
 Chromosome getFittest()
          The instance method public Chromosome getFittest() returns the "best" individual of the population, i.e.
 java.lang.String toString()
          Returns a String representation of this Population.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_POPULATION_SIZE

public static final int DEFAULT_POPULATION_SIZE
A constant that will be used as the default size of the population

See Also:
Constant Field Values
Constructor Detail

Population

public Population(int initialSize,
                  java.lang.String chain)
A constructor of arity 2 to initialize the Population.

Parameters:
size - is the size of the population, the number of chromosomes to be created
chain - is the chain for which a fold is sought

Population

public Population(java.lang.String chain)
A constructor of arity 1 to initialize the Population. The population has the default size.

Parameters:
chain - is the chain for which a fold is sought
Method Detail

evolve

public void evolve()
The method evolve selects parent chromosomes. An offspring is then created from the two parents, using the method crossover. The offspring is mutated, and then inserted into the population. As a result, the least fitted individual will be eliminated from the population. Remember that the population is kept in increasing order of fitness. For the selection of the parents, you can experiment with different scenarios. A possible scenario is to randomly select two parents. Another possible one would be to select the fittest, and a randomly selected one. Or else, select the two most fitted individuals.


getFittest

public Chromosome getFittest()
The instance method public Chromosome getFittest() returns the "best" individual of the population, i.e. the one that has the smallest fitness value.

Returns:
returns the currently best solution

toString

public java.lang.String toString()
Returns a String representation of this Population.

Overrides:
toString in class java.lang.Object
Returns:
the String representation of this Population