Build Status MINLPTests codecov

AmplNLWriter.jl is an interface between MathOptInterface.jl and AMPL-enabled solvers.


This wrapper is maintained by the JuMP community and has no official connection with the AMPL modeling language or AMPL Optimization Inc.


Install AmplNLWriter using Pkg.add:

import Pkg

Use with JuMP

AmplNLWriter requires an AMPL compatible solver binary to function.

Pass a string pointing to any AMPL-compatible solver binary as the first positional argument to AmplNLWriter.

For example, if the bonmin executable is on the system path, use:

using JuMP, AmplNLWriter
model = Model(() -> AmplNLWriter.Optimizer("bonmin"))

If the solver is not on the system path, pass the full path to the solver:

using JuMP, AmplNLWriter
model = Model(() -> AmplNLWriter.Optimizer("/Users/Oscar/ampl.macos64/bonmin"))

Precompiled binaries

To simplify the process of installing solver binaries, a number of Julia packages provide precompiled binaries that are compatible with AmplNLWriter. These are generally the name of the solver, followed by _jll. For example, bomin is provided by the Bonmin_jll package.

To call Bonmin via AmplNLWriter.jl, install the Bonmin_jll package, then run:

using JuMP, AmplNLWriter, Bonmin_jll
model = Model(() -> AmplNLWriter.Optimizer(Bonmin_jll.amplexe))

Supported packages include:

Solver Julia Package Executable
Bonmin Bonmin_jll.jl Bomin_jll.amplexe
Couenne Couenne_jll.jl Couenne_jll.amplexe
Ipopt Ipopt_jll.jl Ipopt_jll.amplexe
SHOT SHOT_jll.jl SHOT_jll.amplexe

MathOptInterface API

The AmplNLWriter optimizer supports the following constraints and attributes.

List of supported objective functions:

List of supported variable types:

List of supported constraint types:

List of supported model attributes:

Note that some solver executables may not support the full list of constraint types. For example, Ipopt_jll does not support MOI.Integer or MOI.ZeroOne constraints.


A list of available options for each solver can be found here:

Set an option using set_attribute. For example, to set the "bonmin.nlp_log_level" option to 0 in Bonmin, use:

using JuMP
import AmplNLWriter
import Bonmin_jll
model = Model(() -> AmplNLWriter.Optimizer(Bonmin_jll.amplexe))
set_attribute(model, "bonmin.nlp_log_level", 0)

opt files

Some options need to be specified via an .opt file.

This file must be located in the current working directory whenever the model is solved.

The .opt file must be named after the name of the solver, for example, bonmin.opt, and each line must contain an option name and the desired value, separated by a space.

For example, to set the absolute and relative tolerances in Couenne to 1 and 0.05 respectively, the couenne.opt file should contain:

allowable_gap 1
allowable_fraction_gap 0.05