def cxESTwoPoint(ind1, ind2):
 size = min(len(ind1), len(ind2))
 pt1 = random.randint(1, size)
 pt2 = random.randint(1, (size - 1))
 if (pt2 >= pt1):
  pt2 += 1
 else:
  (pt1, pt2) = (pt2, pt1)
 (ind1[pt1:pt2], ind2[pt1:pt2]) = (ind2[pt1:pt2], ind1[pt1:pt2])
 (ind1.strategy[pt1:pt2], ind2.strategy[pt1:pt2]) = (ind2.strategy[pt1:pt2], ind1.strategy[pt1:pt2])
 return (ind1, ind2)

def cxESTwoPoint ( ind1 , ind2 ) : size = min ( len ( ind1 ) , len ( ind2 ) ) pt1 = random . randint ( 1 , size ) pt2 = random . randint ( 1 , ( size - 1 ) ) if ( pt2 >= pt1 ) : pt2 += 1 else : ( pt1 , pt2 ) = ( pt2 , pt1 ) ( ind1 [ pt1 : pt2 ] , ind2 [ pt1 : pt2 ] ) = ( ind2 [ pt1 : pt2 ] , ind1 [ pt1 : pt2 ] ) ( ind1 . strategy [ pt1 : pt2 ] , ind2 . strategy [ pt1 : pt2 ] ) = ( ind2 . strategy [ pt1 : pt2 ] , ind1 . strategy [ pt1 : pt2 ] ) return ( ind1 , ind2 )
executes a classical two points crossover on both the individuals and their strategy .