def varOr(population, toolbox, lambda_, cxpb, mutpb):
 assert ((cxpb + mutpb) <= 1.0), 'The sum of the crossover and mutation probabilities must be smaller or equal to 1.0.'
 offspring = []
 for _ in xrange(lambda_):
  op_choice = random.random()
  if (op_choice < cxpb):
   (ind1, ind2) = map(toolbox.clone, random.sample(population, 2))
   (ind1, ind2) = toolbox.mate(ind1, ind2)
   del ind1.fitness.values
   offspring.append(ind1)
  elif (op_choice < (cxpb + mutpb)):
   ind = toolbox.clone(random.choice(population))
   (ind,) = toolbox.mutate(ind)
   del ind.fitness.values
   offspring.append(ind)
  else:
   offspring.append(random.choice(population))
 return offspring

def varOr ( population , toolbox , lambda_ , cxpb , mutpb ) : assert ( ( cxpb + mutpb ) <= 1.0 ) , 'The sum of the crossover and mutation probabilities must be smaller or equal to 1.0.' offspring = [ ] for _ in xrange ( lambda_ ) : op_choice = random . random ( ) if ( op_choice < cxpb ) : ( ind1 , ind2 ) = map ( toolbox . clone , random . sample ( population , 2 ) ) ( ind1 , ind2 ) = toolbox . mate ( ind1 , ind2 ) del ind1 . fitness . values offspring . append ( ind1 ) elif ( op_choice < ( cxpb + mutpb ) ) : ind = toolbox . clone ( random . choice ( population ) ) ( ind , ) = toolbox . mutate ( ind ) del ind . fitness . values offspring . append ( ind ) else : offspring . append ( random . choice ( population ) ) return offspring
part of an evolutionary algorithm applying only the variation part .