This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Interfacing with Standard LP Solvers
CS 149 Staﬀ October 1, 2006 Unless you decide to work for a company like ILOG there is no need to actually write a linear programming solver. Instead, you simply need to pass the linear program to a standard solver which will then solve it for you. One good option is to express your linear program as a text ﬁle in the LP format. The following example LP ﬁle is adapted from /com/cplex/cplex101/examples/data/qpex.lp. Problem Sample LP Maximize obj: x1 + 2 x2 + 3 x3 Subject To c1: - x1 + x2 + x3 <= 20 c2: x1 - 3 x2 + x3 = 30 Bounds 0 <= x1 <= 40 End This format is pretty self-explanatory. One nonobvious feature is that if you don’t give the bound for a variable it defaults to nonnegative. If you have a lot of LPs to solve creating and deleting ﬁles is tedious and slow. A better way is to use the C++ interface to CPLEX. This interface allows you to create variables, combine them using +, -, ¡= etc. to form objectives and constraints, and then add them to the model. See examples such as /com/cplex/cplex101/examples/src/ilodiet.cpp. There are also CPLEX interfaces for C and Java. 1 ...
View Full Document
This note was uploaded on 11/03/2009 for the course CS CS 149 taught by Professor Meinolf during the Spring '09 term at Sanford-Brown College.
- Spring '09