(genome, **args)
return int(mutations)
The mutator of G1DList, Allele Mutator

   To use this mutator, you must specify the *allele* genome parameter with the
   :class:`GAllele.GAlleles` instance.
The mutator of G1DList, Allele Mutator
The mutator of G1DList Allele Mutator
def G1DListMutatorAllele(genome, **args):
   """ The mutator of G1DList, Allele Mutator

   To use this mutator, you must specify the *allele* genome parameter with the
   :class:`GAllele.GAlleles` instance.

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

   allele = genome.getParam("allele", None)
   if allele is None:
      Util.raiseException("to use the G1DListMutatorAllele, you must specify the 'allele' parameter", TypeError)

   if mutations < 1.0:
      mutations = 0
      for it in xrange(listSize):
         if Util.randomFlipCoin(args["pmut"]):
            new_val = allele[it].getRandomAllele()
            genome[it] = new_val
            mutations += 1
   else:
      for it in xrange(int(round(mutations))):
         which_gene = rand_randint(0, listSize - 1)
         new_val = allele[which_gene].getRandomAllele()
         genome[which_gene] = new_val

   return int(mutations)
def G1DListMutatorAllele ( genome , * * args ) : if args [ "pmut" ] <= 0.0 : return 0 listSize = len ( genome ) mutations = args [ "pmut" ] * listSize allele = genome . getParam ( "allele" , None ) if allele is None : Util . raiseException ( "to use the G1DListMutatorAllele, you must specify the 'allele' parameter" , TypeError ) if mutations < 1.0 : mutations = 0 for it in xrange ( listSize ) : if Util . randomFlipCoin ( args [ "pmut" ] ) : new_val = allele [ it ] . getRandomAllele ( ) genome [ it ] = new_val mutations += 1 else : for it in xrange ( int ( round ( mutations ) ) ) : which_gene = rand_randint ( 0 , listSize - 1 ) new_val = allele [ which_gene ] . getRandomAllele ( ) genome [ which_gene ] = new_val return int ( mutations )