Main > Reference Manual > Extension modules > Linear programming solver module
This module implements a linear programming solver.
The solver is intended primarly for prototyping purposes. A linear programming model can quickly be built and validated in a generic way.
Important: This solver module is licensed under the GPL, which is different from the GLPL license normally used by frePPLe.
The module uses the "GNU Linear Programming Kit" library (aka GLPK) to solve the LP model
The solver works as follows:
- The solver expects a model file and a data file as input.
The model file represents the mathematical representation of the problem to solve. It can be edited to meet your specfic business problem.
The data file holds the data to be loaded into the problem. If no data file is specified, the data section in the model file is used instead.
The user needs to create these files. A convenient way to generate the data file is to use the Python module. See the unit test lp_solver1 for an example. - The solver solves for a number of objectives in sequence.
After solving an objective's optimal value, the solver freezes the objective value as a constraint and start for the next objective. Subsequent objectives can thus never yield a solution that is suboptimal for the previous objectives. - After solving for all objectives the solution is written to a solution file.
The user is responsible for all processing of this solution file. A convenient way is again to use the Python module.
The unit test lp_solver1 shows how a capacity allocation problem is solved with the module.
Different business problems will obviously require a different formulation.
Technical implementation
The module is based on the GLPK (GNU Linear Programming Kit) package. More information on the package can be found on http://www.gnu.org/software/glpk/glpk.html.
Go through the following steps for a typical usage of this solver:
- Load the Python and the LPsolver modules with commands as follows in the init.xml file:
frepple.loadmodule("mod_lp_solver.so")
- Copy your model file and Python code into your $FREPPLE_HOME directory.
Assume the function exportData is used for exporting the data file, and the function importSolution is used to read the solution file. - Export the data files, run the solver and import the solution with the following Python commands:
exportData("mymodel.dat") lp = frepple.solver_lp(loglevel=2, modelfile="mymodel.mod", datafile="mymodel.dat", solutionfile="mymodel.sol", minimum=True, objective=["column_name_1", "column_name_2", "column_name_3"]) lp.solve() importSolution("mymodel.sol")