Surrogates.jl
Surrogates.jl copied to clipboard
Optimization function mutates surrogate struct
The optimization functions in surrogates mutate the surrogate struct.
To reproduce:
using Surrogates
#sphere function
function s(x)
return sum(x .^ 2)
end
n = 30
d = 3
lb = [-10.0 for i in 1:d]
ub = [10.0 for i in 1:d]
x = sample(n, lb, ub, SobolSample())
y = s.(x)
r = RadialBasis(x, s.(x), lb, ub, rad = linearRadial())
size(r.x) #(30,)
size(r.y) #(30,)
surrogate_optimize(s, SRBF(), lb, ub, r, UniformSample())
size(r.x) #(165,)
size(r.y) #(165,)
Should we be indicating that the function mutates with the !
convention (i.e. surrogate_optimize!(s, SRBF(), lb, ub, r, UniformSample())
)?
Yes it should have a !
This also confused me for a bit.