org.generation5.bio
Class EvolveStandard

java.lang.Object
  extended byorg.generation5.bio.EvolveStandard
All Implemented Interfaces:
java.lang.Comparable, Evolvable
Direct Known Subclasses:
EvoDiophantine, EvoHelloWorld

public abstract class EvolveStandard
extends java.lang.Object
implements Evolvable

EvolveStandard implements the Evolvable interface and provides default behaviour for fitness values, as well as providing the necessary Comparable implementation for sorting in both ascending and descending order.


Field Summary
protected  double fitnessValue
          The fitness value.
protected  boolean minimizeFitness
          Whether the genetic algorithm minimize or maximize the fitness.
protected static java.util.Random random
          An instance of java.util.Random, useful for generating a range of random numbers.
 
Constructor Summary
EvolveStandard()
          Creates a new instance of EvolveStandard
 
Method Summary
abstract  void calculateFitness()
          The fitness function.
 int compareTo(java.lang.Object o)
          Compares two EvolveStandard objects and sorts by fitness.
 double getFitness()
          Retrieve the fitness of this instance.
abstract  Evolvable mate(Evolvable partner)
          Abstract function to mate with another object to produce an offspring for the next generation.
abstract  void mutate()
          Abstract function to mutate the object.
abstract  void randomInitialize()
          An abstract function to randomize the object's initial settings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fitnessValue

protected double fitnessValue
The fitness value.


minimizeFitness

protected boolean minimizeFitness
Whether the genetic algorithm minimize or maximize the fitness. This is implemented through the sorting function.

See Also:
compareTo(Object)

random

protected static java.util.Random random
An instance of java.util.Random, useful for generating a range of random numbers.

Constructor Detail

EvolveStandard

public EvolveStandard()
Creates a new instance of EvolveStandard

Method Detail

calculateFitness

public abstract void calculateFitness()
The fitness function. Should store the fitness to fitnessValue.

Specified by:
calculateFitness in interface Evolvable

compareTo

public int compareTo(java.lang.Object o)
Compares two EvolveStandard objects and sorts by fitness. By default, values are sorted in ascending order.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the object to compare to.
Returns:
-1, 0 or 1 according to fitness levels.

getFitness

public double getFitness()
Retrieve the fitness of this instance.

Specified by:
getFitness in interface Evolvable
Returns:
the fitness value of this instance.

mate

public abstract Evolvable mate(Evolvable partner)
Abstract function to mate with another object to produce an offspring for the next generation.

Specified by:
mate in interface Evolvable
Parameters:
partner - the partner object.
Returns:
a child object.

mutate

public abstract void mutate()
Abstract function to mutate the object.

Specified by:
mutate in interface Evolvable

randomInitialize

public abstract void randomInitialize()
An abstract function to randomize the object's initial settings.

Specified by:
randomInitialize in interface Evolvable

This documentation is part of the Generation5 JDK.