# Problem using NLopt in JuMP model

**URL:** <https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, nonlinear\
**Created:** [December 28, 2020, 9:52am UTC](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499 "2020-12-28T09:52:39Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emmanouil\_Bakirtzis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emmanouil_bakirtzis/32/11456_2.png) [@Emmanouil\_Bakirtzis](https://discourse.julialang.org/u/Emmanouil_Bakirtzis)\
**Post date:** [December 28, 2020, 9:52am UTC](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499/1 "2020-12-28T09:52:39Z")

</div>

Hi,

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

```julia
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?

---

<div class="post-metadata">

**Author:** ![mike\_k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_k/32/211864_2.png) [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Post date:** [December 28, 2020, 10:37am UTC](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499/2 "2020-12-28T10:37:38Z")

</div>

Which JuMP version do you use?

---

<div class="post-metadata">

**Author:** ![Emmanouil\_Bakirtzis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emmanouil_bakirtzis/32/11456_2.png) [@Emmanouil\_Bakirtzis](https://discourse.julialang.org/u/Emmanouil_Bakirtzis)\
**Post date:** [December 28, 2020, 1:56pm UTC](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499/3 "2020-12-28T13:56:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mike\_k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_k/32/211864_2.png) [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Post date:** [December 29, 2020, 9:46am UTC](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499/4 "2020-12-29T09:46:34Z")

</div>

Hmm, the syntax is correct according to the tutorial of [NLopt](https://github.com/JuliaOpt/NLopt.jl). Did you test the packages with the package manager? e.g., `(@1.5) pkg> test NLopt`

---

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [December 29, 2020, 10:48am UTC](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499/5 "2020-12-29T10:48:19Z")

</div>

> [@Emmanouil\_Bakirtzis](#):
>
> I am using JuMP v0.21.3 and NLopt v0.6.0

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

---

<div class="post-metadata">

**Author:** ![Emmanouil\_Bakirtzis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emmanouil_bakirtzis/32/11456_2.png) [@Emmanouil\_Bakirtzis](https://discourse.julialang.org/u/Emmanouil_Bakirtzis)\
**Post date:** [December 29, 2020, 4:55pm UTC](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499/6 "2020-12-29T16:55:48Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Emmanouil\_Bakirtzis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emmanouil_bakirtzis/32/11456_2.png) [@Emmanouil\_Bakirtzis](https://discourse.julialang.org/u/Emmanouil_Bakirtzis)\
**Post date:** [December 29, 2020, 4:57pm UTC](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499/7 "2020-12-29T16:57:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [December 30, 2020, 1:28am UTC](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499/8 "2020-12-30T01:28:01Z")

</div>

> [@Emmanouil\_Bakirtzis](#):
>
> 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 ?

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

```julia
(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`.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [December 30, 2020, 6:29am UTC](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499/9 "2020-12-30T06:29:30Z")

</div>

Or try `Ipopt`

---

<div class="post-metadata">

**Author:** ![Emmanouil\_Bakirtzis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emmanouil_bakirtzis/32/11456_2.png) [@Emmanouil\_Bakirtzis](https://discourse.julialang.org/u/Emmanouil_Bakirtzis)\
**Post date:** [January 4, 2021, 11:32pm UTC](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499/10 "2021-01-04T23:32:53Z")

</div>

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

```julia
(@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.

---

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [January 5, 2021, 12:32am UTC](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499/11 "2021-01-05T00:32:07Z")

</div>

What happens if you remove `VegaLite`?

```julia
Pkg.rm("VegaLite")
Pkg.update()

```

---

<div class="post-metadata">

**Author:** ![Emmanouil\_Bakirtzis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emmanouil_bakirtzis/32/11456_2.png) [@Emmanouil\_Bakirtzis](https://discourse.julialang.org/u/Emmanouil_Bakirtzis)\
**Post date:** [January 5, 2021, 2:55pm UTC](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499/12 "2021-01-05T14:55:23Z")

</div>

@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 !!
