def mutUniformInt(individual, low, up, indpb):
 size = len(individual)
 if (not isinstance(low, Sequence)):
  low = repeat(low, size)
 elif (len(low) < size):
  raise IndexError(('low must be at least the size of individual: %d < %d' % (len(low), size)))
 if (not isinstance(up, Sequence)):
  up = repeat(up, size)
 elif (len(up) < size):
  raise IndexError(('up must be at least the size of individual: %d < %d' % (len(up), size)))
 for (i, xl, xu) in zip(xrange(size), low, up):
  if (random.random() < indpb):
   individual[i] = random.randint(xl, xu)
 return (individual,)

def mutUniformInt ( individual , low , up , indpb ) : size = len ( individual ) if ( not isinstance ( low , Sequence ) ) : low = repeat ( low , size ) elif ( len ( low ) < size ) : raise IndexError ( ( 'low must be at least the size of individual: %d < %d' % ( len ( low ) , size ) ) ) if ( not isinstance ( up , Sequence ) ) : up = repeat ( up , size ) elif ( len ( up ) < size ) : raise IndexError ( ( 'up must be at least the size of individual: %d < %d' % ( len ( up ) , size ) ) ) for ( i , xl , xu ) in zip ( xrange ( size ) , low , up ) : if ( random . random ( ) < indpb ) : individual [ i ] = random . randint ( xl , xu ) return ( individual , )
mutate an individual by replacing attributes .