Quick Startlp_solve (or lpsolve) has allot of features in-house. For a beginner, it can be difficult to determine where to start. The distribution contains many files and to start with, you need only a couple of them. As you learn the package you may need extras. This text explains how to start with lp_solve. Skip the blabla, just give me a very quick start.How to call lp_solveBasically, lp_solve is a library, a set of routines, called the API that can be called from almost any programming language to solve MILP problems. There are several ways to pass the data to the library:
Via the APIThe API is a set of routines that can be called from a programming language to build the model in memory, solve it and return the results. There are many API routines to perform many possible tasks and set several options. See lp_solve API reference for an overview.Via input filesStandard, lp_solve supports several input files types.
The common known MPS format (see mps-format) is supported by most solvers, but
it is not very readable for humans. Another format is the lp format (see lp-format)
that is more readable. lp_solve has the unique ability to use user-written routines to input the model
(see External Language Interface).
See read_mps, read_freemps, read_MPS, read_freeMPS and read_lp, read_LP for
the API calls to read the model from file. Via an IDEThanks to Henri Gourvest, there is now also an IDE program called LPSolve IDE that uses the API to provide a Windows application to solve models. See LPSolve IDE for its usage. With this program you don't have to know anything of API or computer programming languages. You can just provide your model to the program and it will solve the model and give you the result. As already stated, lp_solve can be called from many programming language. Among them are C, C++, Pascal, Delphi, Java, VB, C#, VB.NET, Excel. But let this list not be a limitation. Any programming language capable of calling external libraries (DLLs under Windows, Shared libraries (.so) under Unix/Linux) can call lp_solve. Some key features of lp_solve
Quick quick startFormulating a problemIf you don't know much about linear programming, first take a look at Formulation of an lp problem in lpsolve. Start with reading the first part where a practical example is presented until the point where the formulation is given in mathematical format, then return to here. This practical example is used in the next presentations. Another very usefull and free paper about linear programming fundamentals and advanced features plus several problems being discussed and modeled is Applications of optimization with Xpress-MP. It describes linear programming and modeling with the commercial solver Xpress-MP, but is as usefull for other solvers like lp_solve. In case that this link would not work anymore, try this via google search. Solve a problem via the IDEThe easiest way to start with lp_solve is via the IDE. This only works under Windows. See LPSolve IDE. Solve a problem via the lp_solve command line programAnother way to solve a model is via the lp_solve command line program. This works on any platform, but is completely command-line driven. Well known by Unix/Linux shell programmers and DOS box users. See lp_solve command. solve a problem via the APIProgrammers want to call lp_solve in a totally different way. They want to call lp_solve as a library directly from their programming language. This is what is called the API (Application Programming Interface). See Calling the lpsolve API from your application and Construct the model from a Programming Language. An overview of the complete API can be found on: lp_solve API reference. Compile the source code yourselfThe distribution contains precompiled libraries/binaries for Windows and Linux. However lp_solve can be compiled on other platforms also. You may also to make modifications to it and then you have to recompile also, even on the precompiled platforms. See Calling the lpsolve API from your application. In this article it is both explained how to link your code to the library and how to compile the lp_solve code. Basis Factorization PackagesAlternative inverse/re-factorization libraries can be used by lp_solve. This is a feature for the more experienced users of lp_solve. See Basis Factorization Packages for more information. The sources of these packages are in the lp_solve_5.5.2.5_bfp_*_source.tar.gz archives. The binaries are in the lp_solve_5.5.2.5_exe* archive. External Language InterfacesAlternative model readers and writers possible via the XLI implementation. Models expressed in format files other than lp or MPS format can also be read or written by lp_solve via this unique feature. See External Language Interfaces for more information. The sources of these packages are in the lp_solve_5.5.2.5_xli_*_source.tar.gz archives. The binaries are in the lp_solve_5.5.2.5_exe* archive. Calling lp_solve from higher level Mathematical languages.lp_solve can be called from AMPL, MATLAB, O-Matrix, Sysquake, Scilab, Octave, FreeMat, Euler, Python, Sage, PHP, R, Microsoft Solver Foundation.You now have a pretty good idea what lp_solve is about. |