Package Bio :: Package GA :: Package Crossover :: Module GeneralPoint :: Class GeneralPointCrossover
[hide private]
[frames] | no frames]

Class GeneralPointCrossover

source code

object --+
         |
        GeneralPointCrossover
Known Subclasses:

Perform n-point crossover between genomes at some defined rates.

Ideas on how to use this class:
    - Call it directly ( construct, do_crossover )
    - Use one of the provided subclasses
    - Inherit from it:
        * replace _generate_locs with a more domain
          specific technique
        * replace _crossover with a more efficient
          technique for your point-count

Instance Methods [hide private]
 
__init__(self, points, crossover_prob=0.1)
Initialize to do crossovers at the specified probability.
source code
 
do_crossover(self, org_1, org_2)
Potentially do a crossover between the two organisms.
source code
 
_generate_locs(self, bound)
Generalized Location Generator:
source code
 
_crossover(self, x, no, locs)
Generalized Crossover Function:
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, points, crossover_prob=0.1)
(Constructor)

source code 
Initialize to do crossovers at the specified probability.
        

Overrides: object.__init__

_generate_locs(self, bound)

source code 
Generalized Location Generator:

arguments:
    bound (int)   - upper bound

returns: [0]+x_0...x_n+[bound]
  where n=self._npoints-1
    and 0 < x_0 < x_1 ... < bound

_crossover(self, x, no, locs)

source code 
Generalized Crossover Function:

arguments:
    x (int)        - genome number [0|1]
    no (organism,organism)
                   - new organisms
    locs (int list, int list)
                   - lists of locations,
                     [0, +n points+, bound]
                     for each genome (sync'd with x)

 return type: sequence (to replace no[x])