linear programming erasmus mobility program (24apr2012) pollack mihály engineering faculty (pmmk)...
TRANSCRIPT
Linear Programming
Erasmus Mobility Program (24Apr2012)Pollack Mihály Engineering Faculty (PMMK)
University of Pécs
João Miranda
http://tiny.cc/jlm_estg ; http://tiny.cc/jlm_ist
24-Apr-2012 Linear Programming 2
Linear Programming (LP)• Basics
• LP typical problems
• LP general model
• LP Simplex method
• Tableau and matrix Simplex approaches
• Duality
• Sensitivity analysis
24-Apr-2012 Linear Programming 3
LP basics
• The typical LP application addresses the rational allocation of limited resources onto different activities, which are competing among them in order to obtain the best possible allocation (the optimal solution).
• The mathematical modeling of LP only uses linear functions to both formulate the objective function and the restrictions.
24-Apr-2012 Linear Programming 4
(…) LP basics
• Usually, the LP model considers:
– Objective Function: linear function to be optimized (maximized or minimized);
– Restrictions: linear constraints to be satisfied by the optimal solution;
– Non-negativity Conditions: the variables must be positive
or zero (!?).
24-Apr-2012 Linear Programming 5
(…) LP basics
• LP model:
• Or:
0x
bA.x
c.x
tosubject
Z ][min
0x
bA.x
c.x
tosubject
Z ][max
24-Apr-2012 Linear Programming 6
(…) LP basics
• Implicitly, a LP model supposes:• Proportionality: the contribution of each activity onto the
objective and the restrictions is proportional to the own level of the activity;
• Additivity: the global value, for the objective or the utilization of resources, results from the addition of the individual contribution of all the activities;
• Continuity or divisibility: the decision variables can present non-integer values, e.g., the variables can be
considered continuous, real and non-negative variables.
24-Apr-2012 Linear Programming 7
(…) LP basics
• Feasible solution: solution satisfying all the restrictions;
• Feasible region: region considering all the feasible solutions;
• Infeasible solution: solution that is not satisfying, at least, one of the restrictions;
• Optimal solution: feasible solution corresponding to the best value (“optimal”) of the objective function.
24-Apr-2012 Linear Programming 8
(…) LP basics
• Multiple optimal solutions: the various and infinite solutions that present the same optimal value of the objective function;
• Adjacent solutions: pair of the feasible corner points that are
sharing the same restriction line, that is, this corners are connected by a line segment that represents a linear restriction;
• Edge: the referred line segment that is bounding the feasible region.
24-Apr-2012 Linear Programming 9
(…) LP basics
• Consider a LP problem with feasible solutions within a bounded search region, corner points, and a optimal solution. Then:– The “best” corner point of the feasible region must be an optimal
solution;
– If the optimal solution is one and only one, then it is a feasible corner point;
– If the optimal solution is multiple, it considers two corner points and the edge/line segment between them.
24-Apr-2012 Linear Programming 10
• A LP problem with n variables and m restrictions can be represented as:
nix
bxaxaxa
bxaxaxa
bxaxaxa
tosubject
xcxcxcZ
i
mnmnmm
nn
nn
nn
..1,0
...
(...)
...
...
...][min
2211
22222121
11212111
2211
(…) LP basics
24-Apr-2012 Linear Programming 11
• An optimization problem occurs when n>m : it corresponds to a linear system of equations that requires to first define (n-m) values, and only then the other m variables can be calculated.
• Non-basic variables: the (n-m) variables that are estimated as zero value;
• Basic variables: the other m variables that can assume non-zero values;
• Basic solution: non-negative values that are obtained for the basic variables, after the non-basic variables are assumed zero;
• Degenerate solution: at least one of the basic variables presents
zero value.
(…) LP basics
24-Apr-2012 Linear Programming 12
LP typical problems
• Product mix;
• Assignment, allocation;
• Diet, blending, covering;
• Production planning;
• Network models;
• Transportation and special cases;
• Game theory;
• Parameters estimation.
24-Apr-2012 Linear Programming 13
A furniture factory builds Tables (t) at a profit of 4 Euros per Table, and Chairs (c) at a profit of 3 Euros per Chair).
Suppose that only 8 short (s) pieces and 6 large (l) pieces are available for building purposes, what combination of Tables and Chairs
do you need to build to make the most profit?
.
If the availability of the short pieces is 8008 and the availability of the large pieces is 6007,
how many Tables and Chairs do you need to build to make the most profit?
Tables & Chairs
24-Apr-2012 Linear Programming 14
Note: modeling is based in the proportionality, aditivity and divisibility between the produced quantities of t and c
and profit and utilization of l and s components.
.
Tables & Chairs
,subject to
ProfitTotalMaximize
tables
large
produce to
used
components
tables
short
produce to
used
components
chairs
large
produce to
used
components
components
ofty Availabili
large
tables
short
produce to
used
components
components
oftyAvailabili
short
24-Apr-2012 Linear Programming 15
Note: modeling is based in the proportionality, aditivity and divisibility between the produced quantities of t and c
and profit and utilization of l and s components.
Tables & Chairs
Prftmax
0,
,
ct
tosubject
600712 ct
800822 ct
ct 34
24-Apr-2012 Linear Programming 16
LP Simplex method
• The Simplex algorithm...
– is a powerful, efficient and robust method;
– considers simple algebraic procedures;
– corresponds to a geometric representation;
– is developed in tableau form;
– is developed in matrix form;
– provides useful information that allow sensitivity analysis.
24-Apr-2012 Linear Programming 17
(…) LP Simplex method
• It only focuses the solutions corresponding to corner points of the feasible region;
• After the initialization phase, the algorithm considers a cycle of optimality testing and new basic solution searching;
• Whenever possible, the initialization step selects the “origin” corner as first basic solution;
• It searches to improve each solution by evaluating only the adjacent corners, following the edges lines that connect them;
• The edge selection aims to improve the objective function the most;
• The optimality test verifies if some of the edges that connect the present corner point may (or not) improve the objective function.
24-Apr-2012 Linear Programming 18
(…) LP Simplex method
Previous step:
LP in canonic form• Initialization: obtain a first feasible basic solution, by assuming
zero for the (n-m) values of the non-basic variables;
• Optimality test: verify if the present feasible basic solution is optimal, checking if all the objective function coefficients (in term of
the non-basic variables) are positive;
24-Apr-2012 Linear Programming 19
(…) LP Simplex method
• Iterative cycle:
1) Direction of search: select the non-basic variable that is entering the basic solution, choosing the negative coefficient of the objective function with largest absolute value;
2) Length of movement: select the basic variable that is leaving the (basic) solution, choosing the variable that first reaches zero by application of the minimum ratio test;
3) Calculation of the new basic solution: use the known Gauss elimination, obtaining the identity vector in the column corresponding to the new basic variable.
24-Apr-2012 Linear Programming 20
Tableau form of LP Simplex
• In tableau form, the Simplex algorithm is only saving the main information, namely:
• the coefficients of restrictions and objective function;
• The parameters (RHS) of the restrictions;
• The basic variable in each equation.
• For instance,
Zccc
b
b
b
aaa
aaa
aaa
n
mmnmm
n
n
0...00...
...
1...00
(...)
0...10
0...01
...
...
...
...
21
2
1
21
22221
11211
24-Apr-2012 Linear Programming 21
LP Simplex specificities
– Slack variables
– Excess/surplus variables
– Artificial variables
– Inversion of restriction
– Limited variables
– Non-constrained variables (+ or -)
– Minimization vs. maximization
– Degenerate solution
– Multiple optimal solutions
– Unbounded objective function
24-Apr-2012 Linear Programming 22
Matrix form of LP Simplex
Note: LP in augmented form
• Sequentially:
BB1
B
1
B
.xcZ;.bBx
B
B
x
solution, basic Calculate4)
matrix, basicInvert 3)
matrix, basic Define2)
, vector variablesbasicSelect 1)
max [ ]
;
Z
sujeito a
c 0 .x
x
A I .x
xb
x
x0
s
s s
24-Apr-2012 Linear Programming 23
(...) Matrix form of LP Simplex
• When minimizing, consider the opposite in step 7) : the solution is optimal if there are only positive coefficients; else, select the negative coefficient with largest absolute value to define the entering variable.
step;first thereturn to s); (line variableleavingtheas
,)
value,ratio minimum with theassociated variable theChoose8)
variable;entering theas e)(column valuepositivelargest with the
variablebasic-non select theor )(optimalityCheck 7)
;.:function objective Update6)
:matrix basic-non Update5)
(...)
ie
i
kB
N
N1
BN1
B
N1
x
0<c
.A.BccrBcy
.ABK
24-Apr-2012 Linear Programming 24
Inverse matrix updating
• The inversion of the basic matrix B is efficiently computed by updating the inverse matrix from last iteration:
B E. B E1 1
( ) ( ),
... ...
... ...
... ...
(...)
... ...
(...)
... ...
i i
s
se
s
se
s
se
se
ms
se
onde
kk
kk
kk
k
kk
1
1
2
2
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1 0
0 0 0 1
24-Apr-2012 Linear Programming 25
Tableau form of LP Simplex (revisited)
• The tableaus in each iteration:
b.Bc.A.Bcc0
bB.ABI
cc
bAB
0c
bIA
1BN
1BN
1N
1
NB
N
,
0
0
then
from
24-Apr-2012 Linear Programming 26
(...) Tableau form of LP Simplex (revisited)
• At the ending step, for instance (S0=I):
• Using the coefficients of the slack variables in each equation, after each iteration, it can be observed how this equation was obtained from the initial equations!
valueoptimal
solutionoptimal
also
then
optimalfinalinitial
y
.b*yZ*
c.A*yc*z
.b*Sb*
.A*SA*
*.Bcy*
*BS*
*Z*c*z
*b*S*A
0c
bIA
1B
1
,
)()(
0
24-Apr-2012 Linear Programming 27
Duality
• In close relation with each LP problem, the primal problem, there is other problem called the dual problem:
0y
c.yA
y.b
0x
bA.x
c.x
T
tosubject
W
tosubject
Z ][min][max
DualPrimal
24-Apr-2012 Linear Programming 28
• Then,
)(
)(
)(
0
0
min
0
0
)(
)(
)(
max
nnrestrictio
mnrestrictio
lnrestrictio
ydconstrainenon
y
y
xdconstrainenon
x
x
knrestrictio
jnrestrictio
inrestrictio
k
j
i
n
m
l
Primal-dual transformation
24-Apr-2012 Linear Programming 29
Duality properties
• Weak duality: for any feasible solutions, primal x and dual y,
• Strong duality: at the optimal solution,
• Complementary of feasible solutions: at each iteration of the Simplex algorithm, feasible and complementing solutions are found,
• Complementary of optimal solutions: at the final iteration of Simplex, optimal and complementing solutions are found, c.x y .b* *
c.x y.b
c.x y.b
c.x y .b* *
24-Apr-2012 Linear Programming 30
Sensitivity analysis
• Usually, the values used as parameters or coefficients are just (rough) estimates;
• Some parameters can be manipulated, they result from internal policies or strategic decisions, and they can be revised if it can be advantageous;
• It is important to identify the parameters that drive the most the optimal solution, and their variation range too.
24-Apr-2012 Linear Programming 31
Sensitivity analysis procedures
1) Review the LP model;
2) Review the Simplex final tableau;
3) Apply Gauss elimination and convert the tableau to the “standard” form;
4) Test the feasibility of the new solution (if it still stands in the feasible region);
5) Test the optimality of the new solution;
6) Re-optimize, if the new solution is not an optimal and feasible
solution.
24-Apr-2012 Linear Programming 32
(...) variation at the objective function, c’
• There is no change in the solution basis if the new solution is satisfying the optimality test:
*''
,
onmaximizati,
onminimizati,,*''
bB.c
0
0.AB.ccr'
1B
N1
BN
Z
then
verifies
24-Apr-2012 Linear Programming 33
(...) variation at the RHS parameters, b’
• There is no change on the solution basis if the new
solution is satisfying the feasibility test:
.b'*y.b'*.Bc
0.b'*S.b*Bb*
1B
1
'
,
'
Z
then
24-Apr-2012 Linear Programming 34
(...) variation in non-basic coefficients
• The new solution remains optimal if:
onmaximizati,
onminimizati,
'*'
0
0
.AB.ccr' N1
BN
verifies
24-Apr-2012 Linear Programming 35
(...) introduction of new variables
• Introducing a new variable, index (n+1), the basic solution remains optimal if:
1n1
1n
1n1
B
.aBa
.aB.c
**
onmaximizati,0
onminimizati,0,*11
and
verifiescr nn
24-Apr-2012 Linear Programming 36
(...) variation in basic coefficients
• In despite of the optimal solution can present different values, the basis remains unchanged if the new solution is satisfying the feasibility and optimality tests:
• Nevertheless, the tableau is updated as in the former situation (introducing new variable) and the Gauss elimination procedure is performed.
0.bBb*
0
0.A.Bccr'
1
N1
BN onmaximizati,
onminimizati,, verifies
24-Apr-2012 Linear Programming 37
(...) introduction of new restriction
• It must be directly checked if the optimal solution satisfies, or not, the new restriction;
• If positive, obviously, the optimal solution remains feasible;
• If negative, re-optimize using the Simplex Dual algorithm.
24-Apr-2012 Linear Programming 38
Parametric Analysis: b1b1-Large y1-Dual Z* Enter Var Depart Var
0 3 0 s1, s2, s3 s11 3 3 C2 3 63 3 9 s34 2 11 T5 2 13 s26 1 14 s37 1 158 1 16 C9 0 16 s110 0 1611 0 1612 0 1613 0 1614 0 1615 0 1616 0 1617 0 1618 0 1619 0 1620 0 16
3 3 3 32 2
1 1 10 0 0 0 0 0 0 0 0 0 0 00
2
4
6
8
10
12
14
16
18
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
b1
y1-Dual
Z*
24-Apr-2012 Linear Programming 39
Parametric Analysis: b1b1-Large y1-Dual Z* Enter Var Depart Var
0 3 0 s1, s2, s3 s11 3 3 C2 3 63 3 9 s34 2 11 T5 2 13 s26 1 14 s37 1 158 1 16 C9 0 16 s110 0 1611 0 1612 0 1613 0 1614 0 1615 0 1616 0 1617 0 1618 0 1619 0 1620 0 16
3 3 3 32 2
1 1 10 0 0 0 0 0 0 0 0 0 0 00
2
4
6
8
10
12
14
16
18
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
b1
y1-Dual
Z*
24-Apr-2012 Linear Programming 40
Parametric Analysis: b1b1-Large y1-Dual Z* Enter Var Depart Var
0 3 0 s1, s2, s3 s11 3 3 C2 3 63 3 9 s34 2 11 T5 2 13 s26 1 14 s37 1 158 1 16 C9 0 16 s110 0 1611 0 1612 0 1613 0 1614 0 1615 0 1616 0 1617 0 1618 0 1619 0 1620 0 16
3 3 3 32 2
1 1 10 0 0 0 0 0 0 0 0 0 0 00
2
4
6
8
10
12
14
16
18
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
b1
y1-Dual
Z*
24-Apr-2012 Linear Programming 41
Parametric Analysis: b1b1-Large y1-Dual Z* Enter Var Depart Var
0 3 0 s1, s2, s3 s11 3 3 C2 3 63 3 9 s34 2 11 T5 2 13 s26 1 14 s37 1 158 1 16 C9 0 16 s110 0 1611 0 1612 0 1613 0 1614 0 1615 0 1616 0 1617 0 1618 0 1619 0 1620 0 16
3 3 3 32 2
1 1 10 0 0 0 0 0 0 0 0 0 0 00
2
4
6
8
10
12
14
16
18
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
b1
y1-Dual
Z*
24-Apr-2012 Linear Programming 42
Parametric Analysis: C1
Ctables Tables Z* Enter Var Depart Var-1 0 9 C, s1, s2 s20 1 9 T1 1 102 1 113 1 12 s14 2 14 s35 2 166 2 18 C7 3 21 s28 3 249 3 2710 3 30
0 1 1 1 1 2 2 2 3 3 3 3
0
5
10
15
20
25
30
35
-1 0 1 2 3 4 5 6 7 8 9 10 11
C1
Tables
Z*
24-Apr-2012 Linear Programming 43
Parametric Analysis: C1
Ctables Tables Z* Enter Var Depart Var-1 0 9 C, s1, s2 s20 1 9 T1 1 102 1 113 1 12 s14 2 14 s35 2 166 2 18 C7 3 21 s28 3 249 3 2710 3 30
0 1 1 1 1 2 2 2 3 3 3 3
0
5
10
15
20
25
30
35
-1 0 1 2 3 4 5 6 7 8 9 10 11
C1
Tables
Z*
24-Apr-2012 Linear Programming 44
Parametric Analysis: C1
Ctables Tables Z* Enter Var Depart Var-1 0 9 C, s1, s2 s20 1 9 T1 1 102 1 113 1 12 s14 2 14 s35 2 166 2 18 C7 3 21 s28 3 249 3 2710 3 30
0 1 1 1 1 2 2 2 3 3 3 3
0
5
10
15
20
25
30
35
-1 0 1 2 3 4 5 6 7 8 9 10 11
C1
Tables
Z*
24-Apr-2012 Linear Programming 45
Parametric Analysis: C1
Ctables Tables Z* Enter Var Depart Var-1 0 9 C, s1, s2 s20 1 9 T1 1 102 1 113 1 12 s14 2 14 s35 2 166 2 18 C7 3 21 s28 3 249 3 2710 3 30
0 1 1 1 1 2 2 2 3 3 3 3
0
5
10
15
20
25
30
35
-1 0 1 2 3 4 5 6 7 8 9 10 11
C1
Tables
Z*
24-Apr-2012 Linear Programming 46
Linear Programming (LPsynthesis)• Basics
• LP typical problems
• LP general model
• LP Simplex method
• tableau and matrix Simplex approaches
• Duality
• Sensitivity analysis