Hooking your solver to AMPL
Every solver hooked to AMPL has its own interface program – called a solver driver — that sits between the AMPL application and the solver. Each invocation of the AMPL “solve” command uses the driver, in the following way:
2. The driver reads the nl format file, translates its contents to the forms required by the solver, and passes the problem to the solver by means of calls to the solver’s API.
3. The solver applies its methods to the problem, and when finished it passes a result back to the AMPL-solver interface.
4. The driver converts the solution back to the form that AMPL expects, and writes a simple file of results to be read by the AMPL application.
The nl format has equivalent binary and ASCII versions. It offers the flexibility needed to support a broad variety of linear and nonlinear solvers, and is designed to promote efficient reading and writing.
We maintain two AMPL-solver interface libraries, MP and ASL, that are freely available in source code for hooking your solver to AMPL.
MP is a C++ library that is designed for building efficient, simple-to-use, and highly configurable solver drivers. It provides type-safe and flexible interfaces suitable for linear and mixed-integer, nonlinear, and constraint programming solvers, and currently incorporates all features of the ASL C library (see below) for solvers not requiring automatic differentiation.
MP incorporates an extensive set of transformations for converting model expressions from natural formulations to forms that various solvers require. Mixed-integer linear quadratic solvers can take advantage of these transformations to support a variety of logical and nonlinear model expressions. An MP Modeling Guide details the forms that are accepted.
ASL is a C-language library for building solver drivers. It is the original AMPL driver library, and underlies the implementations of dozens of solver drivers.
ASL’s interface to nonlinear solvers is distinguished by its powerful features for supporting “local” nonlinear solvers that rely on function derivatives to provide fast convergence. Building upon standard features for computing 1st derivatives (objective gradients and constraint Jacobians), ASL is extended in two significant respects:
An overview and discussion of the implementation are also provided in two related technical reports by David Gay:
In the usual mode of operation, 1st and 2nd derivative values are provided to solvers automatically as part of the optimization process, while only the optimal solutions are returned to AMPL. For rare situations in which it is desired to view the derivative values or manipulate them in AMPL, a pseudo-solver gjh is available.
We offer a selection of the highest-quality solvers, interfaced to AMPL for full access to algorithms and options.