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

   .. note:: this mutator is :term:`Data Type Independent`
The mutator of G1DList, Swap Mutator
The mutator of G1DList Swap Mutator
def G1DListMutatorSwap(genome, **args):
   """ The mutator of G1DList, Swap Mutator

   .. note:: this mutator is :term:`Data Type Independent`

   """
   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"]):
            Util.listSwapElement(genome, it, rand_randint(0, listSize - 1))
            mutations += 1
   else:
      for it in xrange(int(round(mutations))):
         Util.listSwapElement(genome, rand_randint(0, listSize - 1), rand_randint(0, listSize - 1))

   return int(mutations)
def G1DListMutatorSwap ( 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" ] ) : Util . listSwapElement ( genome , it , rand_randint ( 0 , listSize - 1 ) ) mutations += 1 else : for it in xrange ( int ( round ( mutations ) ) ) : Util . listSwapElement ( genome , rand_randint ( 0 , listSize - 1 ) , rand_randint ( 0 , listSize - 1 ) ) return int ( mutations )