def run_experiment(pm, trials): ''' The shell function to cycle through repeated trials.''' pm.validate() s = time.time() # Data structure that will contain the data and will be pickled # to a file. maps = {'Sparsity':[], 'Coverage':[], 'Representation':[]} units = {'Number of fields':[], 'Coverage':[]} fields = {'Area':[]} for rnd in range(trials): logging.info('Trial number %i:',rnd+1) maps, units, fields = run_simulation(pm) # Store data in file tot = {'maps':maps, 'units':units, 'fields':fields} fn = 'exp results size%s,modes%s,plccells%d,grdcells%d,runs%d'%(pm.L, str(pm.modules), pm.plc_cells, pm.grd_cells, rnd+10) cPickle.dump(tot,open(fn,'w')) logging.info('Total experiment time so far: %.3f', time.time()-s)
def fitness(a): ''' Fitness function for optimization a = (thresh,f_I) ''' [f_I, thresh] = a try: assert _validate_params(thresh,f_I) except: return 10**8 pm.f_I = f_I pm.thresh=thresh maps, _, _ = run_simulation(pm) assert len(maps['Sparsity']) == 1 sparsity = maps['Sparsity'][0] assert len(maps['Coverage']) == 1 coverage = maps['Coverage'][0] return sparsity, coverage