elif args.optimizer == 'local': acq_optimizer_type = 'local_random' else: raise ValueError('Unknown optimizer %s' % args.optimizer) if acq_type in ['mesmoc', 'mesmoc2']: surrogate_type = None acq_optimizer_type = None rep = args.rep start_id = args.start_id plot_mode = args.plot_mode if acq_type == 'ehvic': mth = 'openbox' else: mth = 'openbox-%s' % acq_type problem = get_problem(problem_str) if initial_runs == 0: initial_runs = 2 * (problem.dim + 1) cs = problem.get_configspace(optimizer='smac') time_limit_per_trial = 600 task_id = '%s_%s_%s' % (mth, acq_type, problem_str) def evaluate(mth, run_i, seed): print(mth, run_i, seed, '===== start =====', flush=True) def objective_function(config): res = problem.evaluate_config(config) res['config'] = config res['objs'] = np.asarray(res['objs']).tolist() res['constraints'] = np.asarray(res['constraints']).tolist()
else: hv_diffs, pf, config_list, perf_list, time_list = save_item if len(hv_diffs) / times != max_runs: print('Error len: ', file, len(hv_diffs)) continue result.append(hv_diffs) print('last hv_diff =', hv_diffs[-1]) if pf is not None: print(mth, 'pareto num =', len(pf)) print('result rep =', len(result), mth) result = np.array(result) if problem_str in ['bnh', 'srn', 'constr']: # fix max hv import sys sys.path.insert(0, '.') from moc_benchmark_function import get_problem max_hv = get_problem(problem_str).new_max_hv result += max_hv print('===== fix max_hv =', max_hv, problem_str) if (result < 0).any() and (result > 0).any(): raise ValueError if log_phv: if (result == 0.0).any(): print('===== WARNING: zero value in result. set to 1e-10 to do log.') result[result == 0.0] = 1e-10 result = log_func(result) # log mean_res = np.mean(result, axis=0) std_res = np.std(result, axis=0) # plot x = (np.arange(len(mean_res)) + 1) / times p, = plt.plot(x, mean_res, label=get_mth_legend(mth), color=color_dict[mth])