net.openai.ai.ga.cell
Class AbstractCell

java.lang.Object
  |
  +--net.openai.ai.ga.cell.AbstractCell
All Implemented Interfaces:
Cell

public abstract class AbstractCell
extends java.lang.Object
implements Cell

The AbstractCell class is an encapsulation of data that will be used to try to solve a problem (Environment). This class provides a skeletal implementation to minimize the effort needed to implement a simple Cell interface.

The following functions must be implemented in the derived class:

The following functions have basic functionality: The following functions are stubbed:

Since:
JDK1.3
Version:
%I%, %G%
Author:
Jared Grubb

Field Summary
protected  double cellFitness
          The last evaluated fitness for the cell is stored here and is used for the getFitness calls.
protected  int cellMaturity
          The maturity of the cell is stored here and is used for the getMaturity.
 
Constructor Summary
AbstractCell()
           
 
Method Summary
abstract  Population combine(Population parents)
          Tells the cell to create new offspring, which will be placed in the population.
 void condemn()
          Tells the cell that it has been condemned to die.
abstract  double evaluateFitness(Environment env)
          Return the fitness of the Cell.
 double getFitness()
          Return the fitness of the Cell.
 int getMaturity()
          Returns the maturity of the Cell.
 void mature()
          Tells the cell to mature.
 void mutate()
          Tells the cell that it has been chosen to mutate.
 java.lang.String toString()
          Returns a string showing the fitness and maturity of this cell.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cellFitness

protected double cellFitness
The last evaluated fitness for the cell is stored here and is used for the getFitness calls.


cellMaturity

protected int cellMaturity
The maturity of the cell is stored here and is used for the getMaturity.

Constructor Detail

AbstractCell

public AbstractCell()
Method Detail

getFitness

public double getFitness()
Return the fitness of the Cell. This call does not neccessarily require that a new evaluation is performed, only that the last fitness generated is desired. This is the preferred method for any function curious about the cell's fitness as it should not require any complex calculations. The fitness must be quantifiable as an integer.

This skeletal implementation returns the value of the cellFitness member.

Specified by:
getFitness in interface Cell
Returns:
a double representing the fitness of this Cell

evaluateFitness

public abstract double evaluateFitness(Environment env)
Return the fitness of the Cell. This call asks that a new evaluation is performed. This method is called during every iteration of a Population. The implementation must determine whether a new evaluation is required or whether the last returned value will suffice. The fitness must be quantifiable as an integer. This function should only be called if there is reason to ask for a new value, but should be generally avoided since it may require extra overhead.

There is no implementation in this skeletal implementation and must be provided by the derived class.

Specified by:
evaluateFitness in interface Cell
Parameters:
env - the Environment to evaluate against
Returns:
a double representing the fitness of this Cell

getMaturity

public int getMaturity()
Returns the maturity of the Cell.

This skeletal implementation returns the value of the cellMaturity member.

Specified by:
getMaturity in interface Cell
Returns:
the maturity of this Cell

condemn

public void condemn()
Tells the cell that it has been condemned to die. This allows for any extra clean-up necessary or for record-keeping of cells that are removed from a population. It is not required that the Cell destroy itself or any objects, but is provided as notification that the Cell will be removed from the population.

This skeletal implementation is a stub {}.

Specified by:
condemn in interface Cell

mutate

public void mutate()
Tells the cell that it has been chosen to mutate. This skeletal implementation is a stub {}.

Specified by:
mutate in interface Cell

mature

public void mature()
Tells the cell to mature. This function is called before evaluation on the cells. Outside calling of this function should be avoided as it may cause over-maturation of a cell. This function may also be as simple as incrementing the age of the cell.

This skeletal implementation increments the cellMaturity member by 1.

Specified by:
mature in interface Cell

combine

public abstract Population combine(Population parents)
Tells the cell to create new offspring, which will be placed in the population. The offspring should be new Cell created by some combination of the parents and should also be initialized with data. The instance of Cell called is the first Cell in the Population.

Specified by:
combine in interface Cell
Parameters:
parents - the chosen Population of parents for the new cell
Returns:
a new Population to be added into the population

toString

public java.lang.String toString()
Returns a string showing the fitness and maturity of this cell. Returned as "(fitness,maturity)".

Overrides:
toString in class java.lang.Object
Returns:
a String containing the fitness and maturity


Copyright - 2001 OpenAI Labs. All Rights Reserved.