Logo Search packages:      
Sourcecode: python-biopython version File versions

def Bio::GA::Crossover::GeneralPoint::GeneralPointCrossover::do_crossover (   self,
  org_1,
  org_2 
) [inherited]

Potentially do a crossover between the two organisms.
	

Definition at line 59 of file GeneralPoint.py.

00059                                         :
        """Potentially do a crossover between the two organisms.
      """
        new_org = ( org_1.copy(), org_2.copy() )
        
        # determine if we have a crossover
        crossover_chance = self._crossover_rand.random()
        if crossover_chance <= self._crossover_prob:
          
          # pre-compute bounds (len(genome))
          bound  = (len(new_org[0].genome), len(new_org[1].genome))
          
          mbound = min(bound)
          # can't have more than 0,x_0...x_n,bound locations
          if (self._npoints == 0 or self._npoints > mbound-2):
            self._npoints = mbound-2
            
          y_locs = []
          # generate list for the shortest of the genomes
          x_locs = self._generate_locs( mbound )

          if (self._sym != 0):  
            y_locs = x_locs
          else:
            # figure out which list we've generated 
            # for, and generate the other
            if (mbound == bound[0]):
                y_locs = self._generate_locs( bound[1] )
            else:
                y_locs = x_locs
                xlocs  = self._generate_locs( bound[0] )
            
          # copy new genome strings over
          tmp = self._crossover(0, new_org, (x_locs,y_locs))
          new_org[1].genome = self._crossover(1, new_org, (x_locs,y_locs))
            new_org[0].genome = tmp

        return new_org

    def _generate_locs(self, bound):


Generated by  Doxygen 1.6.0   Back to index