combinations = itertools.product(\ matched['ratios'].items(),\ pulses, \ range(settings.get('nTrials')) ) simulationRoot = rootDirectory print(f"Making {simulationRoot}") os.makedirs(simulationRoot, exist_ok=1) settings['equilibrium'] = matched # make settings print(settings['graph']) IO.savePickle(os.path.join(simulationRoot, 'settings'),\ settings) # load settings file elif os.path.isdir(file): print('reading settings') # load old settings # if root in settings # read settings oldSettings = None for (root, dir, files) in os.walk(file): for f in files: fn = os.path.join(root, f) if f.endswith('settings.pickle'): oldSettings = fn break if not oldSettings:
settings = dict( repeats = repeats,\ deltas = deltas,\ nSamples = nSamples,\ step = step,\ burninSamples = burninSamples,\ pulseSizes = pulseSizes,\ updateType = updateType,\ nNodes = graph.number_of_nodes(),\ nTrials = nTrials,\ # this is added graph = graph,\ mapping = model.mapping,\ rmapping = model.rmapping,\ directory = targetDirectory,\ nudgeType = nudgeType,\ CHECK = CHECK,\ tempres = tempres, \ magSide = magSide,\ targetDirectory = targetDirectory,\ start = start, \ now = now,\ ) runFile = genDataFile(idx) IO.savePickle(runFile, settings) cmd = f"sbatch control_slurm.sh {runFile}".split() subprocess.call(cmd)
corrTimeSettings = IO.loadResults(targetDirectory, 'corrTimeSettings') burninSteps = mixingResults['burninSteps'] distSamples = mixingResults['distSamples'] # try to load neighbourhood shell data. If it doesn't exist yet, generate it try: if len(args.neighboursDir) > 0: neighboursG = IO.loadPickle(args.neighboursDir, 'neighboursG') else: neighboursG = IO.loadPickle(targetDirectory, 'neighboursG') except: print(f'determining neighbours') neighboursG = model.neighboursAtDistAllNodes(nodes, maxDist) if len(args.neighboursDir) > 0: os.makedirs(args.neighboursDir, exist_ok=True) IO.savePickle(args.neighboursDir, 'neighboursG', neighboursG) else: IO.savePickle(targetDirectory, 'neighboursG', neighboursG) snapshotSettings = dict( \ nSamples = args.numSamples, \ burninSteps = burninSteps, \ distSamples = distSamples, \ maxDist = maxDist, \ nBins = args.bins ) # repetitive runs of the MI estimation procedure for r in range(args.runs):
# m.equilibriate(magRatios, eqSettings) combinations = itertools.product(\ m.matched['ratios'].items(),\ pulseSizes, \ range(settings.get('nTrials')) ) settings['graph'] = g # setup filepaths now = datetime.datetime.now().isoformat() simulationRoot = os.path.join(\ rootDirectory, now) print(f"Making {simulationRoot}") os.makedirs(simulationRoot, exist_ok=1) settings['equilibrium'] = m.matched IO.savePickle(os.path.join(simulationRoot, 'settings'),\ settings) for (ratio, pulse, trial) in combinations: # tmp added properties settings['trial'] = trial settings['ratio'] = ratio if pulse: for node in m.graph.nodes(): tmp = copy.deepcopy(m) tmp.t = ratio[1] intervention = {node: pulse} tmp.nudges = intervention settings['pulse'] = intervention