(genome, **args)
return int(mutations)
The mutator of G1DList, the binary mutator

   This mutator will random change the 0 and 1 elements of the 1D List.
The mutator of G1DList, the binary mutator
The mutator of G1DList the binary mutator
def G1DListMutatorIntegerBinary(genome, **args):
   """ The mutator of G1DList, the binary mutator

   This mutator will random change the 0 and 1 elements of the 1D List.

   """
   if args["pmut"] <= 0.0:
      return 0
   listSize = len(genome)
   mutations = args["pmut"] * (listSize)

   if mutations < 1.0:
      mutations = 0
      for it in xrange(listSize):
         if Util.randomFlipCoin(args["pmut"]):
            if genome[it] == 0:
               genome[it] = 1
            elif genome[it] == 1:
               genome[it] = 0

            mutations += 1
   else:
      for it in xrange(int(round(mutations))):
         which_gene = rand_randint(0, listSize - 1)
         if genome[which_gene] == 0:
            genome[which_gene] = 1
         elif genome[which_gene] == 1:
            genome[which_gene] = 0

   return int(mutations)
def G1DListMutatorIntegerBinary ( genome , * * args ) : if args [ "pmut" ] <= 0.0 : return 0 listSize = len ( genome ) mutations = args [ "pmut" ] * ( listSize ) if mutations < 1.0 : mutations = 0 for it in xrange ( listSize ) : if Util . randomFlipCoin ( args [ "pmut" ] ) : if genome [ it ] == 0 : genome [ it ] = 1 elif genome [ it ] == 1 : genome [ it ] = 0 mutations += 1 else : for it in xrange ( int ( round ( mutations ) ) ) : which_gene = rand_randint ( 0 , listSize - 1 ) if genome [ which_gene ] == 0 : genome [ which_gene ] = 1 elif genome [ which_gene ] == 1 : genome [ which_gene ] = 0 return int ( mutations )