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 selfexplanatory. 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
 Spring '09
 Meinolf
 Linear Programming, Optimization, CPLEX, Standard LP Solvers, LP Maximize obj, example LP ﬁle

Click to edit the document details