JavaGenes, NASA Ames. Written largely by Al Globus

gov.nasa.javaGenes.core
Class Population

java.lang.Object
  extended bygov.nasa.javaGenes.core.Population
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ChromosomePopulation, EOSschedulingPopulation, GraphPopulation, PermutationPopulation

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

Represents a population of evolvable Graph objects

See Also:
Serialized Form

Field Summary
protected  int generation
           
protected  long memory
          memory used by the program after population generated
protected  Individual[] population
           
protected  long time
          time to generate this population
 
Constructor Summary
Population(int size)
          create an empty population with int size members
 
Method Summary
 double averageFitness()
           
 Fitness bestFitness()
           
 Individual bestIndividual()
           
 int bestIndividualIndex()
           
protected  int countParts(Iterator i, java.util.Hashtable table)
           
 void evaluateFitness(FitnessFunction f)
          Calculate the fitness of all individuals in the population.
protected  void fillEntropy(ManySamples samples, java.util.Hashtable table, int count, java.lang.String name)
           
 void fillSamples(ManySamples samples)
          Add Sample objects to ManySamples samples that summarize the population.
 Evolvable getEvolvable(int i)
           
 java.lang.String getEvolvableHeader()
           
 Fitness getFitness(int i)
           
 int getGeneration()
           
 int getIndex(Individual individual)
           
 IntegerInterval getIndexRange()
           
 Individual getIndividual(int i)
           
 int getLastIndex()
           
 java.lang.String getLogHeaderString()
           
 java.lang.String getLogString(FitnessFunction distanceFunction)
           
 long getMemory()
           
 Population getParetoFront()
           
 int getSize()
           
 java.lang.String getStandarPartOfLogHeaderString()
           
 long getTime()
           
 java.lang.String getUniqueLogValue(Individual best)
           
 java.lang.String getUniqueLogValueHeader()
           
 boolean isDuplicate(Individual individual)
           
 boolean isIndexLegal(int index)
           
 Individual makeIndividual(Evolvable e, FitnessFunction f)
          Meant to be a general purpose method that creates individuals of whatever type are in this population.
 Individual[] makeIndividualArray(int[] indices)
           
 Population makePopulation(int size)
           
 Individual pick()
           
 Individual pick(Individual notThis)
           
 Individual pick(Individual notThis, Individual orThis)
           
 void report(java.io.PrintWriter out)
          Write out an ASCII version of the population
 void retestStudents(StudentFitnessFunction f)
           
 void setGeneration(int g)
           
 void setIndividual(int i, Individual person)
           
 void setMemory(long m)
           
 void setTime(long t)
           
 void stateRestore(TokenizeInput tokenizer)
          write to a checkpoint file
 void stateSave(TokenizeOutput tokenizer)
          read from a checkpoint file
 int totalEvolvableSize()
           
 Fitness worstFitness()
           
 Fitness worstFitness(Fitness mustBeBetterThan)
           
 Individual worstIndividual()
           
 Individual worstIndividual(Fitness mustBeBetterThan)
           
 int worstIndividualIndex()
           
 int worstIndividualIndex(Fitness mustBeBetterThan)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

population

protected Individual[] population

generation

protected int generation

time

protected long time
time to generate this population


memory

protected long memory
memory used by the program after population generated

Constructor Detail

Population

public Population(int size)
create an empty population with int size members

Method Detail

stateSave

public void stateSave(TokenizeOutput tokenizer)
read from a checkpoint file


stateRestore

public void stateRestore(TokenizeInput tokenizer)
write to a checkpoint file


makePopulation

public Population makePopulation(int size)
Returns:
a new empty population with int size members

makeIndividual

public Individual makeIndividual(Evolvable e,
                                 FitnessFunction f)
Meant to be a general purpose method that creates individuals of whatever type are in this population. Must be rewritten to actually do that.

Returns:
a new Individual that has a evolvable. Normally replaced by subclass.

getIndexRange

public IntegerInterval getIndexRange()

getLastIndex

public int getLastIndex()

evaluateFitness

public void evaluateFitness(FitnessFunction f)
Calculate the fitness of all individuals in the population.


getFitness

public Fitness getFitness(int i)

getEvolvable

public Evolvable getEvolvable(int i)

retestStudents

public void retestStudents(StudentFitnessFunction f)

getParetoFront

public Population getParetoFront()

totalEvolvableSize

public int totalEvolvableSize()
Returns:
the sum of the sizes of each individual in the population.

getIndex

public int getIndex(Individual individual)
Returns:
the index (starting at 0) of GraphIndividual individual

averageFitness

public double averageFitness()
Returns:
the mean of the fitness of all individuals that have a normal number for fitness. Return 0 if no individuals have a normal number for the fitness.

bestIndividual

public Individual bestIndividual()
Returns:
the most fit individual in the population

bestFitness

public Fitness bestFitness()
Returns:
the fitness of the most fit individual

bestIndividualIndex

public int bestIndividualIndex()
Returns:
the index of the most fit individual

worstFitness

public Fitness worstFitness()

worstIndividual

public Individual worstIndividual()

worstIndividualIndex

public int worstIndividualIndex()

worstIndividual

public Individual worstIndividual(Fitness mustBeBetterThan)
                           throws NotFoundException
Throws:
NotFoundException

worstFitness

public Fitness worstFitness(Fitness mustBeBetterThan)
                     throws NotFoundException
Throws:
NotFoundException

worstIndividualIndex

public int worstIndividualIndex(Fitness mustBeBetterThan)
                         throws NotFoundException
Returns:
the index of the least fit individual better than mustBeBetterThan. It's a fatal error for there to be no better
Throws:
NotFoundException

isIndexLegal

public boolean isIndexLegal(int index)

makeIndividualArray

public Individual[] makeIndividualArray(int[] indices)

pick

public Individual pick()
Returns:
a random individual

pick

public Individual pick(Individual notThis)
Returns:
a random individual that isn't notThis. If the population only has one individual this method will loop forever.

pick

public Individual pick(Individual notThis,
                       Individual orThis)
Returns:
a random individual that isn't notThis or orThis. If the population only has one individual this method will loop forever.

fillSamples

public void fillSamples(ManySamples samples)
Add Sample objects to ManySamples samples that summarize the population. Used for data analysis of evolution.

See Also:
Sample

countParts

protected int countParts(Iterator i,
                         java.util.Hashtable table)

fillEntropy

protected void fillEntropy(ManySamples samples,
                           java.util.Hashtable table,
                           int count,
                           java.lang.String name)

report

public void report(java.io.PrintWriter out)
Write out an ASCII version of the population


isDuplicate

public boolean isDuplicate(Individual individual)

getLogHeaderString

public java.lang.String getLogHeaderString()
Returns:
a tab separated string for getLogString
See Also:
getLogString(gov.nasa.javaGenes.core.FitnessFunction)

getStandarPartOfLogHeaderString

public java.lang.String getStandarPartOfLogHeaderString()

getEvolvableHeader

public java.lang.String getEvolvableHeader()

getLogString

public java.lang.String getLogString(FitnessFunction distanceFunction)
Returns:
a tab separated string summarizing the population

getUniqueLogValueHeader

public java.lang.String getUniqueLogValueHeader()

getUniqueLogValue

public java.lang.String getUniqueLogValue(Individual best)

setIndividual

public void setIndividual(int i,
                          Individual person)

getIndividual

public Individual getIndividual(int i)

getSize

public int getSize()

setTime

public void setTime(long t)

getTime

public long getTime()

setGeneration

public void setGeneration(int g)

getGeneration

public int getGeneration()

setMemory

public void setMemory(long m)

getMemory

public long getMemory()

JavaGenes, NASA Ames. Written largely by Al Globus