Quick questions for multi-variables, multi-threads.
Hello! Thank you very much for developing such an excellent tool :)
I have a couple of questions that arose while running one of the example files. I noticed that when attempting to use more than two input parameters, as shown in the previous example (e.g., 11 dimensions), the optimizer starts repeatedly selecting the exact same set of 'x' parameters after a certain number of iterations. Could you please advise if I am potentially misusing or misunderstanding the kernel configuration, specifically regarding the number of bounds required for the kernel in the MAPGPOptimizer? I adjusted the size of the kernel boundary to match the number of input parameters, but I suspect this might be incorrect, and any clarification on the proper setup would be greatly appreciated.
using BayesianOptimization, GaussianProcesses, Distributions
N_DIM = 11
function f(x::Vector{Float64})
if length(x) != N_DIM
error("Input vector must have length $N_DIM")
end
return sum((x .- 1.0).^2) + randn()
end
initial_length_scales = zeros(N_DIM)
model = ElasticGPE(N_DIM,
mean = MeanConst(0.),
kernel = SEArd(initial_length_scales, 5.),
logNoise = 0.,
capacity = 3000)
set_priors!(model.mean, [Normal(1, 2)])
kern_l_bounds = vcat(fill(-3.0, N_DIM), 0.0)
kern_u_bounds = vcat(fill(4.0, N_DIM), 10.0)
modeloptimizer = MAPGPOptimizer(
every = 50,
noisebounds = [-4, 3],
kernbounds = [kern_l_bounds, kern_u_bounds],
maxeval = 40
)
lower_bounds = fill(-5.0, N_DIM)
upper_bounds = fill(5.0, N_DIM)
opt = BOpt(f,
model,
UpperConfidenceBound(),
modeloptimizer,
lower_bounds, upper_bounds,
repetitions = 5,
maxiterations = 300,
sense = Min, # minimize
acquisitionoptions = (
method = :LD_LBFGS,
restarts = 5,
maxtime = 20,
maxeval = 1000
),
verbosity = Progress
)
result = boptimize!(opt)
Second question concerns multi-threading/parallelization: I would like to run the optimization using multiple CPUs via multi-threading. Does this require deep modification of the internal code, or can it be achieved simply by using external libraries like Distributed.jl? Specifically, I'm thinking of drawing multiple next searching points after each acquisition function evaluation to speed up the process, and I'm curious if this would be technically feasible or overly complex to implement.
My final question concerns how to retrieve all observed function values corresponding to the sampled input parameters. While I can access the sampled input parameters via opt.model.x, I suspect that opt.model.y does not contain the complete history of function evaluations. It appears to store only the function value of the optimal point found at each iteration (the observed optimum), rather than the full set of function values for all sampled points. Could you please clarify where the complete history of all function evaluation results (i.e., the $f(x)$ value for every sampled $x$ in opt.model.x) is stored within the BOpt object ?
Thanks a lot!