org.vizzini.ai.geneticalgorithm
Class AbstractChromosome

java.lang.Object
  extended by org.vizzini.ai.geneticalgorithm.AbstractChromosome
All Implemented Interfaces:
Cloneable, Comparable, IChromosome
Direct Known Subclasses:
AbstractChromosomeGP, ChromosomeBoolean, ChromosomeDouble, ChromosomeInt

public abstract class AbstractChromosome
extends Object
implements IChromosome

Provides base functionality for chromosomes for a genetic algorithm.

Since:
v0.1
Version:
v0.3
Author:
Jeffrey M. Thompson

Field Summary
 
Fields inherited from interface org.vizzini.ai.geneticalgorithm.IChromosome
UNKNOWN_FITNESS
 
Constructor Summary
AbstractChromosome()
           
 
Method Summary
 void addFitness(int value)
          Add to the fitness.
 Object clone()
          Return a clone of this instance.
 int compareTo(Object another)
          Return -1, 0, or 1 if this is less than, equal to, or greater than the given chromosome.
 void copy(IChromosome another)
          Copy the given chromosome into this.
 boolean equals(Object object)
          Return true if the given object is equal to this.
 String getDescription()
          Return the description.
 int getFitness()
          Return the fitness.
 int hashCode()
          Returns a hash code value for the object.
 boolean isFitnessUnknown()
          Return true if the fitness is unknown.
 void mix(IChromosome c1, IChromosome c2, double fraction)
          Mix the genes of the given chromosomes into this using the given fraction.
 void setDescription(String description)
          Set the description.
 void setFitness(int fitness)
          Set the fitness.
 void setFitnessUnknown()
          Set the fitness to unknown.
 String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.vizzini.ai.geneticalgorithm.IChromosome
mix, mutate, randomlyInitialize, size, splice
 

Constructor Detail

AbstractChromosome

public AbstractChromosome()
Method Detail

addFitness

public void addFitness(int value)
Add to the fitness.

Specified by:
addFitness in interface IChromosome
Since:
v0.1

clone

public Object clone()
Return a clone of this instance.

Specified by:
clone in interface IChromosome
Overrides:
clone in class Object
Since:
v0.2

compareTo

public int compareTo(Object another)
Return -1, 0, or 1 if this is less than, equal to, or greater than the given chromosome.

Specified by:
compareTo in interface Comparable
Since:
v0.1

copy

public void copy(IChromosome another)
Copy the given chromosome into this.

Specified by:
copy in interface IChromosome
Since:
v0.1

equals

public boolean equals(Object object)
Return true if the given object is equal to this.

Specified by:
equals in interface IChromosome
Overrides:
equals in class Object
Parameters:
object - The object to compare.
Since:
v0.1

getDescription

public String getDescription()
Return the description.

Specified by:
getDescription in interface IChromosome
Since:
v0.1

getFitness

public int getFitness()
Return the fitness.

Specified by:
getFitness in interface IChromosome
Since:
v0.1

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class Object
Since:
v0.1

isFitnessUnknown

public boolean isFitnessUnknown()
Return true if the fitness is unknown.

Specified by:
isFitnessUnknown in interface IChromosome
Since:
v0.1

mix

public void mix(IChromosome c1,
                IChromosome c2,
                double fraction)
Mix the genes of the given chromosomes into this using the given fraction.

Specified by:
mix in interface IChromosome
Since:
v0.3

setDescription

public void setDescription(String description)
Set the description.

Specified by:
setDescription in interface IChromosome
Since:
v0.1

setFitness

public void setFitness(int fitness)
Set the fitness.

Specified by:
setFitness in interface IChromosome
Since:
v0.1

setFitnessUnknown

public void setFitnessUnknown()
Set the fitness to unknown.

Specified by:
setFitnessUnknown in interface IChromosome
Since:
v0.1

toString

public String toString()
Return a string representation of this object.

Overrides:
toString in class Object
Since:
v0.1


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02