def varAnd(population, toolbox, cxpb, mutpb):
 offspring = [toolbox.clone(ind) for ind in population]
 for i in range(1, len(offspring), 2):
  if (random.random() < cxpb):
   (offspring[(i - 1)], offspring[i]) = toolbox.mate(offspring[(i - 1)], offspring[i])
   del offspring[(i - 1)].fitness.values, offspring[i].fitness.values
 for i in range(len(offspring)):
  if (random.random() < mutpb):
   (offspring[i],) = toolbox.mutate(offspring[i])
   del offspring[i].fitness.values
 return offspring

def varAnd ( population , toolbox , cxpb , mutpb ) : offspring = [ toolbox . clone ( ind ) for ind in population ] for i in range ( 1 , len ( offspring ) , 2 ) : if ( random . random ( ) < cxpb ) : ( offspring [ ( i - 1 ) ] , offspring [ i ] ) = toolbox . mate ( offspring [ ( i - 1 ) ] , offspring [ i ] ) del offspring [ ( i - 1 ) ] . fitness . values , offspring [ i ] . fitness . values for i in range ( len ( offspring ) ) : if ( random . random ( ) < mutpb ) : ( offspring [ i ] , ) = toolbox . mutate ( offspring [ i ] ) del offspring [ i ] . fitness . values return offspring
part of an evolutionary algorithm applying only the variation part .