AmplNLWriter with JuMP 0.21.2

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.

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

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

1 Like

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

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

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

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

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

2 Likes

Thank you both. It worked after restarting…

1 Like

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.

all the package are updated.

Unfortunately, it looks like they aren’t. You need AmplNLWriter v0.6.0: https://github.com/JuliaOpt/AmplNLWriter.jl/releases/tag/v0.6.0

Run the following, then report the output:

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

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

[7c4d4715] AmplNLWriter v0.4.2
[2f02e5f0] CouenneNL v0.0.0 #master (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

You cannot use CouenneNL with the latest version of AMPLNLwriter.

You can download the Couenne binary directly from here: https://ampl.com/products/solvers/open-source/

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

You need to remove CouenneNL, then update:

] rm CouenneNL
] up

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

Now it works perfectly. Thanks so much.