Example #1
0
                                                  scaling=False,
                                                  verbose=True)

    # Run the Bayessian optimization
    Bopt = bo_optimizer.optimize(test_function, n_iter=nb_iter_bo)
    print(Bopt)

    if display_figures:
        # Plot the acquisition function
        fig = plt.figure(figsize=(10, 10))
        ax = Axes3D(fig)
        bo_plot_acquisition_spd(
            ax,
            acq_fct,
            r_cone=r_cone,
            xs=bo_optimizer.acquisition.data[0],
            opt_x=Bopt.x,
            true_opt_x=symmetric_matrix_to_vector_mandel(true_sigma)[None],
            alpha=0.25,
            n_elems=20,
            n_elems_h=10)
        ax.set_title('Acquisition function', fontsize=50)
        plt.show()

        # Plot the GP
        fig = plt.figure(figsize=(10, 10))
        ax = Axes3D(fig)
        bo_plot_gp_spd(
            ax,
            model,
            r_cone=r_cone,
            xs=bo_optimizer.acquisition.data[0],
Example #2
0
    # BO optimum to SPD
    opt_x_chol = np.zeros((dim, dim))
    opt_x_chol[indices] = Bopt.x
    opt_x_mat = np.dot(opt_x_chol, opt_x_chol.T)
    opt_x_vec = symmetric_matrix_to_vector_mandel(opt_x_mat)[None]

    if display_figures:
        # Plot the acquisition function
        fig = plt.figure(figsize=(10, 10))
        ax = Axes3D(fig)
        bo_plot_acquisition_spd(
            ax,
            acq_fct,
            r_cone=r_cone,
            xs=x_eval_vec,
            opt_x=opt_x_vec,
            true_opt_x=symmetric_matrix_to_vector_mandel(true_sigma)[None],
            chol=True,
            alpha=0.25,
            n_elems=20,
            n_elems_h=10)
        ax.set_title('Acquisition function', fontsize=50)
        plt.show()

        # Plot the GP
        fig = plt.figure(figsize=(10, 10))
        ax = Axes3D(fig)
        bo_plot_gp_spd(
            ax,
            model,
            r_cone=r_cone,
Example #3
0
        x_eval_mat[n] = np.dot(sigmaL, sigmaL.T)
        x_eval[n] = symmetric_matrix_to_vector_mandel(x_eval_mat[n])

    best_x_mat = np.zeros((len(best_x_chol), dim, dim))
    best_x = np.zeros((len(best_x_chol), dim_vec))
    for n in range(len(best_x_chol)):
        sigmaL = np.zeros((dim, dim))
        sigmaL[indices] = best_x_chol[n].detach().numpy()
        best_x_mat[n] = np.dot(sigmaL, sigmaL.T)
        best_x[n] = symmetric_matrix_to_vector_mandel(best_x_mat[n])

    if disp_fig:
        # Plot acquisition function
        fig = plt.figure(figsize=(5, 5))
        ax = Axes3D(fig)
        bo_plot_acquisition_spd(ax, acq_fct, r_cone=r_cone, xs=x_eval, opt_x=best_x[-1][None],
                                true_opt_x=true_min_vec, n_elems=20, n_elems_h=10)
        ax.set_title('Acquisition function', fontsize=20)
        plt.show()

        # Plot GP
        fig = plt.figure(figsize=(5, 5))
        ax = Axes3D(fig)
        bo_plot_gp_spd(ax, model, r_cone=r_cone, xs=x_eval, opt_x=best_x[-1][None], true_opt_x=true_min_vec,
                       true_opt_y=true_opt_val, max_colors=25., n_elems=20,
                       n_elems_h=10)
        ax.set_title('GP mean', fontsize=20)
        plt.show()

    if dim == 2:
        # Plot convergence on the sphere
        # 3D figure