Пример #1
0
        # Obtain next sampling point from the acquisition function (expected_improvement)
        X_next = propose_location(expected_improvement, X_sample, Y_sample,
                                  gpr, bounds)

        # Obtain next noisy sample from the objective function
        Y_next = f_x(X_next, noise)

        # Plot samples, surrogate function, noise-free objective and next sampling location
        plt.subplot(n_iter, 2, 2 * i + 1)
        plot_approximation(gpr,
                           X,
                           Y,
                           X_sample,
                           Y_sample,
                           X_next,
                           show_legend=i == 0)
        plt.title(f'Iteration {i + 1}')

        plt.subplot(n_iter, 2, 2 * i + 2)
        plot_acquisition(X,
                         expected_improvement(X, X_sample, Y_sample, gpr),
                         X_next,
                         show_legend=i == 0)

        # Add sample to previous samples
        X_sample = np.vstack((X_sample, X_next))
        Y_sample = np.vstack((Y_sample, Y_next))

    plot_convergence(X_sample, Y_sample)
Пример #2
0
        for fun_idx, f in enumerate(f_list):
            Y_next_list.append(f(X_next, noise=noise))

        # Plot samples, surrogate function, noise-free objective and next sampling location
        plt.subplot(n_iter, 2, 2 * i + 1)
        plot_approximation(gpr,
                           X,
                           Y_alpha,
                           X_sample,
                           Y_sample_alpha,
                           X_next,
                           show_legend=i == 0)
        plt.title(f'Iteration {i + 1}')

        plt.subplot(n_iter, 2, 2 * i + 2)
        plot_acquisition(X,
                         expected_improvement(X, X_sample, Y_sample_alpha,
                                              gpr),
                         X_next,
                         show_legend=i == 0)

        # Add sample to previous samples
        X_sample = np.vstack((X_sample, X_next))
        for fun_idx, Y_sample in enumerate(Y_sample_list):
            Y_sample_list[fun_idx] = np.vstack(
                [Y_sample_list[fun_idx], Y_next_list[fun_idx]])

        Y_sample_alpha = Y_sample_list[0] + alpha * Y_sample_list[1]

    plot_convergence(X_sample, Y_sample_alpha)