From ApCoCoAWiki
Revision as of 17:17, 12 November 2008 by StK (talk | contribs)


solve linear programms


GLPK.LPSolv(Objective_Function:POLYNOM, EQ_Polynomials:LIST, LE_Polynomials:LIST, GE_Polynomials:LIST, Bounds:LIST, Methode:STRING, MinMax:STRING)


The basic idea behind this package is to make the linear optimization program GLPK usable in/with ApCoCoA.

The package GLPK contains various functions that let you make use of the GLPK library, rather the stand-alone LP/MIP Solver glpsol.

Objective_Function: A linear polynomial which is equivalent to the linear objective Function.

EQ_Polynomials: List of linear polynomials, which are equivalent to the equality-part in the list of conditions.

LE_Polynomials: List of linear polynomials, which are equivalent to the lower or equal-part in the list of conditions.

GE_Polynomials: List of linear polynomials, which are equivalent to the greater or equal-part in the list of conditions.

Bounds: List of lists with two elements. Each List contains the lower and upper bounds for each variable.

Methode: You can choose between the inner-point-method (InnerP) or the simplex-algorithm (Simplex).

MinMax: Minimization (Min) or maximization (Max), that's the question.

When you execute the package, you had to specify the path of the LP solver "glpsol", i.e. GlpsolPath:="/usr/bin/";

and the working path, i.e. WorkingPath:="/home/user/";


<em>Linear programming example 1996 MBA exam</em>

A cargo plane has three compartments for storing cargo: front, centre and rear. 
These compartments have the following limits on both weight and space:

Compartment   Weight capacity (tonnes)   Space capacity (cubic metres)
Front         10                         6800
Centre        16                         8700
Rear          8                          5300

Furthermore, the weight of the cargo in the respective compartments must be the same 
proportion of that compartment's weight capacity to maintain the balance of the plane.

The following four cargoes are available for shipment on the next flight:

Cargo   Weight (tonnes)   Volume (cubic metres/tonne)  Profit (£/tonne)
C1      18                480                          310
C2      15                650                          380
C3      23                580                          350
C4      12                390                          285

Any proportion of these cargoes can be accepted. The objective is to determine how much 
(if any) of each cargo C1, C2, C3 and C4 should be accepted and how to distribute each 
among the compartments so that the total profit for the flight is maximised. 

To solve this problem we had to compose a linear program.