http://apcocoa.uni-passau.de/wiki/api.php?action=feedcontributions&user=91.40.215.137&feedformat=atomApCoCoAWiki - User contributions [en]2024-03-28T14:45:38ZUser contributionsMediaWiki 1.35.0http://apcocoa.uni-passau.de/wiki/index.php?title=ApCoCoA-1:GLPK.MIPSolve&diff=8026ApCoCoA-1:GLPK.MIPSolve2008-12-20T16:04:29Z<p>91.40.215.137: </p>
<hr />
<div><command><br />
<title>LPSolve</title><br />
<short_description>solve linear programms</short_description><br />
<syntax><br />
GLPK.MIPSolve(Objective_f:POLYNOM, EQ_Poly:LIST, LE_Poly:LIST, GE_Poly:LIST, Bounds:LIST, IntNum:LIST, Binaries:LIST, MinMax:STRING)<br />
</syntax><br />
<description><br />
{{ApCoCoAServer}}<br />
<br />
<em>Objective_f</em>: A linear polynomial which is equivalent to the linear objective function.<br />
<br />
<em>EQ_Poly</em>: List of linear polynomials, which are equivalent to the equality-part in the list of conditions.<br />
<br />
<em>LE_Poly</em>: List of linear polynomials, which are equivalent to the lower or equal-part in the list of conditions.<br />
<br />
<em>GE_Poly</em>: List of linear polynomials, which are equivalent to the greater or equal-part in the list of conditions.<br />
<br />
<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).<br />
<br />
<em>IntNum</em>: List of variables, which should be integer. <em>Note</em>: For each variable in this list, the borders get rounded (lower bound: up and upper bound: down). In the case that the lower rounded bound becomes greater then the upper rounded bound, glpk returns: Solution Status: INTEGER UNDEFINED - Value of objective function: 0.<br />
<br />
<em>Binaries</em>: List of variables, which should be binaries (0 or 1).<br />
<br />
<em>MinMax</em>: Minimization ("Min") or maximization ("Max"), that's the question.<br />
<br />
<br />
First we want to discuss a rather easy example. <br />
<example><br />
We want to maximize the Function y = - 1/2x, <br />
with the two conditions y ≤ 6 - 3/4x and y ≥ 1 - x and the bounds 0 ≤ x ≤ 6 and 1/3 ≤ y ≤ 4.<br />
<br />
We prename the input of GLPK.MIPSolve-function.<br />
Use S::=Q[x,y];<br />
OF := 1/2x + y;<br />
LE := [3/4x + y - 6];<br />
GE := [x + y - 1];<br />
Bounds:=[[0,6], [1/3,4]];<br />
IntNum:=[x,y];<br />
<br />
Then we compute the solution with<br />
$GLPK.MIPSolve(OF, [], LE, GE, Bounds, IntNum, [], "Max");<br />
<br />
<br />
And we achieve:<br />
Solution Status: INTEGER OPTIMAL<br />
Value of objective function: 5<br />
[x[1] - 2, x[2] - 4]<br />
</example><br />
<br />
[[Image:LinOpt_2.jpg]]<br />
<br />
<br />
<br />
<example><br />
''Linear programming example 1996 MBA exam''<br />
<br />
A cargo plane has three compartments for storing cargo: front, centre and rear. <br />
These compartments have the following limits on both weight and space:<br />
<br />
Compartment Weight capacity (tonnes) Space capacity (cubic metres)<br />
Front 10 6800<br />
Centre 16 8700<br />
Rear 8 5300<br />
<br />
Furthermore, the weight of the cargo in the respective compartments must be the same <br />
proportion of that compartment's weight capacity to maintain the balance of the plane.<br />
<br />
The following four cargoes are available for shipment on the next flight:<br />
<br />
Cargo Weight (tonnes) Volume (cubic metres/tonne) Profit (£/tonne)<br />
C1 18 480 310<br />
C2 15 650 380<br />
C3 23 580 350<br />
C4 12 390 285<br />
<br />
Any proportion of these cargoes can be accepted. The objective is to determine how much <br />
(if any) of each cargo C1, C2, C3 and C4 should be accepted and how to distribute each <br />
among the compartments so that the total profit for the flight is maximised. <br />
<br />
<br />
To solve this problem we had to compose a linear program.<br />
<br />
Variables<br />
<br />
We need to decide how much of each of the four cargoes to put in each of the three compartments. <br />
Hence let:<br />
<br />
xij be the number of tonnes of cargo i (i=1,2,3,4 for C1, C2, C3 and C4 respectively) that is put into <br />
compartment j (j=1 for Front, j=2 for Centre and j=3 for Rear) where xij >=0 i=1,2,3,4; j=1,2,3<br />
<br />
Note here that we are explicitly told we can split the cargoes into any proportions (fractions) that we like.<br />
<br />
Constraints<br />
<br />
* cannot pack more of each of the four cargoes than we have available<br />
<br />
x11 + x12 + x13 ≤ 18<br />
x21 + x22 + x23 ≤ 15<br />
x31 + x32 + x33 ≤ 23<br />
x41 + x42 + x43 ≤ 12<br />
<br />
* the weight capacity of each compartment must be respected<br />
<br />
x11 + x21 + x31 + x41 ≤ 10<br />
x12 + x22 + x32 + x42 ≤ 16<br />
x13 + x23 + x33 + x43 ≤ 8<br />
<br />
* the volume (space) capacity of each compartment must be respected<br />
<br />
480x11 + 650x21 + 580x31 + 390x41 ≤ 6800<br />
480x12 + 650x22 + 580x32 + 390x42 ≤ 8700<br />
480x13 + 650x23 + 580x33 + 390x43 ≤ 5300<br />
<br />
* the weight of the cargo in the respective compartments must be the same proportion <br />
of that compartment's weight capacity to maintain the balance of the plane<br />
<br />
[x11 + x21 + x31 + x41]/10 = [x12 + x22 + x32 + x42]/16 = [x13 + x23 + x33 + x43]/8<br />
<br />
Objective<br />
<br />
The objective is to maximise total profit, i.e.<br />
<br />
maximise 310[x11+ x12+x13] + 380[x21+ x22+x23] + 350[x31+ x32+x33] + 285[x41+ x42+x43]<br />
<br />
The basic assumptions are:<br />
<br />
* that each cargo can be split into whatever proportions/fractions we desire<br />
* that each cargo can be split between two or more compartments if we so desire<br />
* that the cargo can be packed into each compartment (for example if the cargo was spherical it would <br />
not be possible to pack a compartment to volume capacity, some free space is inevitable in sphere packing)<br />
* all the data/numbers given are accurate<br />
<br />
<br />
In ApCoCoa you can solve this LP like this:<br />
<br />
Use S::= Q[x[1..4,1..3]];<br />
<br />
Objective := 310*(x[1,1]+x[1,2]+x[1,3])+310*(x[2,1]+x[2,2]+x[2,3])+350*(x[3,1]+x[3,2]+x[3,3])+285*(x[4,1]+x[4,2]+x[4,3]);<br />
Balance := [16(x[1,1]+x[2,1]+x[3,1]+x[4,1])-10(x[1,2]+x[2,2]+x[3,2]+x[4,2]), 8(x[1,2]+x[2,2]+x[3,2]+x[4,2])-16(x[1,3]+x[2,3]+x[3,3]+x[4,3])];<br />
<br />
Available := [x[1,1]+x[1,2]+x[1,3]-18, x[2,1]+x[2,2]+x[2,3]-15, x[3,1]+x[3,2]+x[3,3]-23, x[4,1]+x[4,2]+x[4,3]-12];<br />
Weight := [x[1,1]+x[2,1]+x[3,1]+x[4,1]-10, x[1,2]+x[2,2]+x[3,2]+x[4,2]-16, x[1,3]+x[2,3]+x[3,3]+x[4,3]-8];<br />
Volume := [480x[1,1]+650x[2,1]+580x[3,1]+390x[4,1]-6800, 480x[1,2]+650x[2,2]+580x[3,2]+390x[4,2]-8700, 480x[1,3]+650x[2,3]+580x[3,3]+390x[4,3]-5300];<br />
LessEq := Flatten([Available, Weight, Volume]);<br />
<br />
Bounds := [[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""]];<br />
<br />
IntNum:=[x[1,2], x[1,3]];<br />
<br />
$GLPK.MIPSolve(Objective, Balance, LessEq, [], Bounds, IntNum, [], "Max");<br />
<br />
<br />
And we receive:<br />
Solution Status: INTEGER OPTIMAL<br />
Value of objective function: 11460<br />
[x[1,1], x[1,2] - 8, x[1,3], x[2,1], x[2,2] - 3, x[2,3], x[3,1] - 10, x[3,2] - 5, x[3,3] - 8, x[4,1], x[4,2], x[4,3]]<br />
<br />
This means <br />
* in the front we put<br />
- 0 of cargo one (x[1,1] = 0)<br />
- 0 of cargo two (x[2,1] = 0)<br />
- 10 tons of cargo three (x[3,1] = 10)<br />
- 0 of cargo four (x[4,1] = 0)<br />
* in the middle we put<br />
- 8 tons of cargo one (x[1,2] = 8)<br />
- 3 of cargo two (x[2,2] = 3)<br />
- 5 tons of cargo three (x[3,2] = 5)<br />
- 0 of cargo four (x[4,2] = 0)<br />
* in the rear we put<br />
- 0 tons of cargo one (x[1,3] = 0)<br />
- 0 of cargo two (x[2,3] = 0)<br />
- 8 tons of cargo three (x[3,3] = 8)<br />
- 0 of cargo four (x[4,3] = 0)<br />
</example><br />
<br />
</description><br />
<types><br />
<type>cocoaserver</type><br />
</types><br />
<key>lpsolve</key><br />
<key>solve linear programm</key><br />
<key>solve lp</key><br />
<key>jbrandt</key><br />
<key>skuehling</key><br />
<wiki-category>Package_GLPK</wiki-category><br />
</command></div>91.40.215.137http://apcocoa.uni-passau.de/wiki/index.php?title=ApCoCoA-1:GLPK.MIPSolve&diff=8025ApCoCoA-1:GLPK.MIPSolve2008-12-20T16:03:56Z<p>91.40.215.137: </p>
<hr />
<div><command><br />
<title>LPSolve</title><br />
<short_description>solve linear programms</short_description><br />
<syntax><br />
GLPK.MIPSolve(Objective_f:POLYNOM, EQ_Poly:LIST, LE_Poly:LIST, GE_Poly:LIST, Bounds:LIST, IntNum:LIST, Binaries:LIST, MinMax:STRING)<br />
</syntax><br />
<description><br />
{{ApCoCoAServer}}<br />
<br />
<em>Objective_f</em>: A linear polynomial which is equivalent to the linear objective function.<br />
<br />
<em>EQ_Poly</em>: List of linear polynomials, which are equivalent to the equality-part in the list of conditions.<br />
<br />
<em>LE_Poly</em>: List of linear polynomials, which are equivalent to the lower or equal-part in the list of conditions.<br />
<br />
<em>GE_Poly</em>: List of linear polynomials, which are equivalent to the greater or equal-part in the list of conditions.<br />
<br />
<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).<br />
<br />
<em>IntNum</em>: List of variables, which should be integer. <em>Note</em>: For each variable in this list, the borders get rounded (lower bound: up and upper bound: down). In the case that the lower rounded bound becomes greater then the upper rounded bound, glpk returns: Solution Status: INTEGER UNDEFINED - Value of objective function: 0.<br />
<br />
<em>Binaries</em>: List of variables, which should be binaries (0 or 1).<br />
<br />
<em>MinMax</em>: Minimization ("Min") or maximization ("Max"), that's the question.<br />
<br />
<br />
First we want to discuss a rather easy example. <br />
<example><br />
We want to maximize the Function y = - 1/2x, <br />
with the two conditions y ≤ 6 - 3/4x and y ≥ 1 - x and the bounds 0 ≤ x ≤ 6 and 1/3 ≤ y ≤ 4.<br />
<br />
We prename the input of GLPK.MIPSolve-function.<br />
Use S::=Q[x,y];<br />
OF := 1/2x + y;<br />
LE := [3/4x + y - 6];<br />
GE :=[ x + y - 1];<br />
Bounds:=[[0,6], [1/3,4]];<br />
IntNum:=[x,y];<br />
<br />
Then we compute the solution with<br />
$GLPK.MIPSolve(OF, [], LE, GE, Bounds, IntNum, [], "Max");<br />
<br />
<br />
And we achieve:<br />
Solution Status: INTEGER OPTIMAL<br />
Value of objective function: 5<br />
[x[1] - 2, x[2] - 4]<br />
</example><br />
<br />
[[Image:LinOpt_2.jpg]]<br />
<br />
<br />
<br />
<example><br />
''Linear programming example 1996 MBA exam''<br />
<br />
A cargo plane has three compartments for storing cargo: front, centre and rear. <br />
These compartments have the following limits on both weight and space:<br />
<br />
Compartment Weight capacity (tonnes) Space capacity (cubic metres)<br />
Front 10 6800<br />
Centre 16 8700<br />
Rear 8 5300<br />
<br />
Furthermore, the weight of the cargo in the respective compartments must be the same <br />
proportion of that compartment's weight capacity to maintain the balance of the plane.<br />
<br />
The following four cargoes are available for shipment on the next flight:<br />
<br />
Cargo Weight (tonnes) Volume (cubic metres/tonne) Profit (£/tonne)<br />
C1 18 480 310<br />
C2 15 650 380<br />
C3 23 580 350<br />
C4 12 390 285<br />
<br />
Any proportion of these cargoes can be accepted. The objective is to determine how much <br />
(if any) of each cargo C1, C2, C3 and C4 should be accepted and how to distribute each <br />
among the compartments so that the total profit for the flight is maximised. <br />
<br />
<br />
To solve this problem we had to compose a linear program.<br />
<br />
Variables<br />
<br />
We need to decide how much of each of the four cargoes to put in each of the three compartments. <br />
Hence let:<br />
<br />
xij be the number of tonnes of cargo i (i=1,2,3,4 for C1, C2, C3 and C4 respectively) that is put into <br />
compartment j (j=1 for Front, j=2 for Centre and j=3 for Rear) where xij >=0 i=1,2,3,4; j=1,2,3<br />
<br />
Note here that we are explicitly told we can split the cargoes into any proportions (fractions) that we like.<br />
<br />
Constraints<br />
<br />
* cannot pack more of each of the four cargoes than we have available<br />
<br />
x11 + x12 + x13 ≤ 18<br />
x21 + x22 + x23 ≤ 15<br />
x31 + x32 + x33 ≤ 23<br />
x41 + x42 + x43 ≤ 12<br />
<br />
* the weight capacity of each compartment must be respected<br />
<br />
x11 + x21 + x31 + x41 ≤ 10<br />
x12 + x22 + x32 + x42 ≤ 16<br />
x13 + x23 + x33 + x43 ≤ 8<br />
<br />
* the volume (space) capacity of each compartment must be respected<br />
<br />
480x11 + 650x21 + 580x31 + 390x41 ≤ 6800<br />
480x12 + 650x22 + 580x32 + 390x42 ≤ 8700<br />
480x13 + 650x23 + 580x33 + 390x43 ≤ 5300<br />
<br />
* the weight of the cargo in the respective compartments must be the same proportion <br />
of that compartment's weight capacity to maintain the balance of the plane<br />
<br />
[x11 + x21 + x31 + x41]/10 = [x12 + x22 + x32 + x42]/16 = [x13 + x23 + x33 + x43]/8<br />
<br />
Objective<br />
<br />
The objective is to maximise total profit, i.e.<br />
<br />
maximise 310[x11+ x12+x13] + 380[x21+ x22+x23] + 350[x31+ x32+x33] + 285[x41+ x42+x43]<br />
<br />
The basic assumptions are:<br />
<br />
* that each cargo can be split into whatever proportions/fractions we desire<br />
* that each cargo can be split between two or more compartments if we so desire<br />
* that the cargo can be packed into each compartment (for example if the cargo was spherical it would <br />
not be possible to pack a compartment to volume capacity, some free space is inevitable in sphere packing)<br />
* all the data/numbers given are accurate<br />
<br />
<br />
In ApCoCoa you can solve this LP like this:<br />
<br />
Use S::= Q[x[1..4,1..3]];<br />
<br />
Objective := 310*(x[1,1]+x[1,2]+x[1,3])+310*(x[2,1]+x[2,2]+x[2,3])+350*(x[3,1]+x[3,2]+x[3,3])+285*(x[4,1]+x[4,2]+x[4,3]);<br />
Balance := [16(x[1,1]+x[2,1]+x[3,1]+x[4,1])-10(x[1,2]+x[2,2]+x[3,2]+x[4,2]), 8(x[1,2]+x[2,2]+x[3,2]+x[4,2])-16(x[1,3]+x[2,3]+x[3,3]+x[4,3])];<br />
<br />
Available := [x[1,1]+x[1,2]+x[1,3]-18, x[2,1]+x[2,2]+x[2,3]-15, x[3,1]+x[3,2]+x[3,3]-23, x[4,1]+x[4,2]+x[4,3]-12];<br />
Weight := [x[1,1]+x[2,1]+x[3,1]+x[4,1]-10, x[1,2]+x[2,2]+x[3,2]+x[4,2]-16, x[1,3]+x[2,3]+x[3,3]+x[4,3]-8];<br />
Volume := [480x[1,1]+650x[2,1]+580x[3,1]+390x[4,1]-6800, 480x[1,2]+650x[2,2]+580x[3,2]+390x[4,2]-8700, 480x[1,3]+650x[2,3]+580x[3,3]+390x[4,3]-5300];<br />
LessEq := Flatten([Available, Weight, Volume]);<br />
<br />
Bounds := [[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""]];<br />
<br />
IntNum:=[x[1,2], x[1,3]];<br />
<br />
$GLPK.MIPSolve(Objective, Balance, LessEq, [], Bounds, IntNum, [], "Max");<br />
<br />
<br />
And we receive:<br />
Solution Status: INTEGER OPTIMAL<br />
Value of objective function: 11460<br />
[x[1,1], x[1,2] - 8, x[1,3], x[2,1], x[2,2] - 3, x[2,3], x[3,1] - 10, x[3,2] - 5, x[3,3] - 8, x[4,1], x[4,2], x[4,3]]<br />
<br />
This means <br />
* in the front we put<br />
- 0 of cargo one (x[1,1] = 0)<br />
- 0 of cargo two (x[2,1] = 0)<br />
- 10 tons of cargo three (x[3,1] = 10)<br />
- 0 of cargo four (x[4,1] = 0)<br />
* in the middle we put<br />
- 8 tons of cargo one (x[1,2] = 8)<br />
- 3 of cargo two (x[2,2] = 3)<br />
- 5 tons of cargo three (x[3,2] = 5)<br />
- 0 of cargo four (x[4,2] = 0)<br />
* in the rear we put<br />
- 0 tons of cargo one (x[1,3] = 0)<br />
- 0 of cargo two (x[2,3] = 0)<br />
- 8 tons of cargo three (x[3,3] = 8)<br />
- 0 of cargo four (x[4,3] = 0)<br />
</example><br />
<br />
</description><br />
<types><br />
<type>cocoaserver</type><br />
</types><br />
<key>lpsolve</key><br />
<key>solve linear programm</key><br />
<key>solve lp</key><br />
<key>jbrandt</key><br />
<key>skuehling</key><br />
<wiki-category>Package_GLPK</wiki-category><br />
</command></div>91.40.215.137http://apcocoa.uni-passau.de/wiki/index.php?title=ApCoCoA-1:GLPK.LPSolve&diff=8024ApCoCoA-1:GLPK.LPSolve2008-12-20T16:02:11Z<p>91.40.215.137: </p>
<hr />
<div><command><br />
<title>LPSolve</title><br />
<short_description>solve linear programms</short_description><br />
<syntax><br />
GLPK.LPSolve(Objective_f:POLYNOM, EQ_Poly:LIST, LE_Poly:LIST, GE_Poly:LIST, Bounds:LIST, Method:STRING, MinMax:STRING)<br />
</syntax><br />
<description><br />
{{ApCoCoAServer}}<br />
<br />
<em>Objective_f</em>: A linear polynomial which is equivalent to the linear objective function.<br />
<br />
<em>EQ_Poly</em>: List of linear polynomials, which are equivalent to the equality-part in the list of conditions.<br />
<br />
<em>LE_Poly</em>: List of linear polynomials, which are equivalent to the lower or equal-part in the list of conditions.<br />
<br />
<em>GE_Poly</em>: List of linear polynomials, which are equivalent to the greater or equal-part in the list of conditions.<br />
<br />
<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).<br />
<br />
<em>Method</em>: You can choose between the interior-point-method ("InterP") or the simplex-algorithm ("Simplex"). Usually you should use the simplex-algorithm.<br />
<br />
<em>MinMax</em>: Minimization ("Min") or maximization ("Max"), that's the question.<br />
<br />
<br />
First we want to discuss a rather easy example. <br />
<example><br />
We want to maximize the Function y = - 1/2x, <br />
with the two conditions y ≤ 6 - 3/4x and y ≥ 1 - x and the bounds 0 ≤ x ≤ 6 and 1/3 ≤ y ≤ 4.<br />
<br />
We prename the input of GLPK.LPSol-function.<br />
Use S::=Q[x,y];<br />
OF := 1/2x + y;<br />
LE := [3/4x + y - 6];<br />
GE := [x + y - 1];<br />
Bounds:=[[0,6], [1/3,4]];<br />
<br />
Then we compute the solution with<br />
$GLPK.LPSolve(OF, [], LE, GE, Bounds, "Simplex", "Max");<br />
<br />
And we achieve: <br />
Solution Status: OPTIMAL<br />
Value of objective function: 5333333333/1000000000<br />
[x[1] - 266667/100000, x[2] - 4]<br />
</example><br />
<br />
[[Image:LinOpt.jpg]]<br />
<br />
<br />
<br />
<example><br />
''Linear programming example 1996 MBA exam''<br />
<br />
A cargo plane has three compartments for storing cargo: front, centre and rear. <br />
These compartments have the following limits on both weight and space:<br />
<br />
Compartment Weight capacity (tonnes) Space capacity (cubic metres)<br />
Front 10 6800<br />
Centre 16 8700<br />
Rear 8 5300<br />
<br />
Furthermore, the weight of the cargo in the respective compartments must be the same <br />
proportion of that compartment's weight capacity to maintain the balance of the plane.<br />
<br />
The following four cargoes are available for shipment on the next flight:<br />
<br />
Cargo Weight (tonnes) Volume (cubic metres/tonne) Profit (£/tonne)<br />
C1 18 480 310<br />
C2 15 650 380<br />
C3 23 580 350<br />
C4 12 390 285<br />
<br />
Any proportion of these cargoes can be accepted. The objective is to determine how much <br />
(if any) of each cargo C1, C2, C3 and C4 should be accepted and how to distribute each <br />
among the compartments so that the total profit for the flight is maximised. <br />
<br />
<br />
To solve this problem we had to compose a linear program.<br />
<br />
Variables<br />
<br />
We need to decide how much of each of the four cargoes to put in each of the three compartments. <br />
Hence let:<br />
<br />
xij be the number of tonnes of cargo i (i=1,2,3,4 for C1, C2, C3 and C4 respectively) that is put into <br />
compartment j (j=1 for Front, j=2 for Centre and j=3 for Rear) where xij >=0 i=1,2,3,4; j=1,2,3<br />
<br />
Note here that we are explicitly told we can split the cargoes into any proportions (fractions) that we like.<br />
<br />
Constraints<br />
<br />
* cannot pack more of each of the four cargoes than we have available<br />
<br />
x11 + x12 + x13 ≤ 18<br />
x21 + x22 + x23 ≤ 15<br />
x31 + x32 + x33 ≤ 23<br />
x41 + x42 + x43 ≤ 12<br />
<br />
* the weight capacity of each compartment must be respected<br />
<br />
x11 + x21 + x31 + x41 ≤ 10<br />
x12 + x22 + x32 + x42 ≤ 16<br />
x13 + x23 + x33 + x43 ≤ 8<br />
<br />
* the volume (space) capacity of each compartment must be respected<br />
<br />
480x11 + 650x21 + 580x31 + 390x41 ≤ 6800<br />
480x12 + 650x22 + 580x32 + 390x42 ≤ 8700<br />
480x13 + 650x23 + 580x33 + 390x43 ≤ 5300<br />
<br />
* the weight of the cargo in the respective compartments must be the same proportion <br />
of that compartment's weight capacity to maintain the balance of the plane<br />
<br />
[x11 + x21 + x31 + x41]/10 = [x12 + x22 + x32 + x42]/16 = [x13 + x23 + x33 + x43]/8<br />
<br />
Objective<br />
<br />
The objective is to maximise total profit, i.e.<br />
<br />
maximise 310[x11+ x12+x13] + 380[x21+ x22+x23] + 350[x31+ x32+x33] + 285[x41+ x42+x43]<br />
<br />
The basic assumptions are:<br />
<br />
* that each cargo can be split into whatever proportions/fractions we desire<br />
* that each cargo can be split between two or more compartments if we so desire<br />
* that the cargo can be packed into each compartment (for example if the cargo was spherical it would <br />
not be possible to pack a compartment to volume capacity, some free space is inevitable in sphere packing)<br />
* all the data/numbers given are accurate<br />
<br />
<br />
In ApCoCoa you can solve this LP like this:<br />
<br />
Use S::= Q[x[1..4,1..3]];<br />
<br />
Objective := 310*(x[1,1]+x[1,2]+x[1,3])+310*(x[2,1]+x[2,2]+x[2,3])+350*(x[3,1]+x[3,2]+x[3,3])+285*(x[4,1]+x[4,2]+x[4,3]);<br />
Balance := [16(x[1,1]+x[2,1]+x[3,1]+x[4,1])-10(x[1,2]+x[2,2]+x[3,2]+x[4,2]), 8(x[1,2]+x[2,2]+x[3,2]+x[4,2])-16(x[1,3]+x[2,3]+x[3,3]+x[4,3])];<br />
<br />
Available := [x[1,1]+x[1,2]+x[1,3]-18, x[2,1]+x[2,2]+x[2,3]-15, x[3,1]+x[3,2]+x[3,3]-23, x[4,1]+x[4,2]+x[4,3]-12];<br />
Weight := [x[1,1]+x[2,1]+x[3,1]+x[4,1]-10, x[1,2]+x[2,2]+x[3,2]+x[4,2]-16, x[1,3]+x[2,3]+x[3,3]+x[4,3]-8];<br />
Volume := [480x[1,1]+650x[2,1]+580x[3,1]+390x[4,1]-6800, 480x[1,2]+650x[2,2]+580x[3,2]+390x[4,2]-8700, 480x[1,3]+650x[2,3]+580x[3,3]+390x[4,3]-5300];<br />
LessEq := Flatten([Available, Weight, Volume]);<br />
<br />
Bounds := [[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""],[0,""]];<br />
<br />
$GLPK.LPSolve(Objective, Balance, LessEq, [], Bounds, "Simplex", "Max");<br />
<br />
<br />
And we receive:<br />
Solution Status: OPTIMAL<br />
Value of objective function: 11460<br />
[x[1,1], x[1,2] - 29/5, x[1,3] - 26/5, x[2,1], x[2,2], x[2,3], x[3,1] - 10, x[3,2] - 51/5, x[3,3] - 14/5, x[4,1], x[4,2], x[4,3]]<br />
<br />
This means <br />
* in the front we put<br />
- 0 of cargo one (x[1,1] = 0)<br />
- 0 of cargo two (x[2,1] = 0)<br />
- 10 tons of cargo three (x[3,1] = 10)<br />
- 0 of cargo four (x[4,1] = 0)<br />
* in the middle we put<br />
- 29/5 tons of cargo one (x[1,2] = 29/5)<br />
- 0 of cargo two (x[2,2] = 0)<br />
- 51/5 tons of cargo three (x[3,2] = 51/5)<br />
- 0 of cargo four (x[4,2] = 0)<br />
* in the rear we put<br />
- 26/5 tons of cargo one (x[1,3] = 26/5)<br />
- 0 of cargo two (x[2,3] = 0)<br />
- 14/5 tons of cargo three (x[3,3] = 14/5)<br />
- 0 of cargo four (x[4,3] = 0)<br />
</example><br />
<br />
</description><br />
<types><br />
<type>cocoaserver</type><br />
</types><br />
<key>lpsolve</key><br />
<key>solve linear programm</key><br />
<key>solve lp</key><br />
<key>jbrandt</key><br />
<key>skuehling</key><br />
<wiki-category>Package_GLPK</wiki-category><br />
</command></div>91.40.215.137