Commit e94ffec8 authored by caminha's avatar caminha
Browse files

same seeds option for run_multiple.py

parent cd5965d7
......@@ -39,6 +39,9 @@ parser.add_argument('--loglevel', type=str, choices=['DEBUG', 'INFO', 'WARNING']
parser.add_argument('--slurm', action='store_true',
help='Should print commands to run on slurm')
parser.add_argument('--same-seeds', dest='same_seeds', action='store_true',
help='Tells the runs to use the same seeds for all combinations of parameters instead of unique ones for each simulation')
parser.add_argument('sim_params', metavar='Others', type=str, nargs=argparse.REMAINDER,
help='Arguments to be put in every run of the simulation')
......@@ -70,16 +73,19 @@ progressCounter = Value('d', 0.0)
if params.singlecpu:
runners = Pool(1, initializer=nas_utils.runSimulationWorkerInitializer, initargs=(progressCounter,))
else:
#runners = Pool(initializer=nas_utils.runSimulationWorkerInitializer, initargs=(progressCounter,))
# runners = Pool(initializer=nas_utils.runSimulationWorkerInitializer, initargs=(progressCounter,))
runners = Pool(int(mp.cpu_count()/2), initializer=nas_utils.runSimulationWorkerInitializer, initargs=(progressCounter,))
params.expanded_sim_params = nas_utils.expand_sim_parameters(params.sim_params)
totalRuns = len(params.expanded_sim_params) * params.runs_per_scenario
try:
logger.info('Running simulations')
logger.debug('Using params: ' + ", ".join([k+'='+str(v) for k, v in vars(params).items() if k != 'expanded_sim_params']))
seed_list = sample(range(10000000, 99999999), totalRuns)
totalRuns = len(params.expanded_sim_params) * params.runs_per_scenario
if params.same_seeds:
seed_list = sample(range(10000000, 99999999), params.runs_per_scenario)*len(params.expanded_sim_params)
else:
seed_list = sample(range(10000000, 99999999), totalRuns)
ids_seeds_and_params = zip(seed_list, cycle(params.expanded_sim_params))
runTestPartial = partial(nas_utils.runSimulation, params.script, outDir, totalRuns, params.slurm)
# total_t1 = time()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment