(genome, **args)
return int(mutations)
A gaussian gradient mutator for G2DList of Real

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

   The difference is that this multiplies the gene by gauss(1.0, 0.0333), allowing
   for a smooth gradient drift about the value.
A gaussian gradient mutator for G2DList of Real
A gaussian gradient mutator for G2DList of Real
def G2DListMutatorRealGaussianGradient(genome, **args):
   """ A gaussian gradient mutator for G2DList of Real

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

   The difference is that this multiplies the gene by gauss(1.0, 0.0333), allowing
   for a smooth gradient drift about the value.

   """
   if args["pmut"] <= 0.0:
      return 0
   height, width = genome.getSize()
   elements = height * width

   mutations = args["pmut"] * elements

   mu = Consts.CDefGaussianGradientMU
   sigma = Consts.CDefGaussianGradientSIGMA

   if mutations < 1.0:
      mutations = 0

      for i in xrange(genome.getHeight()):
         for j in xrange(genome.getWidth()):
            if Util.randomFlipCoin(args["pmut"]):
               final_value = genome[i][j] * 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.setItem(i, j, final_value)
               mutations += 1
   else:

      for it in xrange(int(round(mutations))):
         which_x = rand_randint(0, genome.getWidth() - 1)
         which_y = rand_randint(0, genome.getHeight() - 1)

         final_value = genome[which_y][which_x] * 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.setItem(which_y, which_x, final_value)

   return int(mutations)
def G2DListMutatorRealGaussianGradient ( genome , * * args ) : if args [ "pmut" ] <= 0.0 : return 0 height , width = genome . getSize ( ) elements = height * width mutations = args [ "pmut" ] * elements mu = Consts . CDefGaussianGradientMU sigma = Consts . CDefGaussianGradientSIGMA if mutations < 1.0 : mutations = 0 for i in xrange ( genome . getHeight ( ) ) : for j in xrange ( genome . getWidth ( ) ) : if Util . randomFlipCoin ( args [ "pmut" ] ) : final_value = genome [ i ] [ j ] * 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 . setItem ( i , j , final_value ) mutations += 1 else : for it in xrange ( int ( round ( mutations ) ) ) : which_x = rand_randint ( 0 , genome . getWidth ( ) - 1 ) which_y = rand_randint ( 0 , genome . getHeight ( ) - 1 ) final_value = genome [ which_y ] [ which_x ] * 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 . setItem ( which_y , which_x , final_value ) return int ( mutations )