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

JuMP tutorial to NLopt doesn't work #165

Closed
sourav-majumdar-math opened this issue May 21, 2021 · 2 comments · Fixed by #162
Closed

JuMP tutorial to NLopt doesn't work #165

sourav-majumdar-math opened this issue May 21, 2021 · 2 comments · Fixed by #162

Comments

@sourav-majumdar-math
Copy link

sourav-majumdar-math commented May 21, 2021

In the tutorial,

using JuMP
using NLopt

model = Model(NLopt.Optimizer)
set_optimizer_attribute(model, "algorithm", :LD_MMA)

a1 = 2
b1 = 0
a2 = -1
b2 = 1

@variable(m, x1)
@variable(m, x2 >= 0)

@NLobjective(m, Min, sqrt(x2))
@NLconstraint(m, x2 >= (a1*x1+b1)^3)
@NLconstraint(m, x2 >= (a2*x1+b2)^3)

set_start_value(x1, 1.234)
set_start_value(x2, 5.678)

optimize!(model)

println("got ", objective_value(model), " at ", [value(x1), value(x2)])

Shouldn't it be model instead of m in @variable(m,x1) and other places where m appears? Otherwise it gives an error that m is not defined.

If I proceed with model instead of m, then at optimize!(model) I get UndefVarError: optimize! not defined.

I am on Ubuntu 20.04 with Julia version 1.4.1. I am using the Juno IDE. The other tutorial with NLopt without calling JuMP worked as expected.

@blegat
Copy link
Member

blegat commented May 21, 2021

Indeed, thanks for letting us know, this should be fixed now. About the error UndefVarError: optimize! not defined. Which JuMP version are you using ? You should use at least v0.19 for this to work.

@sourav-majumdar-math
Copy link
Author

I am using JuMP v0.21.8. Additionally I get the warning WARNING: both NLopt and JuMP export "optimize!"; uses of it in module Main must be qualified on calling optimize!.

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

Successfully merging a pull request may close this issue.

2 participants