TRY NOW!
AMPL > >Resources > >Hooking your solver to AMPL

HOOKING YOUR SOLVER TO AMPL

AMPL has a publicly documented interface that you can use to make your own link to any solver you are developing. The interface works through files; AMPL writes a “.nl” problem file to be read by your solver, and your solver writes a “.sol” solution file to be read back by AMPL. The file format has equivalent binary and ASCII versions. It offers the flexibility needed to support a wide variety of solvers, yet is designed to afford very efficient reading and writing.

The AMPL interface is described and illustrated in Hooking Your Solver to AMPLa guide that you can view in PDF.

You can also download standard interface routines (in the C programming language) for reading and writing the AMPL file formats, along with a variety of examples:

  • All sample files cited in the “Hooking” report, and related sample input and output files.
  • Source code, makefiles and instructions for compiling AMPL/solver links to CPLEX, Gurobi, LOQO, MINOS, SNOPT, Xpress and other solvers.
  • Source for nlc, a program that converts AMPL “.nl” problem files to C or Fortran 77.

See our solvers page for a detailed list of solvers that have already been hooked to AMPL.

Enhanced support for nonlinear solvers

The AMPL interface to nonlinear solvers is distinguished by its powerful features for providing derivative values to solvers. Common modeling language features for computing gradients and Jacobians are 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.

All of these features are documented in the latest versions of Hooking Your Solver to AMPL, described above. 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. Available components of gjh include instructions for use, source code, and binaries for Windows, Linux, and Mac OS X.