(genome, **args)
return (sister, brother)
The OX Crossover for G1DList  (order crossover)
The OX Crossover for G1DList  (order crossover)
The OX Crossover for G1DList ( order crossover )
def G1DListCrossoverOX(genome, **args):
   """ The OX Crossover for G1DList  (order crossover) """
   sister = None
   brother = None
   gMom = args["mom"]
   gDad = args["dad"]
   listSize = len(gMom)

   c1, c2 = [rand_randint(1, len(gMom) - 1), rand_randint(1, len(gMom) - 1)]

   while c1 == c2:
      c2 = rand_randint(1, len(gMom) - 1)

   if c1 > c2:
      h = c1
      c1 = c2
      c2 = h

   if args["count"] >= 1:
      sister = gMom.clone()
      sister.resetStats()
      P1 = [c for c in gMom[c2:] + gMom[:c2] if c not in gDad[c1:c2]]
      sister.genomeList = P1[listSize - c2:] + gDad[c1:c2] + P1[:listSize - c2]

   if args["count"] == 2:
      brother = gDad.clone()
      brother.resetStats()
      P2 = [c for c in gDad[c2:] + gDad[:c2] if c not in gMom[c1:c2]]
      brother.genomeList = P2[listSize - c2:] + gMom[c1:c2] + P2[:listSize - c2]

   assert listSize == len(sister)
   assert listSize == len(brother)

   return (sister, brother)
def G1DListCrossoverOX ( genome , * * args ) : sister = None brother = None gMom = args [ "mom" ] gDad = args [ "dad" ] listSize = len ( gMom ) c1 , c2 = [ rand_randint ( 1 , len ( gMom ) - 1 ) , rand_randint ( 1 , len ( gMom ) - 1 ) ] while c1 == c2 : c2 = rand_randint ( 1 , len ( gMom ) - 1 ) if c1 > c2 : h = c1 c1 = c2 c2 = h if args [ "count" ] >= 1 : sister = gMom . clone ( ) sister . resetStats ( ) P1 = [ c for c in gMom [ c2 : ] + gMom [ : c2 ] if c not in gDad [ c1 : c2 ] ] sister . genomeList = P1 [ listSize - c2 : ] + gDad [ c1 : c2 ] + P1 [ : listSize - c2 ] if args [ "count" ] == 2 : brother = gDad . clone ( ) brother . resetStats ( ) P2 = [ c for c in gDad [ c2 : ] + gDad [ : c2 ] if c not in gMom [ c1 : c2 ] ] brother . genomeList = P2 [ listSize - c2 : ] + gMom [ c1 : c2 ] + P2 [ : listSize - c2 ] assert listSize == len ( sister ) assert listSize == len ( brother ) return ( sister , brother )