gpsys
Class CrossoverBookkeeping

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

class CrossoverBookkeeping
extends java.lang.Object

This is an implementation of the bookkeeping class used for memory efficient crossover as described in the book Genetic Programming III.

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:
Population, GPParameters

Field Summary
(package private)  ParentInfo[] listHead
          The list heads in this array are used to create 4 lists.
(package private)  ParentInfo[] parentTable
          The parent table is 2 elements bigger than the number of individuals in the population.
 
Constructor Summary
(package private) CrossoverBookkeeping(int size)
          Construct a bookkeeping object suitable for storing the selected genetic operations for creating the next generation.
 
Method Summary
(package private)  void addCrossoverOperation(int p1, int p2)
          Add a crossover operation to the list of operations to be performed.
(package private)  void addMutationOperation(int p)
          Add a mutation operation to the list of operations to be performed.
(package private)  void addReproductionOperation(int p)
          Add a reproduction operation to the list of operations to be performed.
private  void addToList(ParentInfo parent)
          Add the parent mating information structure to the appropriate list.
(package private)  void createLists()
          Populate the four lists with parent mating information.
(package private)  int removeFreeSlot()
          Remove a parent from the free list.
private  void removeFromList(ParentInfo parent)
          Remove the parent mating information structure from the associated list.
(package private)  GeneticOperation removeOperation()
          Remove a genetic operation from the list of operations to be performed.
(package private)  void reset()
          Reset the bookkeeping data structure.
 java.lang.String toString()
          Create a string representation of the bookkeeping data structure.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

listHead

ParentInfo[] listHead
The list heads in this array are used to create 4 lists. These lists hold information about parents with 0, 1, 2 or more operations respectively.

parentTable

ParentInfo[] parentTable
The parent table is 2 elements bigger than the number of individuals in the population. It holds information about each individual as a potential parent. The extra 2 slots are required by the algorithm to gurantee that sufficient space is avaliable for newly created individuals.
Constructor Detail

CrossoverBookkeeping

CrossoverBookkeeping(int size)
Construct a bookkeeping object suitable for storing the selected genetic operations for creating the next generation.
Parameters:
size - The size of the population.
Method Detail

addCrossoverOperation

void addCrossoverOperation(int p1,
                           int p2)
Add a crossover operation to the list of operations to be performed.
Parameters:
p1 - The index of the first parent.
p1 - The index of the second parent.

addReproductionOperation

void addReproductionOperation(int p)
Add a reproduction operation to the list of operations to be performed.
Parameters:
p - The index of the individual to be reproduced.

addMutationOperation

void addMutationOperation(int p)
Add a mutation operation to the list of operations to be performed.
Parameters:
p - The index of the individual to be mutated.

removeOperation

GeneticOperation removeOperation()
Remove a genetic operation from the list of operations to be performed. The selected operation is guranteed to involve a parent with the least number of operations remaining.
Returns:
The next GeneticOperation to be performed.

removeFreeSlot

int removeFreeSlot()
Remove a parent from the free list.
Returns:
the index of the removed parent.

createLists

void createLists()
Populate the four lists with parent mating information.

addToList

private void addToList(ParentInfo parent)
Add the parent mating information structure to the appropriate list. The parent information will be added to either the 1st, 2nd, 3rd or 4rth list depending on wether the parent is ivolved in 0, 1, 2 or more than two genetic operations respectively.

removeFromList

private void removeFromList(ParentInfo parent)
Remove the parent mating information structure from the associated list.

reset

void reset()
Reset the bookkeeping data structure. This method resets each parent information data structure and ensures that the 4 lists are empty.

toString

public java.lang.String toString()
Create a string representation of the bookkeeping data structure.
Returns:
A String representing the current state of this object.
Overrides:
toString in class java.lang.Object