Difference between revisions of "ApCoCoA-1:GLPK.LPSolve"

From ApCoCoAWiki
m (added version info)
 
(65 intermediate revisions by 9 users not shown)
Line 1: Line 1:
 +
{{Version|1|[[Package glpk/GLPK.LPSolve]]}}
 
<command>
 
<command>
<title>LPSolve</title>
+
<title>GLPK.LPSolve</title>
<short_description>solve linear programms</short_description>
+
<short_description>Solving linear programmes.</short_description>
 
<syntax>
 
<syntax>
GLPK.LPSolv(Polynome:LIST, TrennInt:LIST, Bounds:LIST, Methode:STRING, MinMax:STRING)
+
GLPK.LPSolve(Objective_f:POLY, EQ_Poly:LIST, LE_Poly:LIST, GE_Poly:LIST, Bounds:LIST, Method:STRING, MinMax:STRING):LIST
 
</syntax>
 
</syntax>
 
<description>
 
<description>
 +
<em>Please note:</em> The function(s) explained on this page is/are using the <em>ApCoCoAServer</em>. You will have to start the ApCoCoAServer in order to use it/them.
 +
 +
<itemize>
 +
<item>@param <em>Objective_f</em>: A linear polynomial which is equivalent to the linear objective function.</item>
 +
<item>@param <em>EQ_Poly</em>: List of linear polynomials, which are equivalent to the equality-part in the list of conditions.</item>
 +
<item>@param <em>LE_Poly</em>: List of linear polynomials, which are equivalent to the lower or equal-part in the list of conditions.</item>
 +
<item>@param <em>GE_Poly</em>: List of linear polynomials, which are equivalent to the greater or equal-part in the list of conditions.</item>
 +
<item>@param <em>Bounds</em>: List of lists with two elements. Each List contains the lower and upper bounds for each variable. You can choose between INT or RAT for the type of each bound, if you type in a (empty) string, then it means minus infinity (first place) or plus infinity (second place).</item>
 +
<item>@param <em>Method</em>: You can choose between the interior-point-method ("InterP") or the simplex-algorithm ("Simplex"). Usually you should use the simplex-algorithm.</item>
 +
<item>@param <em>MinMax</em>:  Minimization ("Min") or maximization ("Max"), that's the question.</item>
 +
<item>@return List of linear polynomials, the zeros of the polynomials are the points where the optimal value of the objective function is achieved</item>
 +
</itemize>
  
 
<example>
 
<example>
<em>Linear programming example 1996 MBA exam</em>
+
-- We want to maximize the Function y = - 1/2x,
 
+
-- with the two conditions y ≤ 6 - 3/4x and y ≥ 1 - x and the bounds 0 ≤ x ≤ 6 and 1/3 ≤ y ≤ 4.
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
+
-- We prename the input of GLPK.LPSolve-function.
proportion of that compartment's weight capacity to maintain the balance of the plane.
+
Use S::=QQ[x,y];
 +
OF := 1/2x + y;
 +
LE := [3/4x + y - 6];
 +
GE := [x + y - 1];
 +
Bounds:=[[0,6], [1/3,4]];
  
The following four cargoes are available for shipment on the next flight:
+
-- Then we compute the solution with
 +
GLPK.LPSolve(OF, [], LE, GE, Bounds, "Simplex", "Max");
  
Cargo  Weight (tonnes)  Volume (cubic metres/tonne)  Profit (£/tonne)
+
-- And we achieve:
C1      18                480                          310
+
-------------------------------------
C2      15                650                          380
+
Solution Status: OPTIMAL
C3      23                580                          350
+
Value of objective function: 5333333333/1000000000
C4      12                390                          285
+
[x - 266667/100000, y - 4]
 
 
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.
 
 
</example>
 
</example>
 
To solve this problem we had to compose a linear program.
 
  
 
</description>
 
</description>
 
 
<types>
 
<types>
   <type>cocoaserver</type>
+
   <type>apcocoaserver</type>
 +
  <type>linear_programs</type>
 
</types>
 
</types>
 +
<see>ApCoCoA-1:Latte.Minimize|Latte.Minimize</see>
 +
<see>ApCoCoA-1:Latte.Maximize|Latte.Maximize</see>
 +
 
<key>lpsolve</key>
 
<key>lpsolve</key>
<key>solve linear programm</key>
+
<key>solve linear program</key>
 
<key>solve lp</key>
 
<key>solve lp</key>
<key>jbrandt</key>
+
<key>GLPK.LPSolve</key>
<key>skuehling</key>
+
<wiki-category>ApCoCoA-1:Package_glpk</wiki-category>
<wiki-category>Package_GLPK</wiki-category>
 
 
</command>
 
</command>

Latest revision as of 15:12, 1 November 2020

This article is about a function from ApCoCoA-1. If you are looking for the ApCoCoA-2 version of it, see Package glpk/GLPK.LPSolve.

GLPK.LPSolve

Solving linear programmes.

Syntax

GLPK.LPSolve(Objective_f:POLY, EQ_Poly:LIST, LE_Poly:LIST, GE_Poly:LIST, Bounds:LIST, Method:STRING, MinMax:STRING):LIST

Description

Please note: The function(s) explained on this page is/are using the ApCoCoAServer. You will have to start the ApCoCoAServer in order to use it/them.

  • @param Objective_f: A linear polynomial which is equivalent to the linear objective function.

  • @param EQ_Poly: List of linear polynomials, which are equivalent to the equality-part in the list of conditions.

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

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

  • @param Bounds: List of lists with two elements. Each List contains the lower and upper bounds for each variable. You can choose between INT or RAT for the type of each bound, if you type in a (empty) string, then it means minus infinity (first place) or plus infinity (second place).

  • @param Method: You can choose between the interior-point-method ("InterP") or the simplex-algorithm ("Simplex"). Usually you should use the simplex-algorithm.

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

  • @return List of linear polynomials, the zeros of the polynomials are the points where the optimal value of the objective function is achieved

Example

-- We want to maximize the Function y = - 1/2x, 
-- with the two conditions y ≤ 6 - 3/4x and y ≥ 1 - x and the bounds 0 ≤ x ≤ 6 and 1/3 ≤ y ≤ 4.

-- We prename the input of GLPK.LPSolve-function.
Use S::=QQ[x,y];
OF := 1/2x + y;
LE := [3/4x + y - 6];
GE := [x + y - 1];
Bounds:=[[0,6], [1/3,4]];

-- Then we compute the solution with
GLPK.LPSolve(OF, [], LE, GE, Bounds, "Simplex", "Max");

-- And we achieve:
------------------------------------- 
Solution Status: OPTIMAL
Value of objective function: 5333333333/1000000000
[x - 266667/100000, y - 4]


Latte.Minimize

Latte.Maximize