(genome, **args)
return int(mutations)
A gaussian mutator for G1DList of Integers

   Accepts the *rangemin* and *rangemax* genome parameters, both optional. The
   random distribution is set with mu=1.0 and std=0.0333

   Same as IntegerGaussian, except that this uses relative gradient rather than
   absolute gaussian. A value is randomly generated about gauss(mu=1, sigma=.0333)
   and multiplied by the gene to drift it up or down (depending on what side of
   1 the random value falls on) and cast to integer
A gaussian mutator for G1DList of Integers
A gaussian mutator for G1DList of Integers
def G1DListMutatorIntegerGaussianGradient(genome, **args):
   """ A gaussian mutator for G1DList of Integers

   Accepts the *rangemin* and *rangemax* genome parameters, both optional. The
   random distribution is set with mu=1.0 and std=0.0333

   Same as IntegerGaussian, except that this uses relative gradient rather than
   absolute gaussian. A value is randomly generated about gauss(mu=1, sigma=.0333)
   and multiplied by the gene to drift it up or down (depending on what side of
   1 the random value falls on) and cast to integer

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

   mu = Consts.CDefGaussianGradientMU
   sigma = Consts.CDefGaussianGradientSIGMA

   if mutations < 1.0:
      mutations = 0
      for it in xrange(listSize):
         if Util.randomFlipCoin(args["pmut"]):
            final_value = int(genome[it] * abs(rand_gauss(mu, sigma)))

            final_value = min(final_value, genome.getParam("rangemax", Consts.CDefRangeMax))
            final_value = max(final_value, genome.getParam("rangemin", Consts.CDefRangeMin))

            genome[it] = final_value
            mutations += 1
   else:
      for it in xrange(int(round(mutations))):
         which_gene = rand_randint(0, listSize - 1)
         final_value = int(genome[which_gene] * abs(rand_gauss(mu, sigma)))

         final_value = min(final_value, genome.getParam("rangemax", Consts.CDefRangeMax))
         final_value = max(final_value, genome.getParam("rangemin", Consts.CDefRangeMin))

         genome[which_gene] = final_value

   return int(mutations)
def G1DListMutatorIntegerGaussianGradient ( genome , * * args ) : if args [ "pmut" ] <= 0.0 : return 0 listSize = len ( genome ) mutations = args [ "pmut" ] * ( listSize ) mu = Consts . CDefGaussianGradientMU sigma = Consts . CDefGaussianGradientSIGMA if mutations < 1.0 : mutations = 0 for it in xrange ( listSize ) : if Util . randomFlipCoin ( args [ "pmut" ] ) : final_value = int ( genome [ it ] * abs ( rand_gauss ( mu , sigma ) ) ) final_value = min ( final_value , genome . getParam ( "rangemax" , Consts . CDefRangeMax ) ) final_value = max ( final_value , genome . getParam ( "rangemin" , Consts . CDefRangeMin ) ) genome [ it ] = final_value mutations += 1 else : for it in xrange ( int ( round ( mutations ) ) ) : which_gene = rand_randint ( 0 , listSize - 1 ) final_value = int ( genome [ which_gene ] * abs ( rand_gauss ( mu , sigma ) ) ) final_value = min ( final_value , genome . getParam ( "rangemax" , Consts . CDefRangeMax ) ) final_value = max ( final_value , genome . getParam ( "rangemin" , Consts . CDefRangeMin ) ) genome [ which_gene ] = final_value return int ( mutations )