Problem using NLopt in JuMP model

Hi,

I am trying to create a JuMP model using NLopt solver in Julia 1.5.3

using JuMP
using NLopt
model = Model(NLopt.Optimizer)

but I get the following error

ERROR: UndefVarError: Optimizer not defined
Stacktrace:
[1] getproperty(::Module, ::Symbol) at .\Base.jl:26
[2] top-level scope at none:1

Any hints?

Which JuMP version do you use?

Hi Mike, I am using JuMP v0.21.3 and NLopt v0.6.0

Hmm, the syntax is correct according to the tutorial of NLopt. Did you test the packages with the package manager? e.g., (@1.5) pkg> test NLopt

I think you need NLopt v0.6.1 for JuMP compatibility.
Have you tried updating your packages?

1 Like

I updated NLopt using Pkg.update("NLopt") but I still get the version NLopt v0.6.0
How can I update to 0.6.1 ?

Yes, I did both Pkg.test("NLopt") and Pkg.test("JuMP") and everything looks fine but it is not working

In the package manager, try explicitly adding version v0.6.1:

(v1.5) pkg> add NLopt@0.6.1

This might fail with error messages, giving you a clue as to which package(s) are holding back NLopt.

2 Likes

Or try Ipopt

2 Likes

@greg_plowman thanks for the hint. I run pkg> add NLopt@0.6.1 and I got the following errors

(@JuliaPro_v1.5.3-1) pkg> add NLopt@0.6.1
  Resolving package versions...
ERROR: Unsatisfiable requirements detected for package VegaLite [112f6efa]:
 VegaLite [112f6efa] log:
 ├─possible versions are: [0.3.4, 0.4.0, 0.5.0-0.5.3, 0.6.0, 0.7.0, 1.0.0, 2.0.0-2.0.1, 2.1.0-2.1.3, 2.2.0, 2.3.0] or uninstalled
 ├─restricted to versions * by an explicit requirement, leaving only versions [0.3.4, 0.4.0, 0.5.0-0.5.3, 0.6.0, 0.7.0, 1.0.0, 2.0.0-2.0.1, 2.1.0-2.1.3, 2.2.0, 2.3.0]
 ├─restricted by compatibility requirements with Queryverse [612083be] to versions: [0.4.0, 0.5.0-0.5.3, 0.6.0, 0.7.0, 1.0.0, 2.0.0-2.0.1, 2.1.0-2.1.3, 2.2.0, 2.3.0]
 │ └─Queryverse [612083be] log:
 │   ├─possible versions are: [0.1.0, 0.2.0, 0.3.0-0.3.1, 0.5.0, 0.6.0-0.6.2] or uninstalled
 │   └─restricted to versions * by an explicit requirement, leaving only versions [0.1.0, 0.2.0, 0.3.0-0.3.1, 0.5.0, 0.6.0-0.6.2]
 ├─restricted by compatibility requirements with JSONSchema [7d188eb4] to versions: [0.3.4, 0.4.0, 0.5.0-0.5.3, 0.6.0] or uninstalled, leaving only versions: [0.4.0, 0.5.0-0.5.3, 0.6.0]
 │ └─JSONSchema [7d188eb4] log:
 │   ├─possible versions are: [0.1.0-0.1.1, 0.2.0, 0.3.0-0.3.3] or uninstalled
 │   └─restricted by compatibility requirements with MathOptInterface [b8f27783] to versions: 0.3.0-0.3.3
 │     └─MathOptInterface [b8f27783] log:
 │       ├─possible versions are: [0.5.0-0.5.1, 0.6.0-0.6.4, 0.7.0, 0.8.0-0.8.4, 0.9.0-0.9.19] or uninstalled
 │       ├─restricted to versions * by an explicit requirement, leaving only versions [0.5.0-0.5.1, 0.6.0-0.6.4, 0.7.0, 0.8.0-0.8.4, 0.9.0-0.9.19]
 │       └─restricted by compatibility requirements with NLopt [76087f3c] to versions: 0.9.17-0.9.19
 │         └─NLopt [76087f3c] log:
 │           ├─possible versions are: [0.5.0-0.5.1, 0.6.0-0.6.1] or uninstalled
 │           └─restricted to versions 0.6.1 by an explicit requirement, leaving only versions 0.6.1
 └─restricted by compatibility requirements with Requires [ae029012] to versions: [0.7.0, 1.0.0, 2.0.0-2.0.1, 2.1.0-2.1.3, 2.2.0, 2.3.0] or uninstalled — no versions left
   └─Requires [ae029012] log:
     ├─possible versions are: [0.5.0-0.5.2, 1.0.0-1.0.3, 1.1.0-1.1.2] or uninstalled
     ├─restricted by compatibility requirements with Atom [c52e3926] to versions: [0.5.0-0.5.2, 1.0.0-1.0.3, 1.1.0-1.1.2]
     │ └─Atom [c52e3926] log:
     │   ├─possible versions are: [0.8.0-0.8.8, 0.9.0-0.9.1, 0.10.0-0.10.2, 0.11.0-0.11.3, 0.12.0-0.12.30] or uninstalled
     │   └─restricted to versions 0.12.25 by an explicit requirement, leaving only versions 0.12.25
     └─restricted by compatibility requirements with Weave [44d3d7a6] to versions: [1.0.0-1.0.3, 1.1.0-1.1.2]
       └─Weave [44d3d7a6] log:
         ├─possible versions are: [0.6.0-0.6.2, 0.7.0-0.7.2, 0.8.0-0.8.1, 0.9.0-0.9.4, 0.10.0-0.10.6] or uninstalled
         └─restricted to versions * by an explicit requirement, leaving only versions [0.6.0-0.6.2, 0.7.0-0.7.2, 0.8.0-0.8.1, 0.9.0-0.9.4, 0.10.0-0.10.6]

I am not sure what I should do exactly. I tried to add or update several packages that are mentionned but the issue has not been resolved.

What happens if you remove VegaLite?

Pkg.rm("VegaLite")
Pkg.update()
1 Like

@greg_plowman Ι removed both Vegalite and Queryverse and I then updated the packages using Pkg.update(). It seems that Queryverse was blocking several Pkg updates including NLopt which now could be updated to version 0.6.1 . Then eventually I was able to create a JuMP model with NLopt optimizer. Thanks a lot !!

2 Likes