gpsys
Class Population

java.lang.Object
  |
  +--gpsys.Population

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

A Population holds all the Individuals of a generation. Additional information is maintained such as the current generation number, the average fitness and complexity of the Individuals, and the best individual in the Population.

Version:
$Revision: 1.1 $, $Date: 2000/07/05 16:21:25 $
Author:
Adil Qureshi
Department of Computer Science,
University College London,
Gower St,
London WC1E 6BT,
UK.
See Also:
Serialized Form

Field Summary
 double averageComplexity
          The average number of nodes in the Individuals of the Population.
 Fitness averageFitness
          The average fitness of the Population.
 Individual bestGeneration
          The fittest Individual in the Population.
 Individual bestRun
          The fittest Individual of the Run.
private  CrossoverBookkeeping bookkeepingInfo
          Used for implementing a minimal memory generational evolution engine.
private static int CROSSOVER
          Used internally to signal a crossover operation.
 long crossovers
          Total number of crossovers performed.
 int generation
          The current generation number.
 GPParameters gpParameters
          The GP parameters for the problem.
private static int MUTATION
          Used internally to signal a mutation operation.
 long mutations
          Total number of mutations performed.
 Individual[] p
          The Individuals in this population.
private static int REPRODUCTION
          Used internally to signal a reproduction operation.
 long reproductions
          Total number of reproductions performed.
 
Constructor Summary
Population(GPParameters gpParameters)
           
 
Method Summary
 void evolve()
          Evolve the current population via the steady state or generational engine depending on the value of the engine parameter.
 void evolveGenerational()
           
 void evolveSteadyState()
           
private  Individual executeCrossoverOperation(int mum, int dad)
          Execute a crossover operation using specified parents.
private  Individual executeMutationOperation(int mum)
          Execute a mutation operation using specified parent.
private  Individual executeReproductionOperation(int mum)
          Execute a reproduction operation using the specified parent.
 void report(java.io.PrintWriter pw)
          Print a report of the population using the specified PrintWriter.
private  int selectBest()
          Select the best individual from a tournament.
private  int selectGeneticOperation()
          Randomly select a new Genetic Operation to be performed using the selection probabilities specified in the GPParameters object via the variable pMutation and pReproduction.
private  int selectWorst()
          Select the worst individual from a tournament.
private  void sort(int[] indexList)
          Sort an array of indices to Individuals so that the first index references the best Individual, and the last the worst.
private  int[] tournamentSelect()
          Perform tournament selection.
 void updateStats()
          Update the statistics for the Population.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

p

public Individual[] p
The Individuals in this population.

generation

public int generation
The current generation number.

bestGeneration

public Individual bestGeneration
The fittest Individual in the Population.

bestRun

public Individual bestRun
The fittest Individual of the Run.

averageFitness

public Fitness averageFitness
The average fitness of the Population.

averageComplexity

public double averageComplexity
The average number of nodes in the Individuals of the Population.

gpParameters

public GPParameters gpParameters
The GP parameters for the problem.

reproductions

public long reproductions
Total number of reproductions performed.

mutations

public long mutations
Total number of mutations performed.

crossovers

public long crossovers
Total number of crossovers performed.

bookkeepingInfo

private transient CrossoverBookkeeping bookkeepingInfo
Used for implementing a minimal memory generational evolution engine.

REPRODUCTION

private static final int REPRODUCTION
Used internally to signal a reproduction operation.

MUTATION

private static final int MUTATION
Used internally to signal a mutation operation.

CROSSOVER

private static final int CROSSOVER
Used internally to signal a crossover operation.
Constructor Detail

Population

public Population(GPParameters gpParameters)
Method Detail

evolve

public void evolve()
Evolve the current population via the steady state or generational engine depending on the value of the engine parameter.

evolveSteadyState

public void evolveSteadyState()

evolveGenerational

public void evolveGenerational()

executeCrossoverOperation

private Individual executeCrossoverOperation(int mum,
                                             int dad)
Execute a crossover operation using specified parents.
Parameters:
mum - index of the first parent involved in the crossover.
father - index of the secong parent involved in the crossover.
Returns:
the child resulting from the crossover.

executeMutationOperation

private Individual executeMutationOperation(int mum)
Execute a mutation operation using specified parent.
Parameters:
mum - index of the parent involved in the mutation.
Returns:
the child resulting from a mutation of the parent.

executeReproductionOperation

private Individual executeReproductionOperation(int mum)
Execute a reproduction operation using the specified parent.
Parameters:
mum - index of the parent involved in the mutation.
Returns:
the child that is a reproduction of the parent.

selectGeneticOperation

private int selectGeneticOperation()
Randomly select a new Genetic Operation to be performed using the selection probabilities specified in the GPParameters object via the variable pMutation and pReproduction. The probability of selecting a crossover operation is 1 - (pMutation + pReproduction).
Returns:
Either REPRODUCTION, MUTATION or CROSSOVER.

selectBest

private int selectBest()
Select the best individual from a tournament.
Returns:
The index of the best individual from a tournament.

selectWorst

private int selectWorst()
Select the worst individual from a tournament.
Returns:
The index of the worst individual from a tournament.

tournamentSelect

private int[] tournamentSelect()
Perform tournament selection. N (specified by the tournament size in the GP parameters) unique individuals are selected at random, and sorted in order of Fitness (hightest first).
Returns:
An array of indices to N Individuals, sorted by fitness.

sort

private void sort(int[] indexList)
Sort an array of indices to Individuals so that the first index references the best Individual, and the last the worst.
Parameters:
The - array of indices to Individuals to be sorted.

updateStats

public void updateStats()
Update the statistics for the Population. This involves finding the individual with the highest fitness, calculating the average fitness over the population and calculating the average complexity over the population.

report

public void report(java.io.PrintWriter pw)
Print a report of the population using the specified PrintWriter. The report includes the generation number just completed, the date and time of completion, the average Fitness, the average complexity and a dump of the bestGeneration Individual.
Parameters:
The - PrintWriter to use to write the report.