LP is one of the most popular formats for explicit description of an optimization model (the other contender being MPS). It uses an algebraic format where you enter the problem’s objective function and constraints line by line. For the last few years I’ve been using that format quite regularly, and I’d say I both hate and like it. Here is an example taken from the LPSolve documentation:
- LP file format is really easy to read and write.
- Most mathematical programming solvers are able to read the format (but see con’s below).
- The format’s syntax is a bit fuzzy. Each solver has its own implementation. For instance, CPLEX allows you to omit spaces between coefficients and variables (as in 2X_4) whereas in Gurobi you have to put a space (2 X_4). CPLEX and Gurobi allow unnamed constraints, while Sulum requires you to name each constraint.
- Large models equals very large files, especially when compared to more compact formats such as AMPL.
Uses for LP files
I use LP files for three things, mostly:
- Toy models. It’s really easy and quick to write LP files. If a model is small enough to be written by hand, I’ll use LP.
- Prototyping. The format is quite easy to write and read, and errors (especially programming errors) are easier to find.
- Sharing models. Since I usually code a LP formulation for most models I create as part of the debugging process, I use the same files when sharing my models with other people.
What do you use LP files for?