# AmplNLWriter with JuMP 0.21.2

**URL:** <https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545>\
**Category:** Optimization (Mathematical)\
**Created:** [May 1, 2020, 10:59am UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545 "2020-05-01T10:59:34Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![noamgold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/noamgold/32/14473_2.png) [@noamgold](https://discourse.julialang.org/u/noamgold)\
**Post date:** [May 1, 2020, 10:59am UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545/1 "2020-05-01T10:59:34Z")

</div>

How to use Couenne (using AmplNLWriter) following the recent changes to the JuMP interface.  
In particular I am trying

m = Model( () → AmplNLSolver(“couenne”) )

and I get the following error:

ERROR: LoadError: The provided `optimizer_constructor` returned an object of type AmplNLSolver. Expected a MathOptInterface.AbstractOptimizer.

---

<div class="post-metadata">

**Author:** ![hellemo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hellemo/32/324_2.png) [@hellemo](https://discourse.julialang.org/u/hellemo)\
**Post date:** [May 1, 2020, 12:36pm UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545/2 "2020-05-01T12:36:19Z")

</div>

```julia
using JuMP, AmplNLWriter
m = Model(()->AmplNLWriter.Optimizer(ENV["COUENNE_PATH"]))

```

works for me (I have the couenne path set as an environment variable).

---

<div class="post-metadata">

**Author:** ![noamgold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/noamgold/32/14473_2.png) [@noamgold](https://discourse.julialang.org/u/noamgold)\
**Post date:** [May 1, 2020, 12:42pm UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545/3 "2020-05-01T12:42:15Z")

</div>

> [@hellemo](#):
>
> ```julia
> m = Model(()->AmplNLWriter.Optimizer(ENV["COUENNE_PATH"]))
> 
> ```

This line no longer works for me (I had something similar working in a previous Julia / JuMP installation) - I get:

ERROR: LoadError: UndefVarError: Optimizer not defined

---

<div class="post-metadata">

**Author:** ![hellemo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hellemo/32/324_2.png) [@hellemo](https://discourse.julialang.org/u/hellemo)\
**Post date:** [May 1, 2020, 12:50pm UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545/4 "2020-05-01T12:50:47Z")

</div>

Weird, here is my installed versions of the relevant packages:

```julia
AmplNLWriter v0.6.0
JuMP v0.21.2
MathOptInterface v0.9.13

```

---

<div class="post-metadata">

**Author:** ![noamgold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/noamgold/32/14473_2.png) [@noamgold](https://discourse.julialang.org/u/noamgold)\
**Post date:** [May 1, 2020, 2:56pm UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545/5 "2020-05-01T14:56:25Z")

</div>

It is very strange indeed. Before I had AmplNLWriter 0.5.0. Now that I updated to 0.6.0 (JuMP 0.21.2, MathOptInterface 0.9.13) it I get:

ERROR: LoadError: The provided `optimizer_constructor` returned an object of type MathOptInterface.Utilities.UniversalFallback{AmplNLWriter.InnerModel{Float64}}. Expected a MathOptInterface.AbstractOptimizer.

My Julia version is 1.4.1

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [May 1, 2020, 3:23pm UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545/6 "2020-05-01T15:23:13Z")

</div>

You need to quit Julia and restart to load the new version of the package.

---

<div class="post-metadata">

**Author:** ![noamgold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/noamgold/32/14473_2.png) [@noamgold](https://discourse.julialang.org/u/noamgold)\
**Post date:** [May 2, 2020, 6:49am UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545/7 "2020-05-02T06:49:34Z")

</div>

Thank you both. It worked after restarting…

---

<div class="post-metadata">

**Author:** ![Luca](https://avatars.discourse-cdn.com/v4/letter/l/51bf81/32.png) [@Luca](https://discourse.julialang.org/u/Luca)\
**Post date:** [June 11, 2020, 10:47am UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545/8 "2020-06-11T10:47:01Z")

</div>

I have the same issue. I have tried both m = Model( () → AmplNLSolver(“couenne”) ) and m = Model( () → AmplNLWriter.Optimizer(“couenne”) ) but I get

**ERROR:** The provided `optimizer_constructor` returned an object of type AmplNLSolver. Expected a MathOptInterface.AbstractOptimizer.

**ERROR:** UndefVarError: Optimizer not defined

I have the latest version of Julia and all the package are updated.

Thanks very much for your help.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [June 11, 2020, 1:46pm UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545/9 "2020-06-11T13:46:50Z")

</div>

> all the package are updated.

Unfortunately, it looks like they aren’t. You need AmplNLWriter v0.6.0: [Release v0.6.0 · jump-dev/AmplNLWriter.jl · GitHub](https://github.com/JuliaOpt/AmplNLWriter.jl/releases/tag/v0.6.0)

Run the following, then report the output:

```Julia
import Pkg
Pkg.status()
] add AmplNLWriter@0.6

```

---

<div class="post-metadata">

**Author:** ![Luca](https://avatars.discourse-cdn.com/v4/letter/l/51bf81/32.png) [@Luca](https://discourse.julialang.org/u/Luca)\
**Post date:** [June 11, 2020, 1:54pm UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545/10 "2020-06-11T13:54:47Z")

</div>

**Status** `~/.julia/environments/v1.4/Project.toml`

[7c4d4715] AmplNLWriter v0.4.2  
[2f02e5f0] CouenneNL v0.0.0 #master ([https://github.com/rdeits/CouenneNL.jl](https://github.com/rdeits/CouenneNL.jl))  
[60bf3e95] GLPK v0.13.0  
[4076af6c] JuMP v0.21.2

**(@v1.4) pkg\>** add AmplNLWriter@0.6

**Updating** registry at `~/.julia/registries/General`  
**Updating** git-repo `https://github.com/JuliaRegistries/General.git`  
**Resolving** package versions…

**ERROR:** Unsatisfiable requirements detected for package AmplNLWriter [7c4d4715]:  
AmplNLWriter [7c4d4715] log:  
├─possible versions are: [0.4.2, 0.5.0, 0.6.0] or uninstalled  
├─restricted to versions 0.4 by CouenneNL [2f02e5f0], leaving only versions 0.4.2  
│ └─CouenneNL [2f02e5f0] log:  
│ ├─possible versions are: 0.0.0 or uninstalled  
│ └─CouenneNL [2f02e5f0] is fixed to version 0.0.0  
└─restricted to versions 0.6 by an explicit requirement — no versions left

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [June 11, 2020, 2:01pm UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545/11 "2020-06-11T14:01:20Z")

</div>

You cannot use `CouenneNL` with the latest version of AMPLNLwriter.

You can download the Couenne binary directly from here: [Open Source Solvers - AMPLAMPL](https://ampl.com/products/solvers/open-source/)

---

<div class="post-metadata">

**Author:** ![Luca](https://avatars.discourse-cdn.com/v4/letter/l/51bf81/32.png) [@Luca](https://discourse.julialang.org/u/Luca)\
**Post date:** [June 11, 2020, 2:13pm UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545/12 "2020-06-11T14:13:31Z")

</div>

Thanks. I have downloaded couenne. but I have still ERROR: LoadError: UndefVarError: Optimizer not defined when I use global model = Model(() → AmplNLWriter.Optimizer(“./couenne”))

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [June 11, 2020, 2:17pm UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545/13 "2020-06-11T14:17:00Z")

</div>

You need to remove `CouenneNL`, then update:

```nohighlight
] rm CouenneNL
] up

```

Then you need to exit Julia, and restart a new session to load the fresh code.

---

<div class="post-metadata">

**Author:** ![Luca](https://avatars.discourse-cdn.com/v4/letter/l/51bf81/32.png) [@Luca](https://discourse.julialang.org/u/Luca)\
**Post date:** [June 11, 2020, 2:24pm UTC](https://discourse.julialang.org/t/amplnlwriter-with-jump-0-21-2/38545/14 "2020-06-11T14:24:26Z")

</div>

Now it works perfectly. Thanks so much.
