Part IB Optimisation
Based on lectures by F. A. Fischer
Notes taken by Dexter Chua
Easter 2015
These notes are not endorsed by the lecturers, and I have modified them (often
significantly) after lectures. They are nowhere near accurate representations of what
was actually lectured, and in particular, all errors are almost surely mine.
Lagrangian methods
General formulation of constrained problems; the Lagrangian sufficiency theorem.
Interpretation of Lagrange multipliers as shadow prices. Examples. [2]
Linear programming in the nondegenerate case
Convexity of feasible region; sufficiency of extreme points. Standardization of problems,
slack variables, equivalence of extreme points and basic solutions. The primal simplex
algorithm, artificial variables, the two-phase method. Practical use of the algorithm;
the tableau. Examples. The dual linear problem, duality theorem in a standardized
case, complementary slackness, dual variables and their interpretation as shadow prices.
Relationship of the primal simplex algorithm to dual problem. Two person zero-sum
games. [6]
Network problems
The Ford-Fulkerson algorithm and the max-flow min-cut theorems in the rational case.
Network flows with costs, the transportation algorithm, relationship of dual variables
with nodes. Examples. Conditions for optimality in more general networks; *the
simplex-on-a-graph algorithm*. [3]
Practice and applications
*Efficiency of algorithms*. The formulation of simple practical and combinatorial
problems as linear programming or network problems. [1]
Contents
1 Introduction and preliminaries
1.1 Constrained optimization
1.2 Review of unconstrained optimization
2 The method of Lagrange multipliers
2.1 Complementary Slackness
2.2 Shadow prices
2.3 Lagrange duality
2.4 Supporting hyperplanes and convexity
3 Solutions of linear programs
3.1 Linear programs
3.2 Basic solutions
3.3 Extreme points and optimal solutions
3.4 Linear programming duality
3.5 Simplex m ethod
3.5.1 The simplex tableau
3.5.2 Using the Tableau
3.6 The two-phase simplex method
4 Non-cooperative games
4.1 Games and Solutions
4.2 The minimax theorem
5 Network problems
5.1 Definitions
5.2 Minimum-cost flow problem
5.3 The transportation problem
5.4 The maximum flow problem
1 Introduction and preliminaries
1.1 Constrained optimization
In optimization, the objective is to maximize or minimize some function. For
example, if we are a factory, we want to minimize our cost of production. Often,
our optimization is not unconstrained. Otherwise, the way to minimize costs is
to produce nothing at all. Instead, there are some constraints we have to obey.
The is known as constrained optimization.
Definition
(Constrained optimization)
.
The general problem is of constrained
optimization is
minimize f (x) subject to h(x) = b, x X
where
x R
n
is the vector of decision variables,
f
:
R
n
R
is the objective
function,
h
:
R
n
R
m
and
b R
m
are the functional constraints, and
X R
n
is the regional constraint.
Note that everything above is a vector, but we do not bold our vectors. This
is since almost everything we work with is going to be a vector, and there isn’t
much point in bolding them.
This is indeed the most general form of the problem. If we want to maximize
f
instead of minimize, we can minimize
f
. If we want our constraints to be an
inequality in the form
h
(
x
)
b
, we can introduce a slack variable
z
, make the
functional constraint as
h
(
x
)
z
=
b
, and add the regional constraint
z
0. So
all is good, and this is in fact the most general form.
Linear programming is, surprisingly, the case where everything is linear. We
can write our problem as:
minimize c
T
x subject to
a
T
i
x b
i
for all i M
1
a
T
i
x b
i
for all i M
2
a
T
i
x = b
i
for all i M
3
x
i
0 for all i N
1
x
j
0 for all i N
2
where we’ve explicitly written out the different forms the constraints can take.
This is too clumsy. Instead, we can perform some tricks and turn them into
a nicer form:
Definition
(General and standard form)
.
The general form of a linear program
is
minimize c
T
x subject to Ax b, x 0
The standard form is
minimize c
T
x subject to Ax = b, x 0.
It takes some work to show that these are indeed the most general forms. The
equivalence between the two forms can be done via slack variables, as described
above. We still have to check some more cases. For example, this form says
that
x
0, i.e. all decision variables have to be positive. What if we want
x
to
be unconstrained, ie can take any value we like? We can split
x
into to parts,
x
=
x
+
x
, where each part has to be positive. Then
x
can take any positive
or negative value.
Note that when I said “nicer”, I don’t mean that turning a problem into this
form necessarily makes it easier to s olve in practice. However, it will be much
easier to work with when developing general theory about linear programs.
Example. We want to minimize (x
1
+ x
2
) subject to
x
1
+ 2x
2
6
x
1
x
2
3
x
1
, x
2
0
Since we are lucky to have a 2D problem, we can draw this out.
x
1
x
2
x
1
x
2
= 3
x
1
+ 2x
2
= 6
c
(x
1
+ x
2
) = 0 (x
1
+ x
2
) = 2 (x
1
+ x
2
) = 5
The shaded region is the feasible region, and
c
is our cost vector. The dotted lines,
which are orthogonal to
c
are lines in which the objective function is constant.
To minimize our objective function, we want the line to be as right as possible,
which is clearly achieved at the intersection of the two boundary lines.
Now we have a problem. In the general case, we have absolutely no idea how
to solve it. What we do know, is how to do unconstrained optimization.
1.2 Review of unconstrained optimization
Let
f
:
R
n
R
,
x
R
n
. A necessary condition for
x
to minimize
f
over
R
n
is f (x
) = 0, where
f =
f
x
1
, · · · ,
f
x
n
T
is the gradient of f .
However, this is obviously not a sufficient condition. Any such point can be
a maximum, minimum or a saddle. Here we need a notion of convexity:
Definition
(Convex region)
.
A region
S R
n
is convex iff for all
δ
[0
,
1],
x, y S
, we have
δx
+ (1
δ
)
y S
. Alternatively, If you take two points, the
line joining them lies completely within the region.
non-convex convex
Definition
(Convex function)
.
A function
f
:
S R
is convex if
S
is convex,
and for all x, y S, δ [0, 1], we have δf(x) + (1 δ)f(y) f(δx + (1 δ)y).
x y
δx + (1 δ)y
δf (x) + (1 δ)f (y)
A function is concave if
f
is convex. Note that a function can be neither
concave nor convex.
We have the following lemma:
Lemma.
Let
f
be twice differentiable. Then
f
is convex on a convex set
S
if
the Hessian matrix
Hf
ij
=
2
f
x
i
x
j
is positive semidefinite for all x S, where this fancy term means:
Definition
(Positive-semidefinite)
.
A matrix
H
is positive semi-definite if
v
T
Hv 0 for all v R
n
.
Which leads to the following theorem:
Theorem.
Let
X R
n
be convex,
f
:
R
n
R
be twice differentiable on
X
.
If
x
X
satisfy
f
(
x
) = 0 and
Hf
(
x
) is positive semidefinite for all
x X
,
then x
minimizes f on X.
We will not prove these.
Note that this is helpful, since linear functions are convex (and concave).
The problem is that our problems are constrained, not unconstrained. So we
will have to convert constrained problems to unconstrained problems.
2 The method of Lagrange multipliers
So how do we solve the problem of constrained maximization? The trick here
is to include the constraints into the constraints into the objective function, so
that things outside the constraint will not be thought to be minima.
Suppose the original problem is
minimize f (x) subject to h(x) = b, x X.
Call the constraint (P ).
Definition (Lagrangian). The Lagrangian of a constraint (P ) is defined as
L(x, λ) = f (x) λ
T
(h(x) b).
for λ R
m
. λ is known as the Lagrange multiplier.
Note that when the constraint is satisfied,
h
(
x
)
b
= 0, and
L
(
x, λ
) =
f
(
x
).
We could as well have used
L(x, λ) = f (x) + λ
T
(h(x) b).
since we just have to switch the sign of
λ
. So we don’t have to worry about
getting the sign of λ wrong when defining the Lagrangian.
If we minimize
L
over both
x
and
λ
, then we will magically find the minimal
solution subject to the constrains. Sometimes.
Theorem (Lagrangian sufficiency). Let x
X and λ
R
m
be such that
L(x
, λ
) = inf
xX
L(x, λ
) and h(x
) = b.
Then x
is optimal for (P).
In words, if
x
minimizes
L
for a fixed
λ
, and
x
satisfies the constraints,
then x
minimizes f .
This looks like a pretty powerful result, but it turns out that it is quite easy
to prove.
Proof.
We first define the “feasible set”: let
X
(
b
) =
{x X
:
h
(
x
) =
b}
, i.e. the
set of all x that satisfies the constraints. Then
min
xX(b)
f(x) = min
xX(b)
(f(x) λ
T
(h(x) b)) since h(x) b = 0
min
xX
(f(x) λ
T
(h(x) b))
= f(x
) λ
T
(h(x
) b).
= f(x
).
How can we interpret this result? To find these values of
λ
and
x
, we have
to solve
L = 0
h(x) = b.
Alternatively, we can write this as
f = λh
h(x) = b.
What does this mean? For better visualization, we take the special case where
f
and
h
are a functions
R
2
R
. Usually, if we want to minimize
f
without
restriction, then for small changes in
x
, there should be no (first-order) change
in f , i.e. df = f · dx = 0. This has to be true for all possible directions of x.
However, if we are constrained by
h
(
x
) =
b
, this corresponds to forcing
x
to
lie along this particular path. Hence the restriction d
f
= 0 only has to hold when
x
lies along the path. Since we need
f ·
d
x
= 0, this means that
f
has to be
perp endicular to d
x
. Alternatively,
f
has to be parallel to the normal to the
path. Since the normal to the path is given by
h
, we obtain the requirement
f = λh.
This is how we should interpret the condition
f
=
λh
. Instead of requiring
that
f
= 0 as in usual minimization problems, we only require
f
to point at
directions perpendicular to the allowed space.
Example. Minimize x
1
+ x
2
2x
3
subject to
x
1
+ x
2
+ x
3
= 5
x
2
1
+ x
2
2
= 4
The Lagrangian is
L(x, λ) = x
1
x
2
2x
3
λ
1
(x
1
+ x
2
+ x
3
5) λ
2
(x
2
1
+ x
2
2
4)
= ((1 λ
1
)x
1
2λ
2
x
2
1
) + ((1 λ
1
)x
2
λ
2
x
2
2
)
+ (2 λ
1
)x
3
+ 5λ
1
+ 4λ
2
We want to pick a
λ
and
x
such that
L
(
x
, λ
) is minimal. Then in particular,
for our λ
, L(x, λ
) must have a finite minimum.
We note that (
2
λ
1
)
x
3
does not have a finite minimum unless
λ
1
=
2,
since
x
3
can take any value. Also, the terms in
x
1
and
x
2
do not have a finite
minimum unless λ
2
< 0.
With these in mind, we find a minimum by setting all first derivatives to be
0:
L
x
1
= 1 λ
1
2λ
2
x
1
= 3 2λ
2
x
1
L
x
2
= 1 λ
1
2λ
2
x
2
= 1 2λ
2
x
2
Since these must be both 0, we must have
x
1
=
3
2λ
2
, x
2
=
1
2λ
2
.
To show that this is indeed a minimum, we look at the Hessian matrix:
HL =
2λ
2
0
0 2λ
2
which is positive semidefinite when
λ
2
<
0, which is the condition we came up
with at the beginning.
Let Y = {λ : R
2
: λ
1
= 2, λ
2
< 0} be our helpful values of λ.
So we have shown above that for every
λ Y
,
L
(
x, λ
) has a unique minimum
at x(λ) = (
3
2λ
2
,
1
2λ2
, x
3
)
T
.
Now all we have to do is find
λ
and
x
such that
x
(
λ
) satisfies the functional
constraints. The second constraint gives
x
2
1
+ x
2
2
=
9
4λ
2
+
1
4λ
2
2
= 4 λ
2
=
r
5
8
.
The first constraint gives
x
3
= 5 x
1
x
2
.
So the theorem implies that
x
1
= 3
r
2
5
, x
2
=
r
2
5
, x
3
= 5 + 4
r
2
5
.
So far so good. But what if our functional constraint is an inequality? We
will need slack variables.
To minimize f(x) subject to h(x) b, x X, we proceed as follows:
(i)
Introduce slack variables to obtain the equivalent problem, to minimize
f(x) subject to h(x) + z = b, x X, z 0.
(ii) Compute the Lagrangian
L(x, z, λ) = f(x) λ
T
(f(x) + z b).
(iii) Find
Y =
λ : inf
xX,z0
L(x, z, λ) > −∞
.
(iv) For each λ Y , minimize L(x, z, λ), i.e. find
x
(λ) X, z
(λ) 0
such that
L(x
(λ), z
(λ), λ) = inf
xX,z0
L(x, z, λ)
(v) Find λ
Y such that
h(x
(λ
)) + z
(λ
) = b.
Then by the Lagrangian sufficiency condition,
x
(
λ
) is optimal for the con-
strained problem.
2.1 Complementary Slackness
If we introduce a slack variable
z
, we note that changing the value of
z
j
does not
affect our objective function, and we are allowed to pick any positive
z
. Hence if
the corresponding Lagrange multiplier is
λ
j
, then we must have (
z
(
λ
))
j
λ
j
= 0.
This is since by definition
z
(
λ
)
j
minimizes
z
j
λ
j
. Hence if
z
j
λ
j
6
= 0, we can
tweak the values of z
j
to make a smaller z
j
λ
j
.
This makes our life easier since our search space is smaller.
Example. Consider the following problem:
maximize x
1
3x
2
subject to
x
2
1
+ x
2
2
+ z
1
= 4
x
1
+ x
2
+ z
2
+ z
2
= 2
z
1
, z
2
0.
where z
1
, z
2
are slack variables.
The Lagrangian is
L(x, z, λ) = ((1 λ
2
)x
1
λ
1
x
2
1
)+((3λ
2
)x
2
λ
1
x
2
2
)λ
1
z
1
λ
2
z
2
+4λ
1
+2λ
2
.
To ensure finite minimum, we need λ
1
, λ
2
0.
By complementary slackness,
λ
1
z
1
=
λ
2
z
2
= 0. We can then consider the
cases λ
1
= 0 and z
1
= 0 separately, and save a lot of algebra.
2.2 Shadow prices
We have previously described how we can understand the requirement
f
=
λh
.
But what does the multiplier λ represent?
Theorem. Consider the problem
minimize f (x) subject to h(x) = b.
Here we assume all functions are continuously differentiable. Suppose that for
each
b R
n
,
φ
(
b
) is the optimal value of
f
and
λ
is the corresponding Lagrange
multiplier. Then
φ
b
i
= λ
i
.
Proof is omitted, as it is just a tedious application of chain rule etc.
This can be interpreted as follows: suppose we are a factory which is capable
of producing
m
different kinds of goo ds. Since we have finitely many resources,
and producing stuff requires resources,
h
(
x
) =
b
limits the amount of goods we
can produce. Now of course, if we have more resources, i.e. we change the value
of
b
, we will be able to produce more/less stuff, and thus generate more profit.
The change in profit per change in b is given by
φ
b
i
, which is the value of λ.
The result also holds when the functional constraints are inequality con-
straints. If the
i
th constraint holds with equality at the optimal solution, then
the above reasoning holds. Otherwise, if it is not held with equality, then the
Lagrange multiplier is 0 by complementary slackness. Also, the partial derivative
of
φ
with respect to
b
i
also has to be 0, since changing the upper bound doesn’t
affect us if we are not at the limit. So they are equal.
2.3 Lagrange duality
Consider the problem
minimize f (x) subject to h(x) = b, x X.
Denote this as P.
The Lagrangian is
L(x, λ) = f (x) λ
T
(h(x) b).
Define the dual function g : R
m
R as
g(λ) = inf
xX
L(x, λ).
ie, we fix λ, and see how small we can get L to be. As before, let
Y = {λ R
n
: g(λ) > −∞}.
Then we have
Theorem (Weak duality). If x X(b) (i.e. x satisfies both the functional and
regional constraints) and λ Y , then
g(λ) f(x).
In particular,
sup
λY
g(λ) inf
xX(b)
f(x).
Proof.
g(λ) = inf
x
0
X
L(x
0
, λ)
L(x, λ)
= f(x) λ
T
(h(x) b)
= f(x).
This suggests that we can solve a dual problem - instead of minimizing
f
,
we can maximize
g
subject to
λ Y
. Denote this problem as (
D
). The original
problem (P ) is called primal.
Definition (Strong duality). (P ) and (D) are said to satisfy strong duality if
sup
λY
g(λ) = inf
xX(b)
f(x).
It turns out that problems satisfying strong duality are exactly those for
which the method of Lagrange multipliers work.
Example. Again consider the problem to minimize x
1
x
2
2x
3
subject to
x
1
+ x
2
+ x
3
= 5
x
2
1
+ x
2
2
= 4
We saw that
Y = {λ R
2
: λ
1
= 2, λ
2
< 0}
and
x
(λ) =
3
2λ
2
,
1
2λ
2
, 5
4
2λ
2
.
The dual function is
g(λ) = inf
xX
L(x, λ) = L(x
(λ), λ) =
10
4λ
2
+ 4λ
2
10.
The dual is the problem to
maximize
10
4λ
2
+ 4λ
2
10 subject to λ
2
< 0.
The maximum is attained for
λ
2
=
r
5
8
After calculating the values of
g
and
f
, we can see that the primal and dual do
have the same optimal value.
Right now, what we’ve got isn’t helpful, because we won’t know if our problem
satisfies strong duality!
2.4 Supporting hyperplanes and convexity
We use the fancy term “hyperplane” to denote planes in higher dimensions (in
an n-dimensional space, a hyperplane has n 1 dimensions).
Definition
(Supporting hyperplane)
.
A hyperplane
α
:
R
m
R
is supporting
to φ at b if α intersects φ at b and φ(c) α(c) for all c.
x
φ
φ(b)
α
Theorem.
(
P
) satisfies strong duality iff
φ
(
c
) =
inf
xX(c)
f
(
x
) has a supporting
hyperplane at b.
Note that here we fix a b, and let φ be a function of c.
Proof.
(
) Suppose there is a supporting hyperplane. Then since the plane
passes through φ(b), it must be of the form
α(c) = φ(b) + λ
T
(c b).
Since this is supporting, for all c R
m
,
φ(b) + λ
T
(c b) φ(c),
or
φ(b) φ(c) λ
T
(c b),
This implies that
φ(b) inf
cR
m
(φ(c) λ
T
(c b))
= inf
cR
m
inf
xX(c)
(f(x) λ
T
(h(x) b))
(since φ(c) = inf
xX(c)
f(x) and h(x) = c for x X(c))
= inf
xX
L(x, λ).
(since
S
cR
m
X
(
c
) =
X
, which is true since for any
x X
, we have
x X
(
h
(
x
)))
= g(λ)
By weak duality, g(λ) φ(b). So φ(b) = g(λ). So strong duality holds.
(
). Assume now that we have strong duality. The there exists
λ
such that
for all c R
m
,
φ(b) = g(λ)
= inf
xX
L(x, λ)
inf
xX(c)
L(x, λ)
= inf
xX(c)
(f(x) λ
T
(h(x) b))
= φ(c) λ
T
(c b)
So φ(b) + λ
T
(c b) φ(c). So this defines a supporting hyperplane.
We are having some progress now. To show that Lagrange multipliers work,
we need to show that (
P
) satisfies strong duality. To show that (
P
) satisfies
strong duality, we need to show that it has a supporting hyperplane at
b
. How
can we show that there is a supporting hyperplane? A sufficient condition is
convexity.
Theorem
(Supporting hyperplane theorem)
.
Suppose that
φ
:
R
m
R
is
convex and
b R
m
lies in the interior of the set of points where
φ
is finite. Then
there exists a supporting hyperplane to φ at b.
Proof follows rather straightforwardly from the definition of convexity, and
is omitted.
This is some even better progress. However, the definition of
φ
is rather
convoluted. How can we show that it is convex? We have the following helpful
theorem:
Theorem. Let
φ(b) = inf
xX
{f(x) : h(x) b}
If X, f, h are convex, then so is φ (assuming feasibility and boundedness).
Proof.
Consider
b
1
, b
2
R
m
such that
φ
(
b
1
) and
φ
(
b
2
) are defined. Let
δ
[0
,
1]
and define
b
=
δb
1
+(1
δ
)
b
2
. We want to show that
φ
(
b
)
δφ
(
b
1
)+(1
δ
)
φ
(
b
2
).
Consider
x
1
X
(
b
1
),
x
2
X
(
b
2
), and let
x
=
δx
1
+ (1
δ
)
x
2
. By convexity
of X, x X.
By convexity of h,
h(x) = h(δx
1
+ (1 δ)x
2
)
δh(x
1
) + (1 δ)h(x
2
)
δb
1
+ (1 δ)b
2
= b
So x X(b). Since φ(x) is an optimal solution, by convexity of f ,
φ(b) f (x)
= f(δx
1
+ (1 δ)x
2
)
δf(x
1
) + (1 δ)f(x
2
)
This holds for any
x
1
X
(
b
1
) and
x
2
X
(
b
2
). So by taking infimum of the
right hand side,
φ(b) δφ(b
1
) + (1 δ)φ(b
2
).
So φ is convex.
h
(
x
) =
b
is equivalent to
h
(
x
)
b
and
h
(
x
)
b
. So the result holds for
problems with equality constraints if both
h
and
h
are convex, i.e. if
h
(
x
) is
linear.
So
Theorem.
If a linear program is feasible and bounded, then it satisfies strong
duality.
3 Solutions of linear programs
3.1 Linear programs
We’ll come up with an algorithm to solve linear program efficiently. We first
illustrate the general idea with the case of a 2D linear program. Consider the
problem
maximize x
1
+ x
2
subject to
x
1
+ 2x
2
6
x
1
x
2
3
x
1
, x
2
0
We can plot the solution space out
x
1
x
2
x
1
x
2
= 3
x
1
+ 2x
2
= 6
c
To maximize
x
1
+
x
2
, we want to go as far in the
c
direction as possible. It
should be clear that the optimal point will lie on a corner of the polygon of
feasible region, no matter what the shape of it might be.
Even if we have cases where c is orthogonal to one of the lines, eg
x
1
x
2
x
1
x
2
= 3
x
1
+ x
2
= 3.5
c
A
An optimal point might be
A
. However, if we know that
A
is an optimal point,
we can slide it across the
x
1
+
x
2
= 3
.
5 line until it meets one of the corners.
Hence we know that one of the corners must be an optimal point.
This already allows us to solve linear programs, since we can just try all
corners and see which has the smallest value. However, this can be made more
efficient, especially when we have a large number of dimensions and hence
corners.
3.2 Basic solutions
Here we will assume that the rows of
A
are linearly independent, and any set
of
m
columns are linearly independent. Otherwise, we can just throw away the
redundant rows or columns.
In general, if both the constraints and the objective functions are linear, then
the optimal point always lies on a “corner”, or an extreme point.
Definition
(Extreme point)
.
An extreme point
x S
of a convex set
S
is a
point that cannot be written as a convex combination of two distinct points in
S, i.e. if y, z S and δ (0, 1) satisfy
x = δy + (1 δ)z,
then x = y = z.
Consider again the linear program in standard form, i.e.
maximize c
T
x subject to Ax = b, x 0, where A R
m×n
and b R
m
.
Note that now we are talking about maximization instead of minimization.
Definition
(Basic solution and basis)
.
A solution
x R
n
is basic if it has at
most
m
non-zero entries (out of
n
), i.e. if there exists a set
B {
1
, · · · , n}
with
|B|
=
m
such that
x
i
= 0 if
i 6∈ B
. In this case,
B
is called the basis, and
x
i
are
the basic variables if i B.
We will later see (via an example) that basic solutions correspond to solutions
at the “corners” of the solution space.
Definition
(Non-degenerate solutions)
.
A basic solution is non-degenerate if it
has exactly m non-zero entries.
Note that by “solution”, we do not mean a solution to the whole maximization
problem. Instead we are referring to a solution to the constraint
Ax
=
b
. Being a
solution does not require that
x
0. Those that satisfy this regional constraint
are known as feasible.
Definition
(Basic feasible solution)
.
A basic solution
x
is feasible if it satisfies
x 0.
Example. Consider the linear program
maximize f (x) = x
1
+ x
2
subject to
x
1
+ 2x
2
+ z
1
= 6
x
1
x
2
+ z
2
= 3
x
1
, x
2
, z
1
, z
2
0
where we have included the slack variables.
Since we have 2 constraints, a basic solution would require 2 non-zero entries,
and thus 2 zero e ntries. The possible basic solutions are
x
1
x
2
z
1
z
2
f(x)
A 0 0 6 3 0
B 0 3 0 6 3
C 4 1 0 0 5
D 3 0 3 0 3
E 6 0 0 4 6
F 0 3 12 0 3
Among all 6,
E
and
F
are not feasible solutions since they have negative entries.
So the basic feasible solutions are A, B, C, D.
A B
C
D
x
1
x
2
x
1
x
2
= 3
x
1
+ 2x
2
= 6
E
F
In previous example, we saw that the extreme points are exactly the basic
feasible solutions. This is true in general.
Theorem.
A vector
x
is a basic feasible solution of
Ax
=
b
if and only if it is
an extreme point of the set X(b) = {x
0
: Ax
0
= b, x
0
0}.
We will not prove this.
3.3 Extreme points and optimal solutions
Recall that we previously showed in our 2D example that the optimal solution
lies on an extreme point, i.e. is a basic feasible solution. This is also true in
general.
Theorem.
If (
P
) is feasible and bounded, then there exists an optimal solution
that is a basic feasible solution.
Proof.
Let
x
be optimal of (
P
). If
x
has at most non-zero entries, it is a basic
feasible solution, and we are done.
Now suppose
x
has
r > m
non-zero entries. Since it is not an extreme point,
we have y 6= z X(b), δ (0, 1) such that
x = δy + (1 δ)z.
We will show there exists an optimal solution strictly fewer than
r
non-zero
entries. Then the result follows by induction.
By optimality of x, we have c
T
x c
T
y and c
T
x c
T
z.
Since
c
T
x
=
δc
T
y
+ (1
δ
)
c
T
z
, we must have that
c
T
x
=
c
T
y
=
c
T
z
, i.e.
y
and z are also optimal.
Since
y
0 and
z
0,
x
=
δy
+ (1
δ
)
z
implies that
y
i
=
z
i
= 0 whenever
x
i
= 0.
So the non-zero entries of
y
and
z
is a subset of the non-zero entries of
x
. So
y
and
z
have at most
r
non-zero entries, which must occur in rows where
x
is
also non-zero.
If
y
or
z
has strictly fewer than
r
non-zero entries, then we are done. Other-
wise, for any
ˆ
δ (not necessarily in (0, 1)), let
x
ˆ
δ
=
ˆ
δy + (1
ˆ
δ)z = z +
ˆ
δ(y z).
Observe that x
ˆ
δ
is optimal for every
ˆ
δ R.
Moreover,
y z 6
= 0, and all non-zero entries of
y z
occur in rows where
x
is non-zero as well. We can thus choose
ˆ
δ R
such that
x
ˆ
δ
0 and
x
ˆ
δ
has
strictly fewer than r non-zero entries.
Intuitively, this is what we do when we “slide along the line” if
c
is orthogonal
to one of the boundary lines.
This result in fact holds more generally for the maximum of a convex function
f over a compact (i.e. closed and bounded) convex set X.
In that case, we can write any point x X as a convex combination
x =
k
X
i=1
δ
i
x
i
of extreme points x
k
X, where δ R
k
0
and
P
k
i=1
δ
i
= 1.
Then, by convexity of f,
f(x)
k
X
i=1
δ
i
f(x
i
) max
i
f(x
i
)
So any point in the interior cannot be better than the extreme points.
3.4 Linear programming duality
Consider the linear program in general form with slack variables,
minimize c
T
x subject to Ax z = b, x, z 0
We have X = {(x, z) : x, z 0} R
m+n
.
The Lagrangian is
L(x, z, λ) = c
T
x λ
T
(Ax z b) = (c
T
λ
T
A)x + λ
T
z + λ
T
b.
Since x, z can be arbitrarily positive, this has a finite minimum if and only if
c
T
λ
T
A 0, λ
T
0.
Call the feasible set
Y
. Then for fixed
λ Y
, the minimum of
L
(
x, z, λ
) is
attained when (c
T
λ
T
A)x and λ
T
z = 0 by complementary slackness. So
g(λ) = inf
(x,z)X
L(x, z, λ) = λ
T
b.
The dual is thus
maximize λ
T
b subject to A
T
λ c, λ 0
Theorem. The dual of the dual of a linear program is the primal.
Proof.
It suffices to show this for the linear program in general form. We have
shown above that the dual problem is
minimize b
T
λ subject to A
T
λ c, λ 0.
This problem has the same form as the primal, with
b
taking the role of
c
,
c
taking the role of
b
,
A
T
taking the role of
A
. So doing it again, we get back to
the original problem.
Example. Let the primal problem be
maximize 3x
1
+ 2x
2
subject to
2x
1
+ x
2
+ z
1
= 4
2x
1
+ 3x
2
+ z
2
= 6
x
1
, x
2
, z
1
, z
2
0.
Then the dual problem is
minimize 4λ
1
+ 6λ
2
such that
2λ
1
+ 2λ
2
µ
1
= 3
λ
1
+ 3λ
2
µ
2
= 2
λ
1
, λ
2
, µ
1
, µ
2
0.
We can compute all basic solutions of the primal and the dual by setting
nm
2
variables to be zero in turn.
Given a particular basic solutions of the primal, the corresponding solutions
of the dual can be found by using the complementary slackness solutions:
λ
1
z
1
= λ
2
z
2
= 0, µ
1
x
1
= µ
2
x
2
= 0.
x
1
x
2
z
1
z
2
f(x) λ
1
λ
2
µ
1
µ
2
g(λ)
A 0 0 4 6 0 0 0 -3 -2 0
B 2 0 0 2 6
3
2
0 0
1
2
6
C 3 0 -2 0 9 0
3
2
0
5
2
9
D
3
2
1 0 0
13
2
5
4
1
4
0 0
13
2
E 0 2 2 0 4 0
2
3
5
3
0 4
F 0 4 0 -6 8 2 0 1 0 8
A B
D
E
C
F
x
1
x
2
2x
1
+ x
2
= 4
2x
1
+ 3x
2
= 6
C
D
F
A
B
E
λ
1
λ
2
2λ
1
+ 2λ
2
= 3
λ
1
+ 3λ
2
= 2
We see that
D
is the only solution such that both the primal and dual solutions
are feasible. So we know it is optimal without even having to calculate
f
(
x
). It
turns out this is always the case.
Theorem.
Let
x
and
λ
be feasible for the primal and the dual of the linear
program in general form. Then
x
and
λ
and optimal if and only if they satisfy
complementary slackness, i.e. if
(c
T
λ
T
A)x = 0 and λ
T
(Ax b) = 0.
Proof. If x and λ are optimal, then
c
T
x = λ
T
b
since every linear program satisfies strong duality. So
c
T
x = λ
T
b
= inf
x
0
X
(c
T
x
0
λ
T
(Ax
0
b))
c
T
x λ
T
(Ax b)
c
T
x.
The last line is since Ax b and λ 0.
The first and last term are the same. So the inequalities hold with equality.
Therefore
λ
T
b = c
T
x λ
T
(Ax b) = (c
T
λ
T
A)x + λ
T
b.
So
(c
T
λ
T
A)x = 0.
Also,
c
T
x λ
T
(Ax b) = c
T
x
implies
λ
T
(Ax b) = 0.
On the other hand, suppose we have complementary slackness, i.e.
(c
T
λ
T
A)x = 0 and λ
T
(Ax b) = 0,
then
c
T
x = c
T
x λ
T
(Ax b) = (c
T
λ
T
A)x + λ
T
b = λ
T
b.
Hence by weak duality, x and λ are optimal.
3.5 Simplex method
The simplex method is an algorithm that makes use of the result we just had.
To find the optimal solution to a linear program, we start with a basic feasible
solution of the primal, and then modify the variables step by step until the dual
is also feasible.
We start with an example, showing what we do, then explain the logic behind,
then do a more proper example.
Example. Consider the following problem:
maximize x
1
+ x
2
subject to
x
1
+ 2x
2
+ z
1
= 6
x
1
x
2
+ z
2
= 3
x
1
, x
2
, z
1
, z
2
0.
We write everything in the simplex tableau, by noting down the coefficients:
x
1
x
2
z
1
z
2
Constraint 1 1 2 1 0 6
Constraint 2 1 -1 0 1 3
Objective 1 1 0 0 0
We see an identity matrix
1 0
0 1
in the
z
1
and
z
2
columns, and these correspond
to basic feasible solution: z
1
= 6, z
2
= 3, x
1
= x
2
= 0. It’s pretty clear that our
basic feasible solution is not optimal, since our objective function is 0. This is
since something in the last row is positive, and we can increase the objective by,
say, increasing x
1
.
The simplex method says that we can find the optimal solution if we make
the bottom row all negative while keeping the right column positive, by doing
row operations.
We multiply the first row by
1
2
and subtract/add it to the other rows to
obtain
x
1
x
2
z
1
z
2
Constraint 1
1
2
1
1
2
0 3
Constraint 2
2
3
0
1
2
1 6
Objective
1
2
0
1
2
0 -3
Our new basic feasible solution is
x
2
= 3
, z
2
= 6
, x
1
=
z
1
= 0. We see that the
number in the bottom-right corner is
f
(
x
). We can continue this process to
finally obtain a solution.
Here we adopt the following notation: let
A R
m×n
and
b R
m
. Assume
that
A
has full rank. Let
B
be a basis and set
B {
1
,
2
, · · · , n}
with
|B|
=
m
,
corresponding to at most m non-zero entries.
We rearrange the columns so that all basis columns are on the left. Then we
can write our matrices as
A
m×n
=
(A
B
)
m×m
(A
N
)
m×(nm)
x
n×1
=
(x
B
)
m×1
(x
N
)
(nm)×1
T
c
1×n
=
(c
B
)
m×1
(c
N
)
(nm)×1
.
Then the functional constraints
Ax = b
can be decomposed as
A
B
x
B
+ A
N
x
N
= b.
We can rearrange this to obtain
x
B
= A
1
B
(b A
N
x
N
).
In particular, when x
N
= 0, then
x
B
= A
1
B
b.
The general tableau is then
Basis c omponents Other components
A
1
B
A
B
= I A
1
B
A
N
A
1
B
b
c
T
B
c
T
B
A
1
B
A
B
= 0 c
T
N
c
T
B
A
1
B
A
N
c
T
B
A
1
B
b
This might look really scary, and it is! Without caring too much about how the
formulas for the cells come from, we see the identity matrix on the left, which is
where we find our basic feasible solution. Below that is the row for the objective
function. The values of this row must be 0 for the basis columns.
On the right-most column, we have
A
1
B
b
, which is our
x
B
. Below that is
c
T
B
A
1
B
b, which is the negative of our objective function c
T
B
x
B
.
3.5.1 The simplex tableau
We have
f(x) = c
T
x
= c
T
B
x
B
+ c
T
N
x
N
= c
T
B
A
1
B
(b A
N
x
N
) + c
T
N
x
N
= c
T
B
A
1
B
b + (c
T
N
c
T
B
A
1
B
A
N
)x
N
.
We will maximize
c
T
x
by choosing a basis such that
c
T
N
c
T
B
A
1
B
A
N
0, i.e.
non-positive everywhere and A
1
B
b 0.
If this is true, then for any feasible solution
x R
n
, we must have
x
N
0.
So (c
T
N
c
T
B
A
1
B
A
N
)x
N
0 and
f(x) c
T
B
A
1
B
b.
So if we choose x
B
= A
1
B
b, x
N
= 0, then we have an optimal solution.
Hence our objective is to pick a basis that makes
c
T
N
c
T
B
A
1
B
A
N
0
while keeping
A
1
B
b
0. To do this, suppose this is not attained. Say (
c
T
N
c
T
B
A
1
B
A
N
)
i
> 0.
We can increase the value of the objective function by increasing (
x
N
)
i
. As
we increase (
x
N
)
i
, we have to satisfy the functional constraints. So the value of
other variables will change as well. We can keep increasing (
x
N
)
i
until another
variable hits 0, say (x
B
)
j
. Then we will have to stop.
(However, if it so happens that we can increase (
x
N
)
i
indefinitely without
other things hitting 0, our problem is unbounded)
The effect of this is that we have switched basis by removing (
x
B
)
j
and
adding (
x
N
)
i
. We can continue from here. If (
c
T
N
c
T
B
A
1
B
A
N
) is negative, we
are done. Otherwise, we continue the above procedure.
The simplex method is a systematic way of doing the above procedure.
3.5.2 Using the Tableau
Consider a tableau of the form
a
ij
a
i0
a
0j
a
00
where a
i0
is b, a
0j
corresponds to the objective function, and a
00
is initial 0.
The simplex method proceeds as follows:
(i) Find an initial basic feasible solution.
(ii)
Check whether
a
0j
0 for every
j
. If so, the current solution is optimal.
Stop.
(iii)
If not, choose a pivot column
j
such that
a
0j
>
0. Choose a pivot row
i {i
:
a
ij
>
0
}
that minimizes
a
i0
/a
ij
. If multiple rows are minimize
a
i0
/a
ij
, then the problem is degenerate, and things might go wrong. If
a
ij
0 for all
i
, i.e. we cannot choose a pivot row, the problem is unbounded,
and we stop.
(iv)
We update the tableau by multiplying row
i
by 1
/a
ij
(such that the new
a
ij
= 1), and add a (
a
kj
/a
ij
) multiple of row
i
to each row
k 6
=
i
,
including k = 0 (so that a
kj
= 0 for all k 6= i)
We have a basic feasible solution, since our choice of
a
ij
makes all right-hand
columns positive after subtracting (apart from a
00
).
(v) GOTO (ii).
Now visit the example at the beginning of the section to see how this is done
in practice. Then read the next section for a more complicated example.
3.6 The two-phase simplex method
Sometimes we don’t have a nice identity matrix to start with. In this case, we
need to use the two-phase simplex method to first find our first basic feasible
solution, then to the actual optimization.
This method is illustrated by example.
Example. Consider the problem
minimize 6x
1
+ 3x
2
subject to
x
1
+ x
2
1
2x
1
x
2
1
3x
2
2
x
1
, x
2
0
This is a minimization problem. To avoid being confused, we maximize
6
x
1
3
x
2
instead. We add slack variables to obtain
maximize 6x
1
3x
2
subject to
x
1
+ x
2
z
1
= 1
2x
1
x
2
z
2
= 1
3x
2
+ z
3
= 2
x
1
, x
2
, z
1
, z
2
, z
3
0
Now we don’t have a basic feasible solution, since we would need
z
1
=
z
2
=
1
, z
3
= 2, which is not feasible. So we add more variables, called the artificial
variables.
maximize 6x
1
3x
2
subject to
x
1
+ x
2
z
1
+ y
1
= 1
2x
1
x
2
z
2
+ y
2
= 1
3x
2
+ z
3
= 2
x
1
, x
2
, z
1
, z
2
, z
3
, y
1
, y
2
0
Note that adding
y
1
and
y
2
might create new solutions, which is bad. We solve
this problem by first trying to make
y
1
and
y
2
both 0 and find a basic feasible
solution. Then we can throw away
y
1
and
y
2
and then get a basic feasible for
our original problem. So momentarily, we want to solve
minimize y
1
+ y
2
subject to
x
1
+ x
2
z
1
+ y
1
= 1
2x
1
x
2
z
2
+ y
2
= 1
3x
2
+ z
3
= 2
x
1
, x
2
, z
1
, z
2
, z
3
, y
1
, y
2
0
By minimizing y
1
and y
2
, we will make them zero.
Our simplex tableau is
x
1
x
2
z
1
z
2
z
3
y
1
y
2
1 1 -1 0 0 1 0 1
2 -1 0 -1 0 0 1 1
0 3 0 0 1 0 0 2
-6 -3 0 0 0 0 0 0
0 0 0 0 0 -1 -1 0
Note that we keep both our original and “kill-
y
i
objectives, but now we only
care about the second one. We will keep track of the original objective so that
we can use it in the second phase.
We see an initial feasible solution
y
1
=
y
2
= 1
, z
3
= 2. However, this is not a
proper simplex tableau, as the basis columns should not have non-zero entries
(apart from the identity matrix itself). But we have the two
1s at the b ottom!
So we add the first two rows to the last to obtain
x
1
x
2
z
1
z
2
z
3
y
1
y
2
1 1 -1 0 0 1 0 1
2 -1 0 -1 0 0 1 1
0 3 0 0 1 0 0 2
-6 -3 0 0 0 0 0 0
3 0 -1 -1 0 0 0 2
Our pivot column is
x
1
, and our pivot row is the second row. We divide it by 1
and add/subtract it from other rows.
x
1
x
2
z
1
z
2
z
3
y
1
y
2
0
3
2
-1
1
2
0 1
1
2
1
2
1
1
2
0
1
2
0 0
1
2
1
2
0 3 0 0 1 0 0 2
0 -6 0 -3 0 0 3 3
0
3
2
1
1
2
0 0
3
2
1
2
There are two possible pivot columns. We pick
z
2
and use the first row as the
pivot row.
x
1
x
2
z
1
z
2
z
3
y
1
y
2
0 3 -2 1 0 2 -1 1
1 1 -1 0 0 1 0 1
0 3 0 0 1 0 0 2
0 3 -6 0 0 6 0 6
0 0 0 0 0 -1 -1 0
We see that
y
1
and
y
2
are no longer in the basis, and hence take value 0. So we
drop all the phase I stuff, and are left with
x
1
x
2
z
1
z
2
z
3
0 3 -2 1 0 1
1 1 -1 0 0 1
0 3 0 0 1 2
0 3 -6 0 0 6
We see a basic feasible solution z
1
= x
1
= 1, z
3
= 2.
We pick
x
2
as the pivot column, and the first row as the pivot row. Then we
have
x
1
x
2
z
1
z
2
z
3
0 1
2
3
1
3
0
1
3
1 0
1
3
1
3
0
2
3
0 0 2 -1 1 1
0 0 -4 -1 0 5
Since the last row is all negative, we have complementary slackness. So this
is a optimal solution. So
x
1
=
2
3
, x
2
=
1
3
, z
3
= 1 is a feasible solution, and our
optimal value is 5.
Note that we previously said that the bottom right entry is the negative
of the optimal value, not the optimal value itself! This is correct, since in the
tableau, we are maximizing
6
x
1
3
x
2
, whose maximum value is
5. So the
minimum value of 6x
1
+ 3x
2
is 5.
4 Non-cooperative games
Here we have a short digression to game theory. We mostly focus on games with
two players.
4.1 Games and Solutions
Definition
(Bimatrix game)
.
A two-player game, or bimatrix game, is given
by two matrices
P, Q R
m×n
. Player 1, or the row player, chooses a row
i
{
1
, · · · , m}
, while player 2, the column player, chooses a column
j {
1
, · · · , n}
.
These are selected without knowledge of the other player’s decisions. The two
players then get payoffs P
ij
and Q
ij
respectively.
Example. A game of rock-paper-scissors can have payoff matrices
P
ij
=
0 1 1
1 0 1
1 1 0
, Q
ij
=
0 1 1
1 0 1
1 1 0
.
Here a victory gives you a payoff of 1, a loss gives a payoff of
1, and a draw
gives a payoff of 1. Also the first row/column corresponds to playing rock, second
corresponds to paper and third corresponds to scissors.
Usually, this is not the best way to display the payoff matrices. First of all,
we need two write out two matrices, and there isn’t an easy way to indicate what
row corresponds to what decision. Instead, we usually write this as a table.
R P S
R (0, 0) (1, 1) (1, 1)
P (1, 1) (0, 0) (1, 1)
S (1, 1) (1, 1) (0, 0)
By convention, the first item in the tuple (
1
,
1) indicates the payoff of the row
player, and the second item indicates the payoff of the column player.
Definition
(Strategy)
.
Players are allowed to play randomly. The set of strate-
gies the row player can have is
X = {x R
m
: x 0,
X
x
i
= 1}
and the column player has strategies
Y = {y R
n
: y 0,
X
y
i
= 1}
Each vector corresponds to the probabilities of selecting each row or column.
A strategy profile (
x, y
)
X × Y
induces a lottery, and we write
p
(
x, y
) =
x
T
P y for the expected payoff of the row player.
If x
i
= 1 for some i, i.e. we always pick i, we call x a pure strategy.
Example
(Prisoner’s dilemma)
.
Suppose Alice and Bob commit a crime together,
and are caught by the police. They can choose to remain silent (
S
) or testify
(T ). Different options will lead to different outcomes:
Both keep silent: the police has little evidence and they go to jail for 2
years.
One testifies and one remains silent: the one who testifies gets awarded
and is freed, while the other gets stuck in jail for 10 years.
Both testify: they both go to jail for 5 years.
We can represent this by a payoff table:
S T
S (2, 2) (0, 3)
T (3, 0) (1, 1)
Note that higher payoff is desired, so a longer serving time corresponds to a
lower payoff. Also, payoffs are interpreted relatively, so replacing (0
,
3) with
(0, 100) (and (3, 0) with (100, 0)) in the payoff table would make no difference.
Here we see that regardless of what the other person does, it is always strictly
better to testify than not (unless you want to be nice). We say
T
is a dominant
strategy, and (1, 1) is Pareto dominated by (2, 2).
Example
(Chicken)
.
The game of Chicken is as follows: two people drive their
cars towards each other at high speed. If they collide, they will di.e. Hence they
can decide to chicken out (
C
) or continue driving (
D
). If both don’t chicken,
they die, which is bad. If one chickens and the other doesn’t the person who
chicken looks silly (but doesn’t die). If both chicken out, they both look slightly
silly. This can be represented by the following table:
C D
C (2, 2) (1, 3)
D (3, 1) (0, 0)
Here there is no dominating strategy, so we need a different way of dec iding
what to do.
Instead, we define the security level of the row player to be
max
xX
min
yY
p(x, y) = max
xX
min
j∈{1,...,n}
m
X
i=1
x
i
p
ij
.
Such an
x
is the strategy the row player can employ that minimizes the worst
possible loss. This is called the maximin strategy.
We can formulate this as a linear program:
maximize v such that
m
X
i=1
x
i
p
ij
v for all j = 1, · · · , n
m
X
i=1
x
i
= 1
x 0
Here the maximin strategy is to chicken. However, this isn’t really what we
are looking for, since if both players employ this maximin strategy, it would be
better for you to not chicken out.
Definition
(Best response and equilibrium)
.
A strategy
x X
is a best response
to y Y if for all x
0
X
p(x, y) p(x
0
, y)
A pair (
x, y
) is an equilibrium if
x
is the best response against
y
and
y
is a best
response against x.
Example.
In the chicken game, there are two pure equilibrium, (3
,
1) and (1
,
3),
and there is a mixed equilibrium in which the players pick the options with equal
probability.
Theorem (Nash, 1961). Every bimatrix game has an equilibrium.
We are not proving this since it is too hard.
4.2 The minimax theorem
There is a special type of game known as a zero sum game.
Definition (Zero-sum game). A bimatrix game is a zero-sum game, or matrix
game, if q
ij
= p
ij
for all i, j, i.e. the total payoff is always 0.
To specify a matrix game, we only need one matrix, not two, since the matrix
of the other player is simply the negative of the matrix of the first.
Example.
The rock-paper-scissors games as sp ecified in the beginning example
is a zero-sum game.
Theorem (von Neumann, 1928). If P R
m×n
. Then
max
xX
min
yY
p(x, y) = min
yY
max
xX
p(x, y).
Note that this is equivalent to
max
xX
min
yY
p(x, y) = max
yY
min
xX
p(x, y).
The left hand side is the worst payoff the row player can get if he employs the
minimax strategy. The right hand side is the worst payoff the column player
can get if he uses his minimax strategy.
The theorem then says that if both players employ the minimax strategy,
then this is an equilibrium.
Proof.
Recall that the optimal value of
max min p
(
x, y
) is a solution to the linear
program
maximize v such that
m
X
i=1
x
i
p
ij
v for all j = 1, · · · , n
m
X
i=1
x
i
= 1
x 0
Adding slack variable z R
n
with z 0, we obtain the Lagrangian
L(v, x, z, w, y) = v +
n
X
j=1
y
j
m
X
i=1
x
i
p
ij
z
j
v
!
w
m
X
i=1
x
i
1
!
,
where w R and y R
n
are Lagrange multipliers. This is equal to
1
n
X
j=1
y
j
v +
m
X
i=1
n
X
j=1
p
ij
y
j
w
x
i
n
X
j=1
y
j
z
j
+ w.
This has finite minimum for all
v R, x
0 iff
P
y
i
= 1,
P
p
ij
y
j
w
for all
i
,
and y 0. The dual is therefore
minimize w subject to
n
X
j=1
p
ij
y
j
w for all i
n
X
j=1
y
j
= 1
y 0
This corresponds to the column player choosing a strategy (
y
i
) such that the
expected payoff is bounded above by w.
The optimum value of the dual is
min
yY
max
xX
p
(
x, y
). So the result follows from
strong duality.
Definition (Value). The value of the matrix game with payoff matrix P is
v = max
xX
min
yY
p(x, y) = min
yY
max
xX
p(x, y).
In general, the equilibrium are given by
Theorem.
(
x, y
)
X × Y
is an equilibrium of the matrix game with payoff
matrix P if and only if
min
y
0
Y
p(x, y
0
) = max
x
0
X
min
y
0
Y
p(x
0
, y
0
)
max
x
0
X
p(x
0
, y) = min
y
0
Y
max
x
0
X
p(x
0
, u
0
)
i.e. the x, y are optimizers for the max min and min max functions.
Proof is in the second example sheet.
5 Network problems
5.1 Definitions
We are going to look into several problems that involve graphs. Unsurprisingly,
we will need some definitions from graph theory.
Definition
(Directed graph/network)
.
A directed graph or network is a pair
G
= (
V, E
), where
V
is the set of vertices and
E V × V
is the set of edges. If
(u, v) E, we say there is an edge from u to v.
Definition
(Degree)
.
The degree of a vertex
u V
is the number of
v V
such that (u, v) E or (v, u) E.
Definition
(Walk)
.
An walk from
u V
to
v V
is a sequence of vertices
u
=
v
1
, · · · , v
k
=
v
such that (
v
i
, v
i+1
)
E
for all
i
. An undirected walk allows
(v
i
, v
i+1
) E or (v
i+1
, v) E, i.e. we are allowed to walk backwards.
Definition (Path). A path is a walk where v
1
, · · · , v
k
are pairwise distinct.
Definition
(Cycle)
.
A cycle is a walk where
v
1
, · · · , v
k1
are pairwise distinct
and v
1
= v
k
.
Definition
(Connected graph)
.
A graph is connected if for any pair of vertices,
there is an undirected path between them.
Definition (Tree). A tree is a connected graph without (undirected) cycles.
Definition
(Spanning tree)
.
The spanning tree of a graph
G
= (
V, E
) is a tree
(V
0
, E
0
) with V
0
= V and E
0
E.
5.2 Minimum-cost flow problem
Let
G
= (
V, E
) be a directed graph. Let the number of vertices be
|V |
=
n
and
let
b R
n
. For each edge, we assign three numbers: a cost, an lower bound and
a upper bound. We denote these as matrices as C, M, M R
n×n
.
Each component of the vector
b
i
denotes the amount of flow entering or
leaving each vertex
i V
. If
b
i
>
0, we call
i V
a source. For example, if
we have a factory at
b
i
that produces stuff,
b
i
will be positive. This is only the
amount of stuff produced or consumed in the vertex, and not how many things
flow through the vertex.
c
ij
is the cost of transferring one unit of stuff from vertex
i
to vertex
j
(fill
entries with 0 if there is no edge between the vertices), and
m
ij
and
m
ij
denote
the lower and upper bounds on the amount of flow along (
i, j
)
E
respectively.
x R
n×n
is a minimum-cost flow if it minimizes the cost of transferring stuff,
while satisfying the constraints, i.e. it is an optimal solution to the problem
minimize
X
(i,j)E
c
ij
x
ij
subject to
b
i
+
X
j:(j,i)E
x
ji
=
X
j:(i,j)E
x
ij
for each i V
m
ij
x
ij
m
ij
for all (i, j) E.
This problem is a linear program. In theory, we can write it into the general
form Ax = b, where A is a huge matrix given by
a
ij
1 if the kth edge starts at vertex i
1 if the kth edge ends at vertex i
0 otherwise
However, using this huge matrix to solve this problem by the simplex method is
not very efficient. So we will look for better solutions.
Note that for the system to make sense, we must have
X
iV
b
i
= 0,
i.e. the total supply is equal to the total consumption.
To simplify the problem, we can convert it into an equivalent circulation
problem, where
b
i
= 0 for all
i
. We do this by adding an additional vertex where
we send all the extra
b
i
to. For example, if a vertex has
b
i
=
1, then it takes in
more stuff than it gives out. So we can mandate it to send out one extra unit to
the additional vertex. Then b
i
= 0.
An uncapacitated problem is the case where
m
ij
= 0 and
m
ij
=
for all
(
i, j
)
E
. An uncapacitated problem is either unbounded or bounded. If it is
bounded, then it is equivalent to a problem with finite capacities, since we can
add a bound greater than what the optimal solution wants.
We are going to show that this can be reduced to a simpler problem:
5.3 The transportation problem
The transportation problem is a special case of the minimum-flow problem,
where the graph is a bipartite graph. In other words, we can split the vertices
into two halves
A, B
, where all edges flow from a vertex in
A
to a vertex in
B
.
We call the vertices of A the suppliers and the vertices of B the consumers.
In this case, we can write the problem as
minimize
n
X
i=1
m
X
j=1
c
ij
x
ij
subject to
m
X
j=1
x
ij
= s
i
for i = 1, · · · , n
n
X
i=1
x
ij
= d
j
for j = 1, · · · , m
x 0
This
s
i
is the supply of each supplier, and
d
i
is the demand of each supplier. We
have s R
n
, d R
m
satisfying s, d 0,
P
s
i
=
P
d
j
.
Finally, we have c R
n×m
representing the cost of transferal.
We now show that every (bounded) minimum cost-flow problem can be
reduced to the transportation problem.
Theorem.
Every minimum cost-flow problem with finite capacities or non-
negative costs has an equivalent transportation problem.
Proof.
Consider a minimum-cost flow problem on network (
V, E
). It is wlog to
assume that
m
ij
= 0 for all (
i, j
)
E
. Otherwise, set
m
ij
to 0,
m
ij
to
m
ij
m
ij
,
b
i
to
b
i
m
ij
,
b
j
to
b
j
+
m
ij
,
x
ij
to
x
ij
m
ij
. Intuitively, we just secretly ship
the minimum amount without letting the network know.
Moreover, we can assume that all capacities are finite: if some edge has
infinite capacity but non-negative cost, then setting the capacity to a large
enough number, for example
P
iV
|b
i
|
does not affect the optimal solutions.
This is since cost is non-negative, and the optimal solution will not want shipping
loops. So we will have at most
P
|b
i
| shipments.
We will construct an instance of the transportation problem as follows:
For every i V , add a consumer with demand
P
k:(i,k)E
m
ik
b
i
.
For every (
i, j
)
E
, add a supplier with supply
m
ij
, an edge to consumer
i
with cost c
(ij,i)
= 0 and an edge to consumer j with cost c
(ij,j)
= c
ij
.
ij
i
j
0
c
ij
m
ij
P
k:(i,k)E
m
ik
b
i
P
k:(j,k)E
m
jk
b
j
The idea is that if the capacity of the edge (
i, j
) is, say, 5, in the original network,
and we want to transport 3 along this edge, then in the new network, we send 3
units from ij to j, and 2 units to i.
The tricky part of the proof is to show that we have the same constraints in
both graphs.
For any flow
x
in the original network, the corresponding flow on (
ij, j
) is
x
ij
and the flow on (ij, i) is m
ij
x
ij
. The total flow into i is then
X
k:(i,k)E
(m
ik
x
ik
) +
X
k:(k,i)E
x
ki
This satisfies the constraints of the new network if and only if
X
k:(i,k)E
(m
ik
x
ik
) +
X
k:(k,i)E
x
ki
=
X
k:(i,k)E
m
ik
b
i
,
which is true if and only if
b
i
+
X
k:(k,i)E
x
ki
X
k:(i,k)E
x
ik
= 0,
which is exactly the constraint for the node
i
in the original minimal-cost flow
problem. So done.
To solve the transportation problem, it is convenient to have two sets of
Lagrange multipliers, one for the supplier constraints and one for the consumer
constraint. Then the Lagrangian of the transp ortation problem can be written
as
L(x, λ, µ) =
m
X
i=1
n
X
j=1
c
ij
x
ij
+
n
X
i=1
λ
i
s
i
m
X
j=1
x
ij
n
X
j=1
µ
j
d
j
n
X
j=1
x
ij
.
Note that we use different signs for the Lagrange multipliers for the suppliers
and the consumers, so that our ultimate optimality condition will look nicer.
This is equivalent to
L(x, λ, µ) =
n
X
i=1
n
X
j=1
(c
ij
λ
i
+ µ
j
)x
ij
+
n
X
i=1
λ
i
s
i
m
X
j=1
µ
j
d
j
.
Since
x
0, the Lagrangian has a finite minimum iff
c
ij
λ
i
+
µ
j
0 for all
i, j. So this is our dual feasibility condition.
At an optimum, complementary slackness entails that
(c
ij
λ
i
+ µ
j
)x
ij
= 0
for all i, j.
In this case, we have a tableau as follows:
µ
1
µ
2
µ
3
µ
4
λ
1
µ
1
λ
1
µ
2
λ
1
µ
3
λ
1
µ
4
λ
1
x
11
c
11
x
12
c
12
x
13
c
13
x
14
c
14
s
1
λ
2
µ
1
λ
2
µ
2
λ
2
µ
3
λ
2
µ
4
λ
2
x
21
c
21
x
22
c
22
x
23
c
23
x
24
c
24
s
1
λ
3
µ
1
λ
3
µ
2
λ
3
µ
3
λ
3
µ
4
λ
3
x
31
c
31
x
32
c
32
x
33
c
33
x
34
c
34
s
1
d
1
d
2
d
3
d
4
We have a row for each supplier and a column for each consumer.
Example.
Suppose we have three suppliers with supplies 8
,
10 and 9; and four
consumers with demands 6, 5, 8, 8.
It is easy to create an initial feasible solution - we just start from the first
consumer and first supplier, and supply as much as we can until one side runs
out of stuff.
We first fill our tableau with our feasible solution.
6 5 2 3 4 6 8
2 3 7 7 4 1 10
5 6 1 2 8 4 9
6 5 8 8
8 = s
1
10 = s
2
9 = s
3
d
1
= 6
d
2
= 5
d
3
= 8
d
4
= 8
6
2
3
7
1
8
We see that our basic feasible solution corresponds to a spanning tree. In general,
if we have
n
suppliers and
m
consumers, then we have
n
+
m
vertices, and hence
n
+
m
1 edges. So we have
n
+
m
1 dual constraints. So we can arbitrarily
choose one Lagrange multiplier, and the other Lagrange multipliers will follow.
We choose λ
1
= 0. Since we require
(c
ij
λ
i
+ µ
i
)x
ij
= 0,
for edges in the spanning tree,
x
ij
6
= 0. So
c
ij
λ
i
+
µ
i
= 0. Hence we must
have
µ
1
=
5. We can fill in the values of the other Lagrange multipliers as
follows, and obtain
-5 -3 0 -2
0 6 5 2 3 4 6
4 2 3 7 7 4 1
2 5 6 1 2 8 4
We can fill in the values of λ
i
µ
i
:
-5 -3 0 -2
0 2
0 6 5 2 3 4 6
9 6
4 2 3 7 7 4 1
7 5
2 5 6 1 2 8 4
The dual feasibility condition is
λ
i
µ
i
c
ij
If it is satisfied everywhere, we have optimality. Otherwise, will have to do
something.
What we do is we add an edge, say from the second supplier to the first
consumer. Then we have created a cycle. We keep increasing the flow on the
new edge. This causes the values on other edges to change by flow conservation.
So we keep doing this until some other edge reaches zero.
If we increase flow by, say, δ, we have
6 δ 5 2 + δ 3 4 6
δ 2 3 δ 7 7 4 1
5 6 1 2 8 4
8 = s
1
10 = s
2
9 = s
3
d
1
= 6
d
2
= 5
d
3
= 8
d
4
= 8
6 δ
2 + δ
3 δ
7
1
8
δ
The maximum value of δ we can take is 3. So we end up with
3 5 5 3 4 6
3 2 7 7 4 1
5 6 1 2 8 4
We re-compute the Lagrange multipliers to obtain
-5 -3 -7 -9
7 9
0 3 5 5 3 4 6
0 6
-3 3 2 7 7 4 1
0 -2
-5 5 6 1 2 8 4
We see a violation at the bottom right. So we do it again:
3 5 5 3 4 6
3 2 7 7 δ 4 δ 1
5 6 1 + δ 2 8 δ 4
The maximum possible value of δ is 7. So we have
3 5 5 3 4 6
3 2 7 4 7 1
5 6 8 2 1 4
Calculating the Lagrange multipliers gives
-5 -3 -2 -4
2 4
0 3 5 5 3 4 6
0 -1
-3 3 2 7 4 7 1
5 3
0 5 6 8 2 1 4
No more violations. Finally. So this is the optimal solution.
5.4 The maximum flow problem
Suppose we have a network (
V, E
) with a single source 1 and a single sink
n
.
There is no costs in transportation, but each edge has a capacity. We want to
transport as much stuff from 1 to n as possible.
We can turn this into a minimum-cost flow problem. We add an edge from
n
to 1 with
1 cost and infinite capacity. Then the minimal cost flow will
maximize the flow from
n
to 1 as possible. So the same amount of stuff will
have to flow from 1 to n through the network.
We can write this is problem as
maximize δ subject to
X
j:(i,j)E
x
ij
X
j(j,i)E
x
ji
=
δ i = 1
δ i = n
0 otherwise
for each i
0 x
ij
C
ij
for each (i, j) E.
Here δ is the total flow from 1 to n.
While we can apply our results from the minimum-cost flow problem, we
don’t have to do so. There are easier ways to solve the problem, using the
max-flow min-cut theorem.
First we need to define a cut.
Definition
(Cut)
.
Suppose
G
= (
V, E
) with capacities
C
ij
for (
i, j
)
E
. A cut
of G is a partition of V into two sets.
For S V , the capacity of the cut (S, V \ S) is
C(S) =
X
(i,j)(S×(V \S))E
C
ij
,
All this clumsy notation says is that we add up the capacities of all edges from
S to V \ S.
Assume
x
is a feasible flow vector that sends
δ
units from 1 to
n
. For
X, Y V , we define
f
x
(X, Y ) =
X
(i,j)(X×Y )E
x
ij
,
i.e. the overall amount of flow from X to Y .
For any solution
x
ij
and cut
S V
with 1
S, n V \ S
, the total flow
from 1 to n can be written as
δ =
X
iS
X
j:(i,j)E
x
ij
X
j:(j,i)E
x
ji
.
This is true since by flow conservation, for any
i 6
= 1,
P
j:(i,j)E
x
ij
P
j:(j,i)E
x
ji
= 0,
and for i = 1, it is δ. So the sum is δ. Hence
δ = f
x
(S, V ) f
x
(V, S)
= f
x
(S, S) + f
x
(S, V \ S) f
x
(V \ S, S) f
x
(S, S)
= f
x
(S, V \ S) f
x
(V \ S, S)
f
x
(S, V \ S)
C(S)
This says that the flow through the cut is less than the capacity of the cut, which
is obviously true. The less obvious result is that this bound is tight, i.e. there is
always a cut S such that δ = C(S).
Theorem (Max-flow min-cut theorem). Let δ be an optimal solution. Then
δ = min{C(S) : S V, 1 S, n V \ S}
Proof.
Consider any feasible flow vector
x
. Call a path
v
0
, · · · , v
k
an augmenting
path if the flow along the path can be increased. Formally, it is a path that
satisfies
x
v
i1
v
i
< C
v
i1
v
i
or x
v
i
v
i1
> 0
for
i
= 1
, · · · , k
. The first condition says that we have a forward edge where
we have not hit the capacity, while the second condition says that we have a
backwards edge with positive flow. If these conditions are satisfied, we can
increase the flow of each edge (or decrease the backwards flow for backwards
edge), and the total flow increases.
Now assume that x is optimal and let
S = {1} {i V : there exists an augmenting path from 1 to i}.
Since there is an augmenting path from 1 to
S
, we can increase flow from 1 to
any vertex in S. So n 6∈ S by optimality. So n V \ S.
We have previously shown that
δ = f
x
(S, V \ S) f
x
(V \ S, S).
We now claim that
f
x
(
V \ S, S
) = 0. If it is not 0, it means that there is a node
v V \ S
such that there is flow from
v
to a vertex
u S
. Then we can add
that edge to the augmenting path to u to obtain an augmenting path to v.
Also, we must have
f
x
(
S, V \ S
) =
C
(
S
). Or else, we can still send more
things to the other side so there is an augmenting path. So we have
δ = C(S).
The max-flow min-cut theorem does not tell us how to find an optimal path.
Instead, it provides a quick way to confirm that our path is optimal.
It turns out that it isn’t difficult to find an optimal solution. We simply keep
adding flow along augmenting paths until we cannot do so. This is known as
the Ford-Fulkerson algorithm.
(i) Start from a feasible flow x, e.g. x = 0.
(ii) If there is no augmenting path for x from 1 to n, then x is optimal.
(iii)
Find an augmenting path for
x
from 1 to
n
, and send a maximum amount
of flow along it.
(iv) GOTO (ii).
Example. Consider the diagram
- -
1 n
5
1
1
5
2
5
4
We can keep adding flow until we reach
- -
1 n
5
1
1
5
2
5
4
4
1
1
2
2
5
3
(red is flow, black is capacity). We know this is an optimum, since our total flow
is 6, and we can draw a cut with capacity 6:
- -
1 n
5
1
1
5
2
5
4