def cxSimulatedBinary(ind1, ind2, eta):
 for (i, (x1, x2)) in enumerate(zip(ind1, ind2)):
  rand = random.random()
  if (rand <= 0.5):
   beta = (2.0 * rand)
  else:
   beta = (1.0 / (2.0 * (1.0 - rand)))
  beta **= (1.0 / (eta + 1.0))
  ind1[i] = (0.5 * (((1 + beta) * x1) + ((1 - beta) * x2)))
  ind2[i] = (0.5 * (((1 - beta) * x1) + ((1 + beta) * x2)))
 return (ind1, ind2)

def cxSimulatedBinary ( ind1 , ind2 , eta ) : for ( i , ( x1 , x2 ) ) in enumerate ( zip ( ind1 , ind2 ) ) : rand = random . random ( ) if ( rand <= 0.5 ) : beta = ( 2.0 * rand ) else : beta = ( 1.0 / ( 2.0 * ( 1.0 - rand ) ) ) beta **= ( 1.0 / ( eta + 1.0 ) ) ind1 [ i ] = ( 0.5 * ( ( ( 1 + beta ) * x1 ) + ( ( 1 - beta ) * x2 ) ) ) ind2 [ i ] = ( 0.5 * ( ( ( 1 - beta ) * x1 ) + ( ( 1 + beta ) * x2 ) ) ) return ( ind1 , ind2 )
executes a simulated binary crossover that modify in-place the input individuals .