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

   Accepts the *rangemin* and *rangemax* genome parameters, both optional. Also
   accepts the parameter *gauss_mu* and the *gauss_sigma* which respectively
   represents the mean and the std. dev. of the random distribution.
The mutator of G1DList, Gaussian Mutator
The mutator of G1DList Gaussian Mutator
def G1DListMutatorRealGaussian(genome, **args):
   """ The mutator of G1DList, Gaussian Mutator

   Accepts the *rangemin* and *rangemax* genome parameters, both optional. Also
   accepts the parameter *gauss_mu* and the *gauss_sigma* which respectively
   represents the mean and the std. dev. of the random distribution.

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

   mu = genome.getParam("gauss_mu")
   sigma = genome.getParam("gauss_sigma")

   if mu is None:
      mu = Consts.CDefG1DListMutRealMU

   if sigma is None:
      sigma = Consts.CDefG1DListMutRealSIGMA

   if mutations < 1.0:
      mutations = 0
      for it in xrange(listSize):
         if Util.randomFlipCoin(args["pmut"]):
            final_value = genome[it] + 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 = genome[which_gene] + 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 G1DListMutatorRealGaussian ( genome , * * args ) : if args [ "pmut" ] <= 0.0 : return 0 listSize = len ( genome ) mutations = args [ "pmut" ] * ( listSize ) mu = genome . getParam ( "gauss_mu" ) sigma = genome . getParam ( "gauss_sigma" ) if mu is None : mu = Consts . CDefG1DListMutRealMU if sigma is None : sigma = Consts . CDefG1DListMutRealSIGMA if mutations < 1.0 : mutations = 0 for it in xrange ( listSize ) : if Util . randomFlipCoin ( args [ "pmut" ] ) : final_value = genome [ it ] + 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 = genome [ which_gene ] + 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 )