License Portal

Search
Close this search box.

Hooking your solver to AMPL

Developing a new solver? Hook it to AMPL using our open-source interfaces.

AMPL's communication with solvers

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:

1. The AMPL application combines model and data to produce a problem instance in memory, then writes out a representation of the problem instance to a file in nl format.

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.

The MP AMPL-solver interface library

About

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.

Getting Started

To get started using MP, see the MP documentation Contents page. Source code and sample drivers are available from the GitHub MP repository.

The ASL AMPL-solver library

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.

Interface to nonlinear solvers

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:

  • Automatic recognition of partial separability. A nonlinear function can be recognized as a sum of terms that each depend on only a few variables (possibly after a linear change of variables).
  • Computation of Hessians. Elements of the matrix of 2nd derivatives can be computed in a range of forms. Partial separability can be exploited to speed the computations.

Technical Reports

More Information

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.

Getting Started

ASL is described and illustrated in Hooking Your Solver to AMPL. Source code, compilation instructions, and sample drivers are available from the GitHub ASL repository.

Explore all solvers for AMPL

We offer a selection of the highest-quality solvers, interfaced to AMPL for full access to algorithms and options.