jaga.evolve
Class Population

java.lang.Object
  |
  +--jaga.evolve.Population
All Implemented Interfaces:
java.io.Serializable

public class Population
extends java.lang.Object
implements java.io.Serializable

A collection of genotypes.

See Also:
Serialized Form

Field Summary
static java.lang.String GEN_DECL
           
static java.lang.String IND_DECL
           
static java.lang.String POP_DECL
           
 
Constructor Summary
Population()
          Creates new Population
Population(int genNr)
           
 
Method Summary
 void add(Genotype g)
           
 void addRandom(Genotype g)
           
 int[] findFittest(int howMany)
          finds the fittest individuals of the population
 double getAvgFitness()
           
 Genotype[] getFittest(int howMany)
           
 int getGeneration()
           
 Genotype getGenotype(int idx)
           
 java.util.Vector getPopVector()
          Should return clone of genotypes, or return new Vector( genotypes );
 void insertGenotype(Genotype g)
          Replaces first individual in pop by g.
 void readFromFile(java.lang.String fileName)
           
 int size()
           
 void sort()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

POP_DECL

public static final java.lang.String POP_DECL

GEN_DECL

public static final java.lang.String GEN_DECL

IND_DECL

public static final java.lang.String IND_DECL
Constructor Detail

Population

public Population()
Creates new Population

Population

public Population(int genNr)
Method Detail

getGenotype

public Genotype getGenotype(int idx)

add

public void add(Genotype g)

addRandom

public void addRandom(Genotype g)

size

public int size()

getPopVector

public java.util.Vector getPopVector()
Should return clone of genotypes, or return new Vector( genotypes );

findFittest

public int[] findFittest(int howMany)
finds the fittest individuals of the population
Parameters:
howMany - of the fittest to return
Returns:
an array of their positions in the population array (made public static to test)

getFittest

public Genotype[] getFittest(int howMany)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

insertGenotype

public void insertGenotype(Genotype g)
Replaces first individual in pop by g. Good to put migrators in when population unsorted.

sort

public void sort()

getGeneration

public int getGeneration()

getAvgFitness

public double getAvgFitness()

readFromFile

public void readFromFile(java.lang.String fileName)