Package Bio :: Package GA :: Package Crossover :: Module TwoPoint
[hide private]
[frames] | no frames]

Source Code for Module Bio.GA.Crossover.TwoPoint

 1  """Perform two-point crossovers between the genomes of two organisms. 
 2   
 3  This module performs two-point crossover between two genomes. 
 4  There are two flavors: OnePointCrossover (Point) and TwoPointCrossover. 
 5   
 6  TwoPointCrossover is the minimal crossover technique that 
 7  facilitates diverse genome length.  Do not use this if you need to 
 8  maintain consistent genome length. 
 9   
10  TwoPointCrossover: 
11  genome 1 --       A B*C D E F 
12  genome 2 --       a b c*d e f 
13   
14  new genome 1 --   A B d e f 
15  new genome 2 --   a b c C D E F 
16   
17  """ 
18  # standard modules 
19  from GeneralPoint import TwoCrossover 
20   
21 -class TwoPointCrossover(TwoCrossover):
22 """Perform two point crossover between genomes at some defined rate. 23 24 This performs a crossover between two genomes at some defined frequency. 25 The location of the points of crossover are chosen randomly if the 26 crossover meets the probability to occur. 27 """
28 - def __init__(self, crossover_prob = .1):
29 """Initialize to do crossovers at the specified probability. 30 """ 31 TwoCrossover.__init__(self, 2, crossover_prob)
32