# Quick Start lp_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_solve Basically, 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 API Via input files Via an IDE #### Via the API The 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 files Standard, 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. There is also a driver program called lp_solve that uses the API to provide a command line application to solve models. See lp_solve 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 via file to the program and it will solve the model and give you the result. #### Via an IDE Thanks 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 Mixed Integer Linear Programming (MILP) solver Basically no limit on model size It is free and with sources Supports Integer variables, Semi-continuous variables and Special Ordered Sets Can read model from MPS, LP or user written format Models can be build in-memory without the use of files Has a powerful API interface Easy callable from other programming languages Advanced pricing using Devex and Steepest Edge for both primal and dual simplexes Provides different scaling methods to make the model more numerical stable Has presolve capabilities to tighten constraints/make the model smaller and faster to solve Has a base crashing routine to determine a starting point Allows restart after making changes to the model. Solve continues from the last found solution Possible to select desired combinations of primal and dual phases 1 and 2 Possible to set several solver parameters like tolerances Alternative (and faster) inverse/re-factorisation libraries are provided for. See Basis Factorization Packages Alternative model readers and writers possible via the XLI implementation. See External Language Interfaces Has the possibility to convert one model format to another format Provides post-optimal sensitivity analysis. See Sensitivity ... ### Quick quick start #### Formulating a problem If 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 IDE The 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 program Another 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 API Programmers 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 yourself The 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 Packages Alternative 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.0_bfp_*_source.tar.gz archives. The binaries are in the lp_solve_5.5.2.0_exe* archive. #### External Language Interfaces Alternative 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.0_xli_*_source.tar.gz archives. The binaries are in the lp_solve_5.5.2.0_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.