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

Class Organism

source code

object --+
         |
        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()

Instance Methods [hide private]
 
__init__(self, genome, fitness_calculator, start_fitness=None)
Initialize an organism
source code
 
__str__(self)
Provide a string output for debugging.
source code
 
__eq__(self, other)
Compare organisms by their genomes (as strings of letters).
source code
 
__ne__(self, other)
Compare organisms by their genomes (as strings of letters).
source code
 
__lt__(self, other)
Compare organisms by their genomes (as strings of letters).
source code
 
__le__(self, other)
Compare organisms by their genomes (as strings of letters).
source code
 
__gt__(self, other)
Compare organisms by their genomes (as strings of letters).
source code
 
__ge__(self, other)
Compare organisms by their genomes (as strings of letters).
source code
 
copy(self)
Return a copy of the organism.
source code
 
recalculate_fitness(self)
Calculate and reset the fitness of the current genome
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

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

source code 
Initialize an organism

Arguments:

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

o fitness_calculator -- A function 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.

Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 
Provide a string output for debugging.
        

Overrides: object.__str__

copy(self)

source code 
Return a copy of the organism.

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

recalculate_fitness(self)

source code 
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.