CS149-Notes-7-interfacing

CS149-Notes-7-interfacing - Interfacing with Standard LP...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Interfacing with Standard LP Solvers CS 149 Staff 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 file in the LP format. The following example LP file 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 files 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

{[ snackBarMessage ]}

Ask a homework question - tutors are online