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.
If you need help, please ask a question on the JuMP community forum.
If you have a reproducible example of a bug, please open a GitHub issue.
Install AmplNLWriter using Pkg.add:
import Pkg
Pkg.add("AmplNLWriter")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"))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 | 
| KNITRO | KNITRO.jl | KNITRO.amplexe | 
The AmplNLWriter optimizer supports the following constraints and attributes.
List of supported objective functions:
- MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}
- MOI.ObjectiveFunction{MOI.ScalarNonlinearFunction}
- MOI.ObjectiveFunction{MOI.ScalarQuadraticFunction{Float64}}
- MOI.ObjectiveFunction{MOI.VariableIndex}
List of supported variable types:
List of supported constraint types:
- MOI.ScalarAffineFunction{Float64}in- MOI.EqualTo{Float64}
- MOI.ScalarAffineFunction{Float64}in- MOI.GreaterThan{Float64}
- MOI.ScalarAffineFunction{Float64}in- MOI.Interval{Float64}
- MOI.ScalarAffineFunction{Float64}in- MOI.LessThan{Float64}
- MOI.ScalarNonlinearFunctionin- MOI.EqualTo{Float64}
- MOI.ScalarNonlinearFunctionin- MOI.GreaterThan{Float64}
- MOI.ScalarNonlinearFunctionin- MOI.Interval{Float64}
- MOI.ScalarNonlinearFunctionin- MOI.LessThan{Float64}
- MOI.ScalarQuadraticFunction{Float64}in- MOI.EqualTo{Float64}
- MOI.ScalarQuadraticFunction{Float64}in- MOI.GreaterThan{Float64}
- MOI.ScalarQuadraticFunction{Float64}in- MOI.Interval{Float64}
- MOI.ScalarQuadraticFunction{Float64}in- MOI.LessThan{Float64}
- MOI.VariableIndexin- MOI.EqualTo{Float64}
- MOI.VariableIndexin- MOI.GreaterThan{Float64}
- MOI.VariableIndexin- MOI.Integer
- MOI.VariableIndexin- MOI.Interval{Float64}
- MOI.VariableIndexin- MOI.LessThan{Float64}
- MOI.VariableIndexin- MOI.ZeroOne
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)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