|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.openai.ai.ga.cell.AbstractCell
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:
double evaluateFitness(Environment)
Cell combine(Population)
double getFitness()
int getMaturity()
void mature()
void condemn()
void mutate()
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 |
protected double cellFitness
getFitness
calls.
protected int cellMaturity
getMaturity
.
Constructor Detail |
public AbstractCell()
Method Detail |
public double getFitness()
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.
getFitness
in interface Cell
double
representing the fitness of this
Cell
public abstract double evaluateFitness(Environment env)
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.
evaluateFitness
in interface Cell
env
- the Environment
to evaluate against
double
representing the fitness of this
Cell
public int getMaturity()
Cell
.
This skeletal implementation returns the value of the
cellMaturity
member.
getMaturity
in interface Cell
Cell
public void condemn()
This skeletal implementation is a stub {}
.
condemn
in interface Cell
public void mutate()
{}
.
mutate
in interface Cell
public void mature()
This skeletal implementation increments the cellMaturity member by 1.
mature
in interface Cell
public abstract Population combine(Population parents)
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
.
combine
in interface Cell
parents
- the chosen Population
of parents for
the new cell
Population
to be added into the populationpublic java.lang.String toString()
toString
in class java.lang.Object
String
containing the fitness and maturity
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |