Back to index

python-biopython  1.60
Public Member Functions | Private Attributes
Bio.GA.Selection.Abstract.AbstractSelection Class Reference

List of all members.

Public Member Functions

def __init__
def mutate_and_crossover
def select

Private Attributes

 _mutator
 _crossover
 _repairer

Detailed Description

Base class for Selector classes.

This classes provides useful functions for different selector classes
and also defines the functions that all selector classes must
implement.

This class should not be used directly, but rather should be subclassed.

Definition at line 4 of file Abstract.py.


Constructor & Destructor Documentation

def Bio.GA.Selection.Abstract.AbstractSelection.__init__ (   self,
  mutator,
  crossover,
  repairer = None 
)
Initialize a selector.

Arguments:

o mutator -- A Mutation object which will perform mutation
on an individual.

o crossover -- A Crossover object which will take two
individuals and produce two new individuals which may
have had crossover occur.

o repairer -- A class which can do repair on rearranged genomes
to eliminate infeasible individuals. If set at None, so repair
will be done.

Definition at line 13 of file Abstract.py.

00013 
00014     def __init__(self, mutator, crossover, repairer = None):
00015         """Initialize a selector.
00016 
00017         Arguments:
00018 
00019         o mutator -- A Mutation object which will perform mutation
00020         on an individual.
00021 
00022         o crossover -- A Crossover object which will take two
00023         individuals and produce two new individuals which may
00024         have had crossover occur.
00025 
00026         o repairer -- A class which can do repair on rearranged genomes
00027         to eliminate infeasible individuals. If set at None, so repair
00028         will be done.
00029         """
00030         self._mutator = mutator
00031         self._crossover = crossover
00032         self._repairer = repairer

Here is the caller graph for this function:


Member Function Documentation

Perform mutation and crossover on the two organisms.

This uses the classes mutator and crossover functions to
perform the manipulations.

If a repair class is available, then the rearranged genomes will
be repaired to make them feasible.

The newly created individuals are returned.

Definition at line 33 of file Abstract.py.

00033 
00034     def mutate_and_crossover(self, org_1, org_2):
00035         """Perform mutation and crossover on the two organisms.
00036 
00037         This uses the classes mutator and crossover functions to
00038         perform the manipulations.
00039 
00040         If a repair class is available, then the rearranged genomes will
00041         be repaired to make them feasible.
00042         
00043         The newly created individuals are returned.
00044         """
00045         # first crossover the two organisms
00046         cross_org_1, cross_org_2 = self._crossover.do_crossover(org_1, org_2)
00047 
00048         # now perform mutation on the two organisms
00049         final_org_1 = self._mutator.mutate(cross_org_1)
00050         final_org_2 = self._mutator.mutate(cross_org_2)
00051 
00052         # if we have a repair class, perform repair
00053         if self._repairer is not None:
00054             final_org_1 = self._repairer.repair(final_org_1)
00055             final_org_2 = self._repairer.repair(final_org_2)
00056 
00057         return final_org_1, final_org_2

Here is the caller graph for this function:

def Bio.GA.Selection.Abstract.AbstractSelection.select (   self,
  population 
)

Definition at line 58 of file Abstract.py.

00058 
00059     def select(self, population):
00060         raise NotImplementedError("Derived classes must implement.")

Here is the caller graph for this function:


Member Data Documentation

Definition at line 30 of file Abstract.py.

Definition at line 29 of file Abstract.py.

Definition at line 31 of file Abstract.py.


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