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

Cannot use Options with box constrained optimization (without providing gradient?) #1016

Open
benoitseron opened this issue Oct 26, 2022 · 2 comments

Comments

@benoitseron
Copy link

benoitseron commented Oct 26, 2022

I am trying to optimize a function in a box constrained setting. I cannot provide its gradient. This seems not to be an issue if I am not asking for any options, but as soon as I put some, I have the following error.

x_0 = [1., 1.]
lower = zeros(length(x_0))
upper = ones(length(x_0))

optimize(f, x_0, Optim.Options(time_limit = 15.0))
# works
optimize(f,lower, upper, x_0)
# works

optimize(f,lower, upper, x_0 , Optim.Options(time_limit = 15.0))
# fails :

# MethodError: objects of type Vector{Float64} are not callable
# Use square brackets [] for indexing an Array.

# I assume that the problem comes from not providing "g"

I am not sure if this comes from misuse from my side.

@jecs
Copy link

jecs commented Oct 27, 2022

Have you tried explicitly instantiating the solver and wrapping it in Fminbox? e.g. Fminbox(NelderMead()).

Fminbox is used in the examples under Box Constrained Optimization. It's a bit indirect to learn about it; the documentation could certainly use some updating. Also, I am not sure if Fminbox works for gradient-free solvers.

Edit: I just checked the source code and Fminbox does indeed seem to support gradient-free methods.

@pkofod
Copy link
Member

pkofod commented Nov 23, 2022

There might be missing a dispatch somewhere. Try to specify Fminbox explicitly before the options as @jecs stated.

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