Advertisement
Guest User

rapid clusters main

a guest
Dec 30th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.63 KB | None | 0 0
  1.     maxGENS=200
  2.     allfits = []
  3.     allrates = []
  4.     parent = ANN()
  5.     parentfit = -9999.0  # We don't know this yet.
  6.    
  7.     for generation in range(maxGENS) :
  8.         children = []
  9.         mrate = 0.05
  10.         for repc in range(12) :
  11.             gchild  = ANNDuplicate(parent)
  12.             if( (generation==0) and (repc==0) ) :
  13.                 gchild = gchild  # Smuggle the parent.  
  14.             else :
  15.                 gchild.Mutate(mrate)
  16.             children.append(gchild)
  17.             mrate = mrate + 0.01   # use a spectrum of rates.    
  18.            
  19.         time_start = time.time()    
  20.         fitpool = FitnessGlobal_Get( children )    # pass the whole list for testing.
  21.         time_end   = time.time()
  22.         elapsed    = time_end - time_start
  23.         if( elapsed > 0.01 ) :
  24.             ratepermin = 60.0 / elapsed
  25.         else :
  26.             ratepermin = 5455.0
  27.         allrates.append(12.0 * ratepermin)
  28.        
  29.         if( generation == 0 ) :
  30.             parentfit = fitpool[0]  
  31.        
  32.         allfits.append(parentfit)
  33.        
  34.         # Consider the child with the highest fitness amongst the children.
  35.         childfit = max( fitpool )  
  36.         hi = fitpool.index( childfit )
  37.         child = children[hi]
  38.        
  39.         # print fitpool # debug
  40.        
  41.         verbosim = "gen={} , {} , {} , {}".format(generation , childfit , parentfit, elapsed)
  42.         print(verbosim)
  43.         if(childfit>parentfit) :
  44.             parentfit=childfit
  45.             parent = ANNDuplicate(child)
  46.             bestWFN = "bestweights_{}.dat".format(generation)
  47.             parent.Send_Synapse_Weights_ToFile(bestWFN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement