init_data.append_sample_points([ SamplePoint(pt, [init_pts_value[num, i] for i in observations], objective_func._sample_var) for num, pt in enumerate(init_pts) ]) cpp_cov = cppSquareExponential(np.ones(objective_func._dim + 1)) noise_variance = np.ones(1 + len(derivatives)) hyper_domain = np.zeros((2 + dim + len(derivatives), 2)) hyper_domain[:(2 + dim), :] = objective_func._hyper_domain[:(2 + dim), :] for g in range(len(derivatives)): hyper_domain[g + 2 + dim, :] = objective_func._hyper_domain[derivatives[g] + 2 + dim, :] hyper_search_domain = cppTensorProductDomain( [ClosedInterval(bound[0], bound[1]) for bound in hyper_domain]) hyper_params = np.ones(2 + dim + len(derivatives)) cpp_gp = cppGaussianProcess(cpp_cov, hyper_params[(1 + objective_func._dim):], init_data, derivatives) cpp_gp_loglikelihood = cppGaussianProcessLogLikelihood( cpp_cov, cpp_gp.get_historical_data_copy(), noise_variance, derivatives) sgd_optimizer = cppGradientDescentOptimizer(hyper_search_domain, cpp_gp_loglikelihood, cpp_sgd_params_hyper) hyper_params = multistart_hyperparameter_optimization( log_likelihood_optimizer=sgd_optimizer, num_multistarts=None, max_num_threads=8)
objective_func = obj_func_dict[obj_func_name] dim = int(objective_func._dim) num_initial_points = initial_n num_fidelity = objective_func._num_fidelity inner_search_domain = pythonTensorProductDomain( [ ClosedInterval( objective_func._search_domain[i, 0], objective_func._search_domain[i, 1] ) for i in range(objective_func._search_domain.shape[0] - num_fidelity) ] ) cpp_search_domain = cppTensorProductDomain( [ClosedInterval(bound[0], bound[1]) for bound in objective_func._search_domain] ) cpp_inner_search_domain = cppTensorProductDomain( [ ClosedInterval( objective_func._search_domain[i, 0], objective_func._search_domain[i, 1] ) for i in range(objective_func._search_domain.shape[0] - num_fidelity) ] ) # get the initial data init_pts = np.zeros((initial_n, objective_func._dim)) init_pts[ :, : objective_func._dim - objective_func._num_fidelity ] = inner_search_domain.generate_uniform_random_points_in_domain(initial_n)
objective_func = synthetic_functions.RandomGP( gp_grad_info_dict['dim'], gp_grad_info_dict['hyper_params'], hist_data_grad) hyper_params = gp_grad_info_dict['hyper_params'] init_pts = [[-2.0], [0.0], [0.3], [0.5]] ymax = 1 else: objective_func = obj_func_dict[obj_func_name] #init_data = utils.get_init_data_from_db(objective_func._dim, objective_func._sample_var, utils.sql_engine, 'init_points_'+obj_func_name) python_search_domain = pythonTensorProductDomain([ ClosedInterval(bound[0], bound[1]) for bound in objective_func._search_domain ]) cpp_search_domain = cppTensorProductDomain([ ClosedInterval(bound[0], bound[1]) for bound in objective_func._search_domain ]) result = numpy.zeros((num_iteration, 6)) best_so_far_kg = numpy.zeros((end_idx - start_idx, num_iteration + 1)) # begin job for job_no in xrange(start_idx, end_idx): python_search_domain = pythonTensorProductDomain([ ClosedInterval(bound[0], bound[1]) for bound in objective_func._search_domain ]) init_value = [objective_func.evaluate(pt) for pt in init_pts] init_data = HistoricalData(objective_func._dim, 1)