linear programming reading: clrs, ch. 29 or reference
DESCRIPTION
Linear Programming Reading: CLRS, Ch. 29 or reference. CSE 6331 Algorithms Steve Lai. Simplex Method. A system of linear inequalities defines a polytope (or simplex) as a feasible region. - PowerPoint PPT PresentationTRANSCRIPT
Linear ProgrammingReading: CLRS, Ch. 29 or reference
CSE 6331 AlgorithmsSteve Lai
1 2
1 2
1 2 1 1 2 2
Let , , , , be real numbers and
let , , , be variables.
Linear function:
( , , , )
Linear equality
Linear functions and linear constraints
n
n
n n n
a a a b
x x x
f x x x a x a x a x
L
L
L L
1 2
1 2
1 2
:
( , , , ) (hyperplane)
Linear inequalities:
( , , , ) (half-space)
( , , , ) (half-space)
n
n
n
f x x x b
f x x x b
f x x x b
L
L
L
2
1 2
1 1 1 2
Given real numbers , , , where 1 , 1 ,
find real numbers , , , to
optimize a linear objective function
General Linear Programming Problems
i j ij
n
n n
b c a i m j n
x x x
c x c x c x
L
L
1
subject to linear constraints
for 1 . n
ij j ij
a x b i m
3
1 2
1 1 2 2
1
find real rnu
1 , 1
1
1
, ,
Given r
, mbers
eal numbers
that
for 1
0 f
m
aximize
subject to
o
Standard Maximum Form
ij
i
j
n
n n
n
ij j ij
j
a i m j n
b i m
c j n
x x x
c x c x c x
a x b i m
x
L
L
r 1 j n
4
11 12 1 1 1
21 22 2 2 2
1 1
and
maximiz
e
subject t
o
In Matrix NotationT
n
n
m m mn n n
a a a x b
a a a x b
a a a x b
c x
Ax b x 0
K
K
M M O M M M
K
5
1 2 1 2
1 2 1 2
11 12 1
21 22 2
1 1
-vectors:
-ve
, , , , , , ,
, , , , , , ,
cto
rs:
-matrix:
NotationT T
m m
T Tn n
n
n
m m mn
b b b y y y
x x x c c c
a a a
a a a
a a
m
n
m n
a
b y
x c
A
K K
K K
K
K
M M O M
K
6
1 1 2 2
11 12 1
21 22 21 2 1 2
1 1
minimize
subject to
and
Standard Minimum Form (in Matrix Notation)T
m m
T T
n
nm n
m m mn
y b y b y b
a a a
a a ay y y c c c
a a a
y b
y A c y 0
L
K
KK K
M M O M
K
7
1 2
1 2
Variables: , , ,
Feasible solution: a vector ( , , , ) that
satisfies all the constraints.
Feasible region : the set of all feasible solutions.
Optimal solut
Terminology
n
n
x x x
x x x
L
L
ion: a solution that optimizes the objective
function.
Optimal objective value *:
A linear program may be
or ( is nonempty or empty)
feasible infeasible
(feasible)
bounded u or
f
g
g ( * is finite onbound r infied nite)f
8
1 2
1 2
1 2
1 2
1 2
maximize
subject to
2 4
4 2 12
1
, 0
objective function
main constraint
s
Example
x x
x x
x x
x x
x x
nonnegativity const ra ints
9
10Source: Linear programming, Thomas S. Ferguson, UCLA
Two maximization LPs, and , are if
for each feasible solution to with objective value
there is a
equivalent
correspond feasible solution ting o with
Equivalence of Linear Programs
L L
zL
L
x
x
equivalent
objective value , and .
A maximization LP, , and a minimization LP, ,
are if for each feasible solution to with
objective value there is a cor
vi
re
ce
sponding f
ve
ea
rsa
sibl
z
z
L L
L
x
e
solution to with objective value , and
vice versa.
L z x
11
We can always convert an LP into an equivalent LP in
standard (maximum or minimum) form.
A linear program may not be in standard maximum form
for any of thes
Converting to Standard Maximum Form
e reasons:
1. The objective funtion may be a minimization.
2. There may be " " (instaed of " ") inequality constraints.
3. There may be equality constraints.
4. There may be some without nonnegix
ativity constraints.
12
1 1
1 1
1. Convert minimization to maximixation:
Minimize ( , , ) maximize ( , , )
2. Convert a " " constraint to a " " constraint:
( )
3. Convert an equality c
n n
n n
ij j i ij j ij j
f x x f x x
a x b a x b
K K
1 1
1
1 1
onstraint into two inequalities:
( )
n n
ij j i ij j inj j
ij j i n nj
ij j i ij j ij j
a x b a x b
a x b
a x b a x b
13
1
4. If is without nonnegativity constraint,
we replace with and add 0, 0.
Thus, becomes , and
becomes .
A feasible solution ,
j
j j j j j
j j j j j j
j j j j j j
x
x x x x x
c x c x c x
a x a x a x
x
1
, , , , to the new LP
corresponds to a feasible solution , , , ,
to the original LP.
j j n
j n
x x x
x x x
K K
K K
14
1 2 1 2
1 21 2
1 21 2
1 21
1
2 3 2 3
subject to
min
subject
im
to
77
7 2 4
ize maximiz
2 4
0
e
0
Example
x x x x
x xx x
x xx x
x xx
x
15
1 1
2 2 2
2
1 2 1 2 2
1 2 1 2
1
2
1 2
2maximize 2 maximize 2
subject to
Replace wit
subject to
7 7
7
2 4
h
0
:
3 3 3
x x x
x x xx x
x x x x x
x x x x
x x
x
2
1 2 2
1 2 2
7
2 2 4
, , 0
x
x x x
x x x
16
1 2 3
1 2 3
1 2 3
1 2 3
2 3
3
2 2
1 2
maximize 2 3 3
subject to
7
7
Renaming ,
2 2
as , yie
4
, , 0
lds:x
x x x
x x x
x x x
x x x
x x x
x x x
17
1 1 2 2
Each LP has an intimately related LP, called its dual.
The original LP is called the pri
maximi
mal.
Primal (standar
ze
subjec
d maximum )
t
L :
P
Duality
Tn nc x c x c x
c x L
1 1 2 2
to
minimiz
and
e
Dua
subject
l (stan
andto
dard minimum LP
):
Tm m
T T
y b y b y b
Ax b x 0
y b
y A c y 0
L
18
1 2
1 11 12 1 1
2 21 22 2
The dual of the Standard Minimum LP is the
Standard Maximum LP.
The primal max LP and the dual min LP can be
simultaneously displayed as:
n
n
n
x x x
y a a a b
y a a a
K
K
K 2
1 2
1 2
m m m mn m
n
b
y a a a b
c c c
M M M O M M
K
K
19
1 2 1 2 3
1 2
1 2
1 2
maximize minimize 4 12
subject to
Primal problem: Dual
subject to
2 4
problem
4 2 12
:
Example
x x y y y
x x
x x
x x
1 2 3
1 2 3
1 2 1 2 3
4 1
2 2 1
1
, 0 , , 0
y y y
y y y
x x y y y
20
1 2
1
2
3
1 2 4
4 2 12
1 1 1
1 1
Example
x x
y
y
y
21
If is a feasible solution to the standard maximum
LP ( , , ) and a feasible solution to its dual, then
Theorem.
Proof.
.
,
,
Weak Duality Theorem
T T
T T
T T T T
x
A b c y c x y b
Ax b x 0 y Ax y b
y A c y 0 y Ax c x .
If a standard LP and its dual are both feasible,
then they are bounded feasible.
If and are feasible solutions to the primal and
dual L
Corollary
Ps, respe
.
Cor
ctiv
ollary.
ely, and
T T
T T
c x y b
x y
c x y b, then
and are optimal solutions to their respective problems.x y
22
A feasible solution to the primal linear program
( , , ) is optimal iff there is a feasible solution to its dual
linear program such
Theore
that . In this ca
m.
se, is
Strong Duality Theorem
T T
x
A b c y
c x y b y also
optimal.
23
Primal
feasible bounded feasible unbounded infeasible
f.b. yes no noDual
f.u. no no yes
i no yes yes
24
1 2 1 2
1 2
11 1 12 2 1,
wh
Fi to
and
, , , , , , ,
, , ,
nd
maximize
subject
o
ere
t
LP in equality form
T
T Tn m m
Tn m
n
x x x b b b
c c c
a x a x a
x
c x
Ax b x 0
x b
c
K K
K
K 1
21 1 22 2 2,
1 1 1 2 ,
m n m
n m n m n
m m m n m n m m
x b
a x a x a x b
a x a x a x b
K
M M M
K
25
Assume rank( ) .
Let be a matrix formed by choosing columns out of
the columns of .
If B is non-singular and if all the variables not associated
with the columns of are se
Basic Solutions
A m
B m
m n A
n
B
t to zero, then the solution to
the resulting system of equations is called a .
The variables associated with the columns
basic solution
basic variables;
in are
called the other variables are im x B
non-basic
variables basic
feasib
. If a basic solution is feasible, it is a
. The number of basic solutions is
( )!at most .
! !
le solution
m nm
m nC
m n
26
1 2
1 2
A set is said to be if for all pointsconvex
extreme poin
,
we have (1 ) for all 0 1.
A point in a convex set is called an
t
Basic feasible solutions are extreme points
C x x C
x x C
x C
1 2 1 2
1 2
if there exist no , , where , and 0 1
such that (1 ) .
Geometrically, extreme points are .
The feasible region of an LP is a conv
corner points (verti
B
ces
ex set.
as i f
)
c
x x C x x
x x x
of an LP (in the equality form)
are of the feasible regions.
If the LP is feasible bounded, t
easible solutions
extreme points
optimum solut
hen at least one
occurs at an extreme poion int.
27
Simplex Method
A system of linear inequalities defines a polytope (or simplex) as a feasible region.
The simplex algorithm begins at a starting vertex and moves along the edges of the polytope until it reaches the vertex of the optimum solution.
28Source: Linear programming, Thomas S. Ferguson, UCLA
v̂
1 2
Find
maximize
to
subject t and
and ( , , , ) to
Standard maximum form:
Equivalent sl
o
Find
ac
m
k for :
Converting standard form to slack form
T
Tms s s
x
c x
Ax b x 0
x s K
(or minimize )
and ,
may be written a
maximize
subjec
t to
s .or
T T
c x c x
Ax s b x 0 s
Ax s b s b Ax s Ax b
0
29
1 2
1 2
1 11 12 1 1
2 21 22 2 2
1
, , , are called .
The equality and the objective
function can be displayed in a tableau:
1 1
slack variables
m
T
n
n
n
m m
s s s
x x x
s a a a b
s a a a
z
b
s a a
s Ax b
c x
K
K
K
K
M M M O M M
2
1 0m mn m
m n
a b
z c c c K
K
30
1 2
1 2
and , :
Basic variables: , , ,
Non-basic variab
minimiz
les: , , ,
The solution i
e
subje
s a, b
ct
as
to
Basic and non-basic variablesT
m
n
B s s s
N x x x
c x
s Ax b x 0 s
x 0 s b
0
K
K
ic solution.
basic feasible s If , the solution is a .
If
olu
in addition , the solution is .
tion
optimum
b 0
c 0
31
32
1
1 11 1 1 1
1
1
1
s.t. and , :
1 1
where 0 initially
If
Max
0, we can pivot ar
imi e
u
z
o
Pivot OperationT
n
j n
i in i
m m mj mn m
j n
j
ii j
i
jx
s
z c x v
x x
s a a a b
a a b
s a a a b
z c c c v v
a
a
s Ax b x 0 s 0
K K
K K
M M M M M
K K
M M M M M
K K
K K
nd , switching the roles
of and
ij
i j
a
s x
33
1 1 , 1 1 , 1 1
, 1 , 111 1 1
Dividing both sides of the equation
by , we have an equivalent equation:
ij
ij
ij ij ij ij ij i
i i j j i j j in n i
i j i ji in ij j
jn
i j
ij
a x a x a x a x b
a aa a bx x x
a
a
a a a a ax
sx
a
s x
L L
L L
11 1
.
Substituting this into every other equation yields:
kj i kj ink k kn n
ij ij
kj ik i
i
kj
j
jij
a ax
a
a a as a x a x
a a
a bb b
a
L L
34
1
1 11 11 1 1
1
1
1
1
After pivoting around , we have the equivalent LP:
1 1
ˆ
ˆ
ˆ ˆ ˆ ˆ
1
n
j in j in
ij ij
mj in mj im m m
i
j
ij
i in ij
i
n mi
j
ij
ij ij
mj
ij
j ij
j n
ij
x x
a a a
s
a
a
a a bx
bs a a b
a a
a a a bs a a b
a a
z c c c v
a
a
a
a a
a
a
K K
K K
M M M M M
K K
M M M M M
K K
K K
35
1
1. Pivot element: 1
2. Other elements in the pivot row:
3. Other elements in the pivot column:
4. All other elements
E xample:
:
3
Summary of Pivot Operation
r p r p
c q c p q rc p
p p
r r p
c c p
q q rc
p
p
0 5 3 2 9 2 7 2
3 1 1 2 3 2 1 2
0 4 3 0 4 3
2
1 1
Find
minimize
subject
to
an
Standard minimum
form:
Equiva
to
Find
d
and ( , , , )
lent slack fo m:
t
r
Converting minimum form to slack form
T
T T
Tns s s
y
y b
y A c y 0
y s K
minimize
subje
o
and ct o t ,
T
T T T
y b
s y A c y 0 s 0
36
1 2
1 11 12 1 1
2 21 22 2 2 1 2
1 2
1 2
1
The equality and objective function
can be displayed in a tableau:
, , ,
, , ,
0
T e h
n
n
n m
n
m m m mn m
m
T T T T
n
s s s
y a a a b
y a a a b B s s s
N y y y
y a a a b
c c c
s y A c y b
K
K
K KM M M O M M K
K
K
, basic solution.
basic feasible soluti
solution is a
If , the solution is a .
If and , the solution i
o
s a
n
optimum solut onn i
y 0 s c
c 0
b 0 c 037
38
1
So we display both the primal and the dual in the
same tableau.
Pivoting for the dual follows the same rule:
r p r p
c q c p q rc p
p
1 2
1 11 12 1 1
2 21 22 2 2
1 2
1
0
n
n
n
m m m mn m
m n
x x x
y a a a b
y a a a b
y a a a b
z c c c
K
K
K
M M M O M M
K
K
39
1 2
1 11 12 1 1
2 21 22 2 2
Pivot madly until we suddently find that all entries in the last
row and last column (exclusive of the corner) are nonnegative.
ˆˆ ˆ ˆ
ˆˆ ˆ ˆ
ˆ
The Pivot Madly Method
n
n
n
m
r r r
t a a a b
t a a a b
t
K
K
K
M M M O M M
1
1
1
1 21
1
0 for , ,
ˆ for , ,
ˆ ˆ for , ,ˆˆ ˆ
0 fo
Solution for primal:
Solution for dual:
ˆOp
r , , 0ˆ ˆ
timal vaˆ ˆ
lue
j j n
i i i m
j j n j
m m mn mi i m
m n
x x r r
x b x t t
y c r r ca a a b
y y t tc c c
vv
K
K
KK
KK
40
1 2 3
11
2 32
4
1 43
2 3
01
4,
Max solution for primal:
Min solution for
34
1
dual:
Optimal value 1
0 03
2, 45 2 4 16
6
Example
x y yx
yx x
x
yy y
xy y
41
Suppose after pivoting for a while we have the tableau:
If , then is a feasible solution for the
maximization problem.
If , then is a f
,
, easible s
v
r 0 t b
t 0
r
t A b
c
r0 c
b 0
c olution for the
minimization problem.
If and , then we have an optimal solution
for both problems.
b 0 c 0
42
The same as the pivot madly method except that we now
choose the points to pivot on more systematically.
The goal is to make all entries in the last row and last
column (ex
The Simplex Method
clusive of the corner) nonnegative.
v
r
t A b
c
43
0
0
0 0 0 0
0
, 0
, ,
Case 1: . Take any column with 0. Among
those with 0, choose the for which the ratio
is smallest. Pivot around . (I
Pivot rules for the simplex method (1)
j
i j
i i j i j
j c
i a i
b a a
b 0
0
1 2 3 4 5 1 2 3
1 1
2 2
3 3
4 4
f no such ,
the max problem is feasible unbounded.)
1 1 1 6 6 1 3 1
0 4 4 4 0 2 4
0 3 1 7 7 2 3 1
5 1 4 2
3
3 2
2
3
3
1
2
1
2
0 5 4 2
5 2 4 2 1 0 5 4 0
i
r r r r r r r r
t t
t t
t t
t t
44
45
0
0
0
0
0
0
0
,
,
After the pivot, stays nonnegative, the entry
becomes positive, and the value never gets less
( gets greater if 0).
1
Properties of rule 1:
j
i
i
i j i
j
i j
c
v
v b
r p r p
c q c p q rc p
b
a b
c
a
v
p
b
0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
, ,
, , , ,
, ,
1
i j i i j
i j i j i i j i i j
j i j j i i j
a b a
a a b a b a
c a v c b a
0, 0
Case 2: some are negative. Take the first 0. Find any
negative entry in row , say 0. (If there is no such ,
the max problem is infeasible.)
Pivot rules for the simplex method (2)
i k
k j
b b
k a j
0 0
0 0 0 0 0
0 0
, ,
, 0 ,
0 ,
1 2 3 4
1
2
3
4
Compare with
for which 0, 0 and choose such that
is smallest ( may be .) Pivot around .
1 3 1
1 2 4 4
2 1 3 1 2
1 4 2 0
5 2 4 2 0
1 2
4
5
k k j i i j
i i j i i j
i j
b a b a
b a i b a
i k a
r r r r
t
t
t
t
1 2 3
1
2
3
4
0 1 2 4
1 3 3 1
2 2 3 1
5 1 4 0
r r r
t
t
t
t
46
47
0
The objective in Case 2 is to get to Case 1.
With the pivot, the nonnegative stay nonnegative,
and becomes no smaller (it gets larger if 0).
1
Properties of rule 2:
i
k i
b
b b
r p r p
c q c c
p
p q r p
0 0 0 0 00
0 0 0 0 0 0 0 0
00 0 0 0 0 0 0
0 0, ,
, , , ,
, ,
,
,
1
i j i i ji
i j i i j i j i i j i i j
k j k k j i j
i j
k k j i i j
a b ab
a b a a b a b a
a
a
b a a b a b a
0
0 0
0
, 0 ,
Case 3: . Treat it as the dual problem.
Take any such that 0. Among those with
0, choose
row
the for which the ratio is
Pivot rules for the simplex method (3)
i
i j j i j
i b j
a j c a
c 0
0 0, 0
1 2 3 4
1
2
3
closest to zero. Pivot around . (If there is no such ,
the dual problem is feasible unbounded.)
1 3 1 6
0 3 2 4 4
2 0 3 1 2
5 1 4 2 3
1
i ja j
r r r r
t
t
t
48
1 2 3
2 3
1 3
1 2 3
1 2 3
2 3
1
Primal: maximize 2 subject to all 0 and
2 3
3 2
2 1
Dual: minimize 3 2 subject to all 0 and
2 1
Example
i
i
x x x x
x x
x x
x x x
y y y y
y y
y y
3
1 2 3
1
2 3 2y y y
49
1 2 3 1 3 3
1 1
2 2
3 2
1 3 2
1 1
3
2
0 1 2 3 2 1 1 2
1 0 3 2 1 0 2
2 1 1 2 1 1 1
1 1 2 0 1 1 1 1
5 3 1 1 3 4 3 1 3 0 1 3 2 3
7 3 1 1 3 1 3
Maximum solution for
2 3 1 1 3 5 3
primal:
3
1
x x x x y x
y y
y y
y x
x y y
y xx
x
[
2 3
1 2 3
0, 1 3, 2 3
l
0,
Minimum solution for dua
Optimal value for bot
1 3
h:
, 1
5 3
x x
y y y
50
The simplex rules as stated may lead to cycling,
even though it is rare in practical problems.
There are strategies (modified simplex methods) for
avoiding cycling.
Smallest-subscript r
Cycling
ule: If there is a choice of pivot rows
or a choice of pivot columns, select the row (or column)
with the variable having the lowest subscript, or if there
are no variables, with the varia
x
x y ble having the lowest
subscript.
51
References
• T.S. Ferguson, “Linear Programming: A Concise Introduction,” http://www.math.ucla.edu/~tom/LP.pdf .
• Lecture notes: http://www.math.cuhk.edu.hk/~wei/LP11.html
52