def first_pass(config):
config = copy.deepcopy(config)
config['result_dir_prefix'] = config['result_dir_prefix'] + '/first-pass'
if config['debug']:
print('Removing fixed params')
config["fixed_params"] = {}
config['max_iter'] = 5 if config['debug'] else 150
if config['debug']:
print('Overriding max_iter params to %d' % config['max_iter'])
dry_run = True if config['debug'] else False
get_params = get_agent_class(config).get_random_config
results = []
futures = []
with concurrent.futures.ProcessPoolExecutor(min(multiprocessing.cpu_count(), config['nb_process'])) as executor:
nb_config = 5 if config['debug'] else 1000
for i in range(nb_config):
params = get_params(config["fixed_params"])
config.update(params)
futures.append(executor.submit(exec_first_pass, i, copy.deepcopy(config), params))
concurrent.futures.wait(futures)
results = []
for future in futures:
results.append(future.result())
return {
'results': sorted(results, key=lambda result: result['mean_score'], reverse=True)
}
评论列表
文章目录