def cxTwoPointCopy(ind1, ind2):
 size = len(ind1)
 cxpoint1 = random.randint(1, size)
 cxpoint2 = random.randint(1, (size - 1))
 if (cxpoint2 >= cxpoint1):
  cxpoint2 += 1
 else:
  (cxpoint1, cxpoint2) = (cxpoint2, cxpoint1)
 (ind1[cxpoint1:cxpoint2], ind2[cxpoint1:cxpoint2]) = (ind2[cxpoint1:cxpoint2].copy(), ind1[cxpoint1:cxpoint2].copy())
 return (ind1, ind2)

def cxTwoPointCopy ( ind1 , ind2 ) : size = len ( ind1 ) cxpoint1 = random . randint ( 1 , size ) cxpoint2 = random . randint ( 1 , ( size - 1 ) ) if ( cxpoint2 >= cxpoint1 ) : cxpoint2 += 1 else : ( cxpoint1 , cxpoint2 ) = ( cxpoint2 , cxpoint1 ) ( ind1 [ cxpoint1 : cxpoint2 ] , ind2 [ cxpoint1 : cxpoint2 ] ) = ( ind2 [ cxpoint1 : cxpoint2 ] . copy ( ) , ind1 [ cxpoint1 : cxpoint2 ] . copy ( ) ) return ( ind1 , ind2 )
execute a two points crossover with copy on the input individuals .