Package Bio :: Package GA :: Module Organism :: Class Organism
[show private | hide private]
[frames | no frames]

Class Organism


Represent a single individual in a population.

Attributes:

o 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.

o 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()
Method Summary
  __init__(self, genome, fitness_calculator, start_fitness)
Initialize an organism
  __cmp__(self, other)
Define comparisons for organisms.
  __str__(self)
Provide a string output for debugging.
  copy(self)
Return a copy of the organism.
  recalculate_fitness(self)
Calculate and reset the fitness of the current genome

Method Details

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

Initialize an organism

Arguments:

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

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

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

__cmp__(self, other)
(Comparison operator)

Define comparisons for organisms.

Compare organisms by their genomes.

__str__(self)
(Informal representation operator)

Provide a string output for debugging.

copy(self)

Return a copy of the organism.

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

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.

Generated by Epydoc 2.1 on Wed Jan 31 09:59:42 2007 http://epydoc.sf.net