org.artoflife.gp
Class Chromosome

java.lang.Object
  |
  +--org.artoflife.gp.Chromosome
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
GpTreeChromosome

public abstract class Chromosome
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

An element of an Individual's genotype, has a unique id to ensure compatibility during crossover, and can be mutated. Should act upon a Phenotype during expression. Can be serialized (as part of an Individual) and cloned.

Author:
Steve Meyfroidt
See Also:
Serialized Form

Constructor Summary
Chromosome(java.lang.String id)
           
 
Method Summary
 java.lang.Object clone()
          Must be able to clone an Individual's genome during clone of an Individual.
 boolean compatibleWith(Chromosome chromosome)
           
abstract  void crossover(Chromosome chromosome2)
          Subclasses should ensure compatibility before doing the crossover, throwing an IncompatibleGenotypeException if not.
 java.lang.String getId()
           
abstract  int getSize()
          The size of this chromosome, used when selecting between two Individuals with the same Fitness, when the smallest is chosen.
abstract  void mutate(float probability)
          Mutate the genes within this Individual's Chromosomes with a given probability.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Chromosome

public Chromosome(java.lang.String id)
Parameters:
id - a unique id that identifies the type of this Chromosome. A Chromosome can only crossover with others of the same type (id). Suggested naming convention: "Individual_Type.Chromosome_Number", for example "Mondrian.1". May not be null.
Throws:
java.lang.IllegalArgumentException - if if is null
Method Detail

getId

public java.lang.String getId()

compatibleWith

public boolean compatibleWith(Chromosome chromosome)
Returns:
is this Chromosome of the same type as the passed one?

mutate

public abstract void mutate(float probability)
Mutate the genes within this Individual's Chromosomes with a given probability.

Parameters:
probability - between 0 (never) and 1.0 (always)

crossover

public abstract void crossover(Chromosome chromosome2)
                        throws IncompatibleChromosomeException
Subclasses should ensure compatibility before doing the crossover, throwing an IncompatibleGenotypeException if not.

Parameters:
chromosome2 - the Chromosome to crossover this one with
Throws:
IncompatibleGenotypeException - if the chromosomes are not compatible
IncompatibleChromosomeException

getSize

public abstract int getSize()
The size of this chromosome, used when selecting between two Individuals with the same Fitness, when the smallest is chosen.

Returns:
measure of size of this Chromosome

clone

public java.lang.Object clone()
Must be able to clone an Individual's genome during clone of an Individual.

Overrides:
clone in class java.lang.Object

artoflife pre0.1.0-dev

Copyright © 2002 the Art Of Life team. All Rights Reserved.