02 IntroLinearProgramming
02 IntroLinearProgramming
Decisions
Introduction to Linear Programming
George Gross
Department of Electrical and Computer Engineering
University of Illinois at Urbana-Champaign
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 1
OUTLINE
problem
assessment
maximum weight
aspect high
value low heels (%)
heels
esthetics 5.0 4.2 3.6 70
comfort 5.0 3.5 4.8 30
weighted assessment as
xH + xL = 1
xH ≥ 0 , xL ≥ 0
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 6
PROBLEM STATEMENT SUMMARY
Decision variables:
⎧⎪1 choose high ⎧⎪1 choose low
xH = ⎨ xL = ⎨
⎪⎩0 otherwise ⎪⎩0 otherwise
Objective function:
max Z = 3.99 x H + 3.96 x L
Constraints:
xH + xL = 1
xH ≥ 0, xL ≥ 0
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 7
OPTIMAL SOLUTION
Z * = Z ( x H* , x L* ) ≥ Z x H , x L ( )
for all feasible (x H ,xL )
We call such a solution an optimal solution
A feasible solution is one that satisfies all the
constraints
The optimal solution, denoted by *
, is selected
from all the feasible solutions to the problem
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 8
SOLUTION APPROACH: EXHAUSTIVE
SEARCH
We enumerate all the possible solutions: in this
problem there are only two choices:
⎧⎪ x H = 1 ⎧ xH = 0
A: ⎨ B: ⎨
⎪⎩ x L = 0 ⎩xL = 1
We evaluate Z for A and B and compare
Z A = 3.99 Z B = 3.96
so that Z A > Z B and so A is the optimal choice
The optimal solution is
x *H = 1 , x *L = 0 and Z * = 3.99
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 9
CHARACTERISTICS OF A
PROGRAMMING/OPTIMIZATION PROBLEM
Objective is to make a decision among various
alternatives and therefore requires the definition of
the decision variables
The solution of the “best” decision is made
according to some objective and requires the
formulation of the objective function
The decision must satisfy certain specified
constraints and so requires the mathematical
statement of the problem constraints
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 10
CLASSIFICATION OF PROGRAMMING
PROBLEMS
The problem statement is characterized by :
continuous valued
decision variables
integer valued
linear
objective function
non linear
linear
constraints
non linear
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 11
PROGRAMMING PROBLEM CLASSES
Linear/nonlinear programming
Static/dynamic programming
Integer programming
Mixed programming
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 12
EXAMPLE 2: CONDUCTOR PROBLEM
A company is producing two types of conductors
for EHV transmission lines
production
metal needed profits
type conductor capacity
(tons/unit) ($/unit)
(unit/day)
1 ACSR 84/19 4 1/6 3
2 ACSR 18/7 6 1/9 5
Z = profits ($/day)
= 3 x1 + 5 x 2
Sanity check for units of the objective function
($/day) = ($/unit) • (unit/day)
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 15
PROBLEM STATEMENT
Objective function:
max Z = 3 x 1 + 5 x 2
Constraints:
capacity limits:
x1 ≤ 4 x2 ≤ 6
metal supply limit:
x1 x2
+ ≤ 1
6 9
common sense requirements:
x 1 ≥ 0, x 2 ≥ 0
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 16
PROBLEM STATEMENT
max Z = 3 x1 + 5x 2
s .t .
x1 ≤ 4
x2 ≤ 6
x1 x2
+ ≤ 1
6 9
x 1 ≥ 0, x 2 ≥ 0
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 17
CONSTRUCTION OF THE FEASIBLE
REGION
x2
x1 = 4
( 4,0 )x
(0, 0 ) 1
x1 ≤ 4 , x 1 ≥ 0, x 2 ≥ 0
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 18
CONSTRUCTION OF THE FEASIBLE
REGION
x2
x2 = 6
(0 ,6 )
x 2 ≤ 6 , x 1 ≥ 0, x 2 ≥ 0
x1
( 0, 0 )
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 19
CONSTRUCTION OF THE FEASIBLE
REGION
x2
x1 x2
( 0,9) 6
+
9
≤1
x 1 ≥ 0, x 2 ≥ 0
( 6,0)
( 0,0) x1
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 20
THE FEASIBLE REGION
x2 x1 = 4
( 2, 6)
x2 = 6
( 0 , 6)
feasible
region
( 4, 3)
x1 x2
+ = 1
6 9
( 0, 0 ) x1
( 4,0 )
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 21
FEASIBLE SOLUTIONS
x2 x1 = 4
( 2, 6)
x2 = 6
( 0 , 6)
D max Z = 3 x 1 + 5 x 2
(1.5, 4.5)
Z = 27 ( 4, 3)
° ( 2, 2 ) x1 x2
Z = 16 + = 1
6 9
x1
( 0, 0 ) ( 4, 0 )
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 22
CONTOURS OF CONSTANT Z
x2 x1 = 4
( 0, 6) ( 2, 6)
x2 = 6
Z = 25
Z = 20 max Z = 3 x 1 + 5 x 2
Z = 15
Z = 36
Z = 10 ( 4, 3)
x1 x2
( 0, 2) + = 1
6 9
x1
( 0, 0 ) ( 4, 0 )
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 23
OPTIMAL SOLUTION
x *
1 = 2 and x *
2 = 6
Z = 3x + 5x
* *
1
*
2 = 36
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 24
LINEAR PROGRAMMING (LP)
PROBLEM
constraints.
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 25
EXAMPLE 3: ONE-POTATO, TWO-
POTATO PROBLEM
Mr. Spud manages the Potatoes-R-Us Co. which
processes potatoes into packages of freedom
fries ( F ), hash browns ( H ) and chips ( C )
Mr. Spud can buy potatoes from two sources;
each source has distinct characteristics/limits
The problem is to determine the respective
quantities Mr. Spud needs to buy from source 1
and from source 2 so as to maximize profits
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 26
EXAMPLE 3: ONE-POTATO, TWO-
POTATO PROBLEM
The known data are summarized in the table
source 1 source 2
product sales limit (tons)
uses (%) uses (%)
F 20 30 1.8
H 20 10 1.2
C 30 30 2.4
profits ($/ton) 5 6
Decision variables:
x 1 = quantity purchased from source 1
x 2 = quantity purchased from source 2
Objective function:
max Z = 5 x 1 + 6 x 2
Constraints:
0.2 x 1 + 0.3 x 2 ≤ 1.8 ( F )
0.2 x 1 + 0.1 x 2 ≤ 1.2 ( H ) x 1 ≥ 0, x 2 ≥ 0
0.3 x 1 + 0.3 x 2 ≤ 2.4 (C)
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 28
FEASIBLE REGION DETERMINATION
x2 x2
6 freedom fries
F 12
4
10
2 hash browns
x2 x1 8
0 2 4 6 8 H
6
8
chips 4
6
C 2
4
x1
2 0 2 4 6 8
x1
0 2 4 6 8
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 29
THE FEASIBLE REGION
x2
12
10
8 feasible
region
6
4
2
x1
2 4 6 8 10 12
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 30
EXAMPLE 3: CONTOURS OF
CONSTANT Z
x2
Z = 36 max Z = 5 x 1 + 6 x 2
Z = 30 6
Z = 40.5
Z = 24 5
Z = 18 4
3 ( 4.5, 3)
2
1
x1
1 2 3 4 5 6
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 31
THE OPTIMAL SOLUTION
x 1* = 4.5 x 2* = 3
needed
step x1 x2 Z
0 0 0 0
1 0 6 36
2 4.5 3 40.5
3 6 0 30
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 36
EXAMPLE 3 : THE SIMPLEX
APPROACH
x2
(0,6) Z = 36 max Z = 5 x1 + 6 x 2
6
5
3 (4.5,3) Z = 40.5
1
(0,0) 0 Z=0 Z = 30 (6,0) x
1
1 2 3 4 5 6
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 37
EXAMPLE 3 : THE SIMPLEX
APPROACH
1. Start at (0,0) with Z (0,0) = 0
2. (i) Move from (0,0) to (0,6), Z (0,6) = 36
(ii) Move from (0,6) to (4.5,3) and evaluate
Z (4.5,3) = 40.5
3. Compare the objective at (4.5,3) to values at (6,0)
and at (6,0):
Z (4.5,3) ≥ Z (6,0)
Z (4.5,3) ≥ Z (6,0)
therefore, (4.5,3) is optimal
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 38
REVIEW
variables
an objective function
Key attributes of an LP
objective function is linear
constraints are linear
Basic steps in formulating a programming
problem
definition of decision variables
statement of objective function
formulation of constraints
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 40
REVIEW
1 25 98 4
2 15 95 3
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 42
EXAMPLE 4 : INSPECTION OF GOODS
PRODUCED
Each error costs $ 2
Objective function
4 + 2 (25)(0.02) = 5 $/hr
Z = 8 [5 x 1 + 4.5 x 2] = 40 x 1 + 36 x 2 ($)
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 45
EXAMPLE 4 : FORMULATION
Constraints:
job completion:
8(25) x 1 + 8(15) x 2 ≥ 1, 800
⇔ 200 x 1 + 120 x 2 ≥ 1, 800
⇔ 5 x1 + 3 x2 ≥ 45
availability limit:
x1 ≤ 8
x 2 ≤ 10
nonnegativity:
x 1 ≥ 0, x 2 ≥ 0
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 46
EXAMPLE 4 : PROBLEM STATEMENT
SUMMARY
Decision variables:
x1 = number of grade 1 inspectors assigned
x2 = number of grade 2 inspectors assigned
Objective function:
min Z = 40 x1 + 36 x2
Constraints:
5 x 1 + 3 x 2 ≥ 45
x1 ≤ 8
x 2 ≤ 10
x 1 ≥ 0, x 2 ≥ 0
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 47
MULTI – PERIOD SCHEDULING
solution
a two–period horizon
res A wA wA wB wB
res A plant res B plant
inflow A B
sA sB
res B
inflow
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 50
EXAMPLE 5 : kAf RESERVOIR DATA
A 150
B 87.5
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 52
EXAMPLE 5 : SYSTEM
CHARACTERISTICS
Demand in MWh ( for each period )
up to 50,000 MWh can be sold @ $ 20/MWh
all additional MWh are sold @ $ 14/MWh
$/MWh
non-linear objective
function
14 $/MWh
20
$/MWh
xh xh MWh
50,000
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 53
EXAMPLE 5 : DECISION VARIABLES
units are in $
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 55
EXAMPLE 5 : CONSTRAINTS
Period 1
energy conservation in a lossless system
• total generation 400 w A1 + 200 w B1 ( MWh )
x
• total sales H1
+ x 1
L ( MWh )
• losses are negelected and so
x 1
H + x 1
L = 400 w 1
A + 200 w 1
B
res. Res.level
level at at res. Res.level
level at at predicted
Res.level at
e.o.p.10
e.o.p. e.o.p.00
e.o.p. inflow
e.o.p. 0
• reservoir B:
w B1 + s B1 + r B1 = 850 + 40 + w A1 + s A1 ( kAf )
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 57
EXAMPLE 5 : CONSTRAINTS
• reservoir A:
1,200 ≤ r 1
A ≤ 2,000 ( kAf )
• reservoir B:
sales constraint
x 1H ≤ 50,000 ( kAf )
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 58
EXAMPLE 5 : CONSTRAINTS
Period 2
energy conservation in a lossless system
• total generation 400 w A2 + 200 w B2 ( MWh )
• total sales x H2 + x L2 ( MWh )
• losses are negelected and so
x 2
H + x 2
L = 400 w 2
A + 200 w 2
B
res. Res.level
level at at res. level atat
Res.level Res.level at
predicted
e.o.p.20 e.o.p. 0 e.o.p. 0
e.o.p. e.o.p. 1 inflow
• reservoir B:
w B2 + s B2 + r B2 = r B1 + 15 + w A2 + s A2 ( kAf )
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 60
EXAMPLE 5 : CONSTRAINTS
• reservoir A:
x H2 ≤ 50,000 ( kAf )
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 61
EXAMPLE 5 : PROBLEM STATEMENT
16 decision variables:
x Hi , x Li , w Ai , w Bi , s Ai , s Bi , r Ai , r Bi , i = 1, 2
Objective function:
Constraints:
quarter t
product variable
1 2 3 4
washing
Wt 1,200 1,500 1,000 1,400
machine
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 63
EXAMPLE 6 : QUARTERLY COST
COMPONENTS
quarter t
cost component parameter unit costs ($)
1 2 3 4
dishwasher ct 125 130 125 126
manufacturing
($/unit) washing
vt 90 100 95 95
machine
dishwasher jt 5.0 4.5 4.5 4.0
storage
($/unit) washing
kt 4.3 3.8 3.8 3.3
machine
hourly labor ($ /hour) pt 6.0 6.0 6.8 6.8
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 64
EXAMPLE 6 : CONSTRAINTS
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 66
EXAMPLE 6 : QUARTER t DECISION
VARIABLES
symbol variable
t = 1, 2, 3, 4
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 67
EXAMPLE 6 : OBJECTIVE FUNCTION
r0 , s 0 r1 , s 1 r2 , s 2 r3 , s 3 r4 , s 4
t=1 t=2 t=3 t=4
D 1 ,W 1 D 2 ,W 2 D 3 ,W 3 D 4 ,W 4
⎧⎪ rt −1 + d t − rt = D t
⎨ t = 1, 2, 3, 4
⎪⎩ s t −1 + w t − s t = W t
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 69
EXAMPLE 6 : CONSTRAINTS
⎧1.5 d t + 2 w t − h t ≤ 0
⎪
⎨ t = 1, 2, 3, 4
⎪ 0.9 h ≤ h ≤ 1.1h
⎩ t −1 t t −1
h 0 = 5, 000
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 70
EXAMPLE 6 : PROBLEM STATEMENT
d1 w1 r1 s1 h1 d2 w2 r2 s2 h2 d3 w3 r3 s3 h3 d4 w4 r4 s4 h4
1 -1 = 1250
1 -1 = 1150
1.5 2 -1 ≤0
1 ≥ 4500
1 ≤ 5500
1 1 -1 = 1300
1 1 -1 = 1500
1.5 2 -1 ≤0
-0.9 1 ≥0
-1.1 1 ≤0
1 1 -1 = 3000
1 1 -1 = 1000
1.5 2 -1 ≤ 0
-0.9 1 ≥0
-1.1 1 ≤0
1 1 -1 = 1000
1 1 -1 = 1400
1.5 2 -1 ≤0
-0.9 1 ≥0
-1.1 1 ≤0
125 90 5.0 4.3 6.0 130 100 4.5 3.8 6.0 125 95 4.5 3.8 6.8 126 95 4.0 3.3 6.8 minimize
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 71
LINEAR PROGRAMMING PROBLEM
max (min) Z = c 1 x 1 + ... + c n x n
s.t.
a 11 x 1 + a 12 x 2 + ... + a 1n x n = b1
a 21 x 1 + a 22 x 2 + ... + a 2n x n = b2
# #
a m1 x 1 + a m2 x 2 + ... + a mn x n = b m
x 1 ≥ 0, x 2 ≥ 0, ... , x n ≥ 0
b 1 ≥ 0, b 2 ≥ 0, ... , b m ≥ 0
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 72
STANDARD FORM OF LP (SFLP)
coefficient matrix
max (min) Z = c T x m× n
A ∈ \
n
x ∈ \
decision
Ax= b vector b ∈ \m
n
c ∈ \
x ≥ 0
requirement
vector profits
(costs)
vector
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 73
CONVERSION OF LP INTO SFLP
xslack ≥ 0
inequality + x slack = b
inequality – x slack = b
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 74
CONVERSION OF LP INTO SFLP
unspecified
with
⎧⎪ x u xu ≥ 0 ⎧ 0 xu ≥ 0
x+ = ⎨ x− = ⎨
⎪⎩0 xu < 0 ⎩- x u xu < 0
and with xu replaced by
x u = x + − x−
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 75
SFLP CHARACTERISTICS
If S = ∅ ⇒ LP is infeasible
x* is optimal ⇒ cT x * ≥ cTx , ∀ x ∈ S
x * may be unbounded
ECE 307 © 2005 - 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 76