Esempio n. 1
0
            )
            eval_pts = np.reshape(
                np.append(
                    eval_pts,
                    (cpp_gp.get_historical_data_copy()).points_sampled[
                        :, : (cpp_gp_loglikelihood.dim - objective_func._num_fidelity)
                    ],
                ),
                (
                    eval_pts.shape[0] + cpp_gp.num_sampled,
                    cpp_gp.dim - objective_func._num_fidelity,
                ),
            )

            test = np.zeros(eval_pts.shape[0])
            ps_evaluator = PosteriorMean(cpp_gp, num_fidelity)
            for i, pt in enumerate(eval_pts):
                ps_evaluator.set_current_point(
                    pt.reshape(
                        (1, cpp_gp_loglikelihood.dim - objective_func._num_fidelity)
                    )
                )
                test[i] = -ps_evaluator.compute_objective_function()

            initial_point = eval_pts[np.argmin(test)]

            ps_sgd_optimizer = cppGradientDescentOptimizer(
                cpp_inner_search_domain, ps_evaluator, cpp_sgd_params_ps
            )
            report_point = posterior_mean_optimization(
                ps_sgd_optimizer, initial_guess=initial_point, max_num_threads=4
Esempio n. 2
0
            plt.plot(discrete_pts.flatten(), temp_mean, 'k')
            plt.fill_between(discrete_pts.flatten(),
                             temp_mean - temp_std,
                             temp_mean + temp_std,
                             color='b',
                             alpha=0.2)

            x_axis = cpp_gp_nogradient.get_historical_data_copy(
            ).points_sampled
            y_axis = cpp_gp_nogradient.get_historical_data_copy(
            ).points_sampled_value[:, 0]
            plt.plot(x_axis, y_axis, 'bs')
            pdf.savefig()  # saves the current figure into a pdf page
            plt.close()

            ps_evaluator = PosteriorMean(cpp_gp_nogradient, 0)
            ps_sgd_optimizer = cppGradientDescentOptimizer(
                cpp_search_domain, ps_evaluator, cpp_sgd_params_ps)

            fig, ax = plt.subplots(figsize=(figwidth, figheight))
            ax.set_ylim(0, 0.5)
            Y = None
            #for num, mc in enumerate([20, 100, 1000]):
            cpp_kg_evaluator_nogradient = cppKnowledgeGradient(
                gaussian_process=cpp_gp_nogradient,
                num_fidelity=0,
                inner_optimizer=ps_sgd_optimizer,
                discrete_pts=init_points,
                num_mc_iterations=100)
            xlist = discrete_pts.flatten()