# BO loop n_iters = 10 for iteration in range(n_iters): # Fit GP model botorch.fit_gpytorch_model(mll=mll_fct) # Define the acquisition function acq_fct = botorch.acquisition.ExpectedImprovement(model=model, best_f=best_f[-1], maximize=False) # Get new candidate new_x = joint_optimize_manifold(acq_fct, sphere_manifold, solver, q=1, num_restarts=5, raw_samples=100, bounds=bounds, equality_constraints=eq_constraints) # Get new observation new_y = test_function(new_x)[0] # Update training points x_data = torch.cat((x_data, new_x)) y_data = torch.cat((y_data, new_y)) # Update best observation new_best_f, index = y_data.min(0) best_x.append(x_data[index]) best_f.append(new_best_f)
inequality_constraints = [ max_eigenvalue_constraint, min_eigenvalue_constraint ] # Define the acquisition function acq_fct = botorch.acquisition.ExpectedImprovement(model=latent_model, best_f=best_f[-1], maximize=False) # Get new candidate new_x_projected = joint_optimize_manifold( acq_fct, latent_spd_manifold, acquisition_solver, q=1, num_restarts=5, raw_samples=100, bounds=bounds, pre_processing_manifold=vector_to_symmetric_matrix_mandel_torch, post_processing_manifold=symmetric_matrix_to_vector_mandel_torch, approx_hessian=True, inequality_constraints=inequality_constraints) # To matrix new_x_projected = vector_to_symmetric_matrix_mandel_torch( new_x_projected) # Projection back onto the original SPD manifold new_x = projection_from_nested_spd_to_spd( new_x_projected, projection_matrix, projection_complement_matrix, bottom_spd_matrix, contraction_matrix) # To vector
# BO loop n_iters = 25 for iteration in range(n_iters): # Fit GP model botorch.fit_gpytorch_model(mll=mll_fct) # Define the acquisition function acq_fct = botorch.acquisition.ExpectedImprovement(model=model, best_f=best_f[-1], maximize=False) # Get new candidate new_x = joint_optimize_manifold(acq_fct, sphere_manifold, solver, q=1, num_restarts=5, raw_samples=100, bounds=bounds) # Get new observation new_y = test_function(new_x)[0] # Update training points x_data = torch.cat((x_data, new_x)) y_data = torch.cat((y_data, new_y)) # Update best observation new_best_f, index = y_data.min(0) best_x.append(x_data[index]) best_f.append(new_best_f)