Wednesday, 23 January 2013

AMPL Toolbox

Only ten years after writing the thing, I've finally got around to making the AMPL toolbox for Matlab available on the Mathworks File Exchange:

AMPL (see stands for "A Mathematical Programming Language" and allows optimization problems to be written in a language close to how you'd write in in equations.  It also takes care of a great deal of "housekeeping" tasks like enumerating variables and constraints over sets of indices.  To solve an optimization, the AMPL executable typically combines a model file, containing the structure of the problem in terms of symbolic variables and parameters, with a data file, containing parameter values, to create a binary "NL" file encoding the whole problem.  Then an external solver (e.g. CPLEX, Gurobi or IPOPT) is invoked to solve the problem in the NL file and report results back to AMPL.

The AMPL-Matlab toolbox contains a series of utilities for writing the AMPL data file from Matlab.  Since MATLAB can also read data back from AMPL easily (just redirect an AMPL "printf" command to a file and use "load" in Matlab), this means you can do the whole process of optimization and data analysis in Matlab scripts.  OK, all that file writing and reading isn't the fastest way of doing business, and if you know exactly what you want to deploy in anger, you'd do it differently.  But, if your business is in tinkering with the structure of the optimization and the algorithm, as ours is, this makes an excellent rapid prototyping tool.

We've used this approach in our work on robot navigation and flight routing, among many other things.