Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization function mutates surrogate struct #380

Open
vikram-s-narayan opened this issue Jul 16, 2022 · 2 comments
Open

Optimization function mutates surrogate struct #380

vikram-s-narayan opened this issue Jul 16, 2022 · 2 comments

Comments

@vikram-s-narayan
Copy link
Contributor

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()))?

@ChrisRackauckas
Copy link
Member

Yes it should have a !

@ablaom
Copy link

ablaom commented Oct 2, 2023

This also confused me for a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants