(genome, **args)
return int(mutations)
Simple real range mutator for G1DList

   Accepts the *rangemin* and *rangemax* genome parameters, both optional.
Simple real range mutator for G1DList
Simple real range mutator for G1DList
def G1DListMutatorRealRange(genome, **args):
   """ Simple real range mutator for G1DList

   Accepts the *rangemin* and *rangemax* genome parameters, both optional.

   """
   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"]):
            genome[it] = rand_uniform(genome.getParam("rangemin", Consts.CDefRangeMin),
                                      genome.getParam("rangemax", Consts.CDefRangeMax))
            mutations += 1

   else:
      for it in xrange(int(round(mutations))):
         which_gene = rand_randint(0, listSize - 1)
         genome[which_gene] = rand_uniform(genome.getParam("rangemin", Consts.CDefRangeMin),
                                           genome.getParam("rangemax", Consts.CDefRangeMax))

   return int(mutations)
def G1DListMutatorRealRange ( 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" ] ) : genome [ it ] = rand_uniform ( genome . getParam ( "rangemin" , Consts . CDefRangeMin ) , genome . getParam ( "rangemax" , Consts . CDefRangeMax ) ) mutations += 1 else : for it in xrange ( int ( round ( mutations ) ) ) : which_gene = rand_randint ( 0 , listSize - 1 ) genome [ which_gene ] = rand_uniform ( genome . getParam ( "rangemin" , Consts . CDefRangeMin ) , genome . getParam ( "rangemax" , Consts . CDefRangeMax ) ) return int ( mutations )