Back to index

python-biopython  1.60
Public Member Functions | Private Attributes
Bio.GA.Evolver.GenerationEvolver Class Reference

List of all members.

Public Member Functions

def __init__
def evolve

Private Attributes

 _population
 _selector

Detailed Description

Evolve a population from generation to generation.

This implements a Generational GA, in which the population moves from
generation to generation.

Definition at line 18 of file Evolver.py.


Constructor & Destructor Documentation

def Bio.GA.Evolver.GenerationEvolver.__init__ (   self,
  starting_population,
  selector 
)
Initialize the evolver.

Arguments:

o starting_population -- An initial set of individuals to begin
the evolution process from. This should be a list of Organism
objects.

o selector -- A Selection object that implements selection, along
with mutation and crossover to select a new population from a
given population.

Definition at line 24 of file Evolver.py.

00024 
00025     def __init__(self, starting_population, selector):
00026         """Initialize the evolver.
00027 
00028         Arguments:
00029 
00030         o starting_population -- An initial set of individuals to begin
00031         the evolution process from. This should be a list of Organism
00032         objects.
00033 
00034         o selector -- A Selection object that implements selection, along
00035         with mutation and crossover to select a new population from a
00036         given population.
00037         """
00038         self._population = starting_population
00039         self._selector = selector

Here is the caller graph for this function:


Member Function Documentation

def Bio.GA.Evolver.GenerationEvolver.evolve (   self,
  stopping_criteria 
)
Evolve the population through multiple generations.

Arguments:

o stoppping_criteria -- A function which, when passed the current
individuals in the population, will determine when to stop
the evolution process.

Returns:

o The final evolved population.

Definition at line 40 of file Evolver.py.

00040 
00041     def evolve(self, stopping_criteria):
00042         """Evolve the population through multiple generations.
00043 
00044         Arguments:
00045 
00046         o stoppping_criteria -- A function which, when passed the current
00047         individuals in the population, will determine when to stop
00048         the evolution process.
00049 
00050         Returns:
00051 
00052         o The final evolved population.
00053         """
00054         while not(stopping_criteria(self._population)):
00055             try:
00056                 # perform selection, mutation, crossover on the population
00057                 self._population = self._selector.select(self._population)
00058 
00059                 # update the fitness of the new popultation
00060                 for organism in self._population:
00061                     organism.recalculate_fitness()
00062 
00063             # dump out all of the organisms for debugging if the
00064             # evolution process is broken with a Control-C
00065             except KeyboardInterrupt:
00066                 # sort the population so we can look at duplicates
00067                 self._population.sort()
00068                 for org in self._population:
00069                     print org
00070                 sys.exit()
00071             
00072         return self._population

Here is the call graph for this function:


Member Data Documentation

Definition at line 37 of file Evolver.py.

Definition at line 38 of file Evolver.py.


The documentation for this class was generated from the following file: