# Parallel Optimization with Surrogates.jl

I’m thinking about using Surrogates.jl to optimize a process in my lab using the Gaussian processes for Bayesian optimization. It’s easier for me to run multiple experiments at once, so I was wondering if it was possible to have Surrogates.jl ask for multiple points at the same time? I’m not seeing any obvious settings in the documentation.

If it’s not possible to do with Surrogates.jl, are there any other packages that would have this functionality?

Just give the constructor an array. Most of the tutorials show this for each specific surrogate type.

With respect to Surrogates.jl, there should be no problem getting multiple points at once from a Gaussian Process surrogate, as Chris suggests.

However, serial Bayesian optimization won’t be able to give you which points to query, as you need to optimize over the joint distribution of multiple queries. For that, you will need something like Botorch, specifically see Batching · BoTorch and Optimization · BoTorch

Unfortunately I’m not aware of anyone porting the algorithms to Julia.

Thank you, for your help! I apologize because I think I was unclear with my question. I see now that it’s pretty simple to get multiple points out of an already constructed surrogate model. However, I don’t see how it’s possible construct a surrogate model in parallel. For example, here is a Kriging example from the documentation.

``````using Surrogates
f = x -> exp(x)*x^2+x^3
lb = 0.0
ub = 10.0
x = sample(50,lb,ub,UniformSample())
y = f.(x)
p = 1.9
my_krig = Kriging(x,y,lb,ub,p=p)

#I want an approximation at 5.4
approx = my_krig(5.4)

surrogate_optimize(f,LCBS(),lb,ub,my_krig,UniformSample(); maxiters = 10, num_new_samples = 10)
``````

I realize that if I wanted to query my pre-existing model, I could just define an array `arr=[1,2,3]` and get the value of the surrogate at those points with `my_krig.(arr)`. However, I’m interested in querying multiple points during the optimization process itself. How could I get `surrogate_optimize` to query `f` multiple times before refitting the surrogate model and asking asking for the next batch of points?

It seems like @platawiec is saying this is currently not possible. Looking more into it, I saw this issue on the Surrogates.jl repo: Plans for parallel optimization · Issue #278 · SciML/Surrogates.jl (github.com). It doesn’t seem too terribly complicated but it was never resolved, so did it end up being harder than originally thought?

It’s not hard, someone just has to do it.

Okay, then I’ll give it a try, myself.

I finally got around to working on this. I’ve opened up a draft PR that introduces the beginnings of this functionality. It’s definitely not finished yet, but I’ll keep working on it once I get the go ahead that my current approach is promising.

1 Like