def run_rep_parallel(bayes_optimiser: BayesOptimiser, queue, config_ind, rep_ind, seed): torch.manual_seed(seed) np.random.seed(seed) bayes_optimiser.run_all_opt_steps() # message = (config_ind, rep_ind, bayes_optimiser.best_val(in_real_units=True)) vals = bayes_optimiser.obj_func_vals_real_units() best_vals = bayes_optimiser.best_val(in_real_units=True) message = (config_ind, rep_ind, vals, best_vals) # message = (config_ind, rep_ind, best_vals) queue.put(message)
(min_vsf_depth_20N - param_dic["target_min_vsf_depth_20N"])**2) return y, min_vsf_depth_20N if __name__ == '__main__': n_init_points = 16 n_bayes_points = 48 n_evals_per_step = 8 measure_year = 100 target_min_vsf_depth_20N = -15 * 10**6 obj_func = OceanObjSimThree(target_min_vsf_depth_20N, measure_year=measure_year) optimiser = BayesOptimiser(n_init_points, n_bayes_points, obj_func, n_evals_per_step=n_evals_per_step) optimiser.save_optimiser() # slurm_set_up.set_up( # optimiser.file_name, ["modi_long", "modi_short"], "global_four_degree.py", make_new_slurm_controller=True, # using_singularity=True, image_path="~/modi_images/hpc-ocean-notebook_latest.sif", conda_env="python3") # # # slurm_set_up.start_opt_run("modi001")
alpha = 1.0 omega = 1.0 acq_func = PredefinedAcqFunction(obj_func.bounds, n_objs, n_evals_per_step, acqfunc_name='EHVI', seq_dist_punish=True, alpha=alpha, omega=omega) constraints = n_objs * [{"covar_module": {"raw_lengthscale": [0.1, 2.0]}}] model_list = n_objs * [MaternModelBO] # Matern is the default kernel = BayesOptModel(obj_func.n_params, obj_func.n_objs, model_class_list=model_list, init_train_its=1000, constraint_dict_list=constraints) optimiser = BayesOptimiser(n_init_points, n_bayes_points, obj_func, acq_func, model=kernel, n_evals_per_step=n_evals_per_step) veropt_gui.run(optimiser)
def run(): n_init_points = 16 n_bayes_points = 64 n_objs = 1 beta = 3.0 gamma = 0.01 n_evals_per_step = 8 # obj_func = PredefinedFitTestFunction("sine_3params") obj_func = PredefinedTestFunction("Hartmann") kernel = BayesOptModel(obj_func.n_params, n_objs, model_class_list=[MaternModelBO], init_train_its=1000, using_priors=False) # alpha_array = np.linspace(0.1, 10, num=20) # omega_array = np.linspace(0.1, 1.0, num=10) alpha_array = np.linspace(0.1, 10, num=5) omega_array = np.linspace(0.1, 1.0, num=5) optimiser_list = [] for alpha in alpha_array: omega = 0.5 acq_func = PredefinedAcqFunction( obj_func.bounds, n_objs, n_evals_per_step=n_evals_per_step, acqfunc_name="UCB_Var", seq_dist_punish=True, beta=beta, gamma=gamma, alpha=alpha, omega=omega, ) optimiser_list.append( BayesOptimiser(n_init_points, n_bayes_points, obj_func, acq_func, model=kernel, test_mode=False, using_priors=False, n_evals_per_step=n_evals_per_step, verbose=False)) for omega in omega_array: alpha = 2.0 acq_func = PredefinedAcqFunction(obj_func.bounds, n_objs, n_evals_per_step=n_evals_per_step, acqfunc_name="UCB_Var", seq_dist_punish=True, beta=beta, gamma=gamma, alpha=alpha, omega=omega) optimiser_list.append( BayesOptimiser(n_init_points, n_bayes_points, obj_func, acq_func, model=kernel, test_mode=False, using_priors=False, n_evals_per_step=n_evals_per_step, verbose=False)) parameters = {"alpha": alpha_array, "omega": omega_array} experiment = BayesExperiment(optimiser_list, parameters) # experiment.run_full_experiment() # experiment.run_full_exp_parallel(save=False) experiment.save_experiment()
super().__init__(bounds=bounds, n_params=n_params, n_objs=n_objs, calc_y_method=calc_y_method, var_names=var_names, obj_names=obj_names, file_path=file_path) if __name__ == '__main__': n_init_points = 8 n_bayes_points = 40 n_evals_per_step = 8 measure_year = 100 target_vsf_depth_min_equator = -3200856.86124386 obj_func = OceanObjSimTwo(target_vsf_depth_min_equator, measure_year=measure_year) optimiser = BayesOptimiser(n_init_points, n_bayes_points, obj_func, using_priors=False, n_evals_per_step=n_evals_per_step) optimiser.save_optimiser()