Table of Contents

Class: Organism Bio/GA/Organism.py

Represent a single individual in a population.

Attributes:

  • genome -- The genome of the organism. This is a Bio.MutableSeq object that has the sequence of the genome, and the alphabet describing all elements that can be a part of the genome.

  • fitness -- The calculate fitness of the organism. This fitness is based on the last time it was calculated using the fitness_calculator. So... the fitness could potentially be out of date with the real genome if you are not careful to recalculate it after changes with recalculate_fitness()

Methods   
__cmp__
__init__
__str__
copy
recalculate_fitness
  __cmp__ 
__cmp__ ( self,  other )

Define comparisons for organisms.

Compare organisms by their genomes.

  __init__ 
__init__ (
        self,
        genome,
        fitness_calculator,
        start_fitness=None,
        )

Initialize an organism

Arguments:

  • genome -- A MutableSeq object representing the sequence of the genome.

  • fitness_calculator -- A funtion that will calculate the fitness of the organism when given the organisms genome.

  • start_fitness - the starting fitness corresponding with the given genome. If not supplied, the fitness will be calculated using fitness_calculator.

  __str__ 
__str__ ( self )

Provide a string output for debugging.

  copy 
copy ( self )

Return a copy of the organism.

This makes it easy to duplicate an organism before changing it.

  recalculate_fitness 
recalculate_fitness ( self )

Calculate and reset the fitness of the current genome

This should be called after the genome is updated to ensure that fitness always stays in sync with the current genome.


Table of Contents

This document was automatically generated on Mon Jul 1 12:03:10 2002 by HappyDoc version 2.0.1