def test_save_gp_2d(self): k = GPy.kern.Matern52(input_dim=2) m = GPModel(kernel=k) myBopt = BayesianOptimization(f=self.f_2d, domain=self.domain_2d, model=m) myBopt.run_optimization(max_iter=1, verbosity=False) myBopt.save_models(self.outfile_path) self.check_output_model_file(['Iteration'])
def test_save_gp_2d(self): k = GPy.kern.Matern52(input_dim=2) m = GPModel(kernel=k) myBopt = BayesianOptimization(f=self.f_2d, domain=self.domain_2d, model=m) myBopt.run_optimization(max_iter=1, verbosity=False) myBopt.save_models(self.outfile_path) self.check_output_model_file(['Iteration'])
def test_save_gp_2d_ard(self): """ This was previously an edge-case, when some parameters were vectors, the naming of the columns was incorrect """ k = GPy.kern.Matern52(input_dim=2, ARD=True) m = GPModel(kernel=k) myBopt = BayesianOptimization(f=self.f_2d, domain=self.domain_2d, model=m) myBopt.run_optimization(max_iter=1, verbosity=False) myBopt.save_models(self.outfile_path) self.check_output_model_file(['Iteration'])
def test_save_gp_2d_ard(self): """ This was previously an edge-case, when some parameters were vectors, the naming of the columns was incorrect """ k = GPy.kern.Matern52(input_dim=2, ARD=True) m = GPModel(kernel=k) myBopt = BayesianOptimization(f=self.f_2d, domain=self.domain_2d, model=m) myBopt.run_optimization(max_iter=1, verbosity=False) myBopt.save_models(self.outfile_path) self.check_output_model_file(['Iteration'])
Y_init = np.reshape(np.array(array_y), (-1, 1)) for ind, cost in enumerate(array_cost): list_sampled_x.append(array_sampled_x[ind, :]) list_y.append(array_y[ind]) list_cost.append(array_cost[ind]) max_iter = max_iter_ - len(list_y) obj_count = len(list_y) - 1 myBO = BayesianOptimization(f=obj_val, domain=domain, constraints=constraints, X=X_init, Y=Y_init, initial_design_numdata=initial_design_numdata, initial_design_type='latin', acquisition_type=acq, maximize=is_max) myBO.run_optimization(max_iter=max_iter) myBO.save_report(report_file=txt_path + '_report.txt') myBO.save_evaluations(evaluations_file=txt_path + '_evaluations.txt') myBO.save_models(txt_path + '_models.txt') result = { 'sampled_x': np.array(list_sampled_x), 'observed_y': np.array(list_y), 'cost': np.array(list_cost), 'random_seeds': random_seeds } with open(txt_path + '_result.txt', "w") as file: file.write(str(result)) with open(txt_path + '_result.pickle', "wb") as file: pickle.dump(result, file)
def test_save_gp_default(self): myBopt = BayesianOptimization(f=self.f_2d, domain=self.domain_2d) myBopt.run_optimization(max_iter=1, verbosity=False) myBopt.save_models(self.outfile_path) self.check_output_model_file(['Iteration'])
def test_save_gp_no_filename(self): myBopt = BayesianOptimization(f=self.f_2d, domain=self.domain_2d) myBopt.run_optimization(max_iter=1, verbosity=False) # Need to at least pass in filename or buffer self.assertRaises(TypeError, lambda: myBopt.save_models())
def test_save_gp_default_no_iters(self): myBopt = BayesianOptimization(f=self.f_2d, domain=self.domain_2d) # Exception should be raised as no iterations have been carried out yet self.assertRaises(ValueError, lambda: myBopt.save_models(self.outfile_path))
def test_save_gp_default(self): myBopt = BayesianOptimization(f=self.f_2d, domain=self.domain_2d) myBopt.run_optimization(max_iter=1, verbosity=False) myBopt.save_models(self.outfile_path) self.check_output_model_file(['Iteration'])
def test_save_gp_no_filename(self): myBopt = BayesianOptimization(f=self.f_2d, domain=self.domain_2d) myBopt.run_optimization(max_iter=1, verbosity=False) # Need to at least pass in filename or buffer self.assertRaises(TypeError, lambda: myBopt.save_models())
def test_save_gp_default_no_iters(self): myBopt = BayesianOptimization(f=self.f_2d, domain=self.domain_2d) # Exception should be raised as no iterations have been carried out yet self.assertRaises(ValueError, lambda: myBopt.save_models(self.outfile_path))