0% found this document useful (0 votes)
179 views

Linear Programming: Brewer's Problem Simplex Algorithm Implementation Linear Programming

The document discusses linear programming, which is a method for optimally allocating scarce resources. It provides an example problem of a brewery choosing how many barrels of ale and beer to produce given limits on ingredients. This is formulated as a linear program to maximize profit subject to constraints. The problem is converted to standard form by introducing slack variables and an objective variable to represent the goal of maximizing profit. Geometry concepts are also briefly discussed, such as how the feasible region for this problem forms a convex polygon and the optimal solution occurs at an extreme point.

Uploaded by

Fadugba
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
179 views

Linear Programming: Brewer's Problem Simplex Algorithm Implementation Linear Programming

The document discusses linear programming, which is a method for optimally allocating scarce resources. It provides an example problem of a brewery choosing how many barrels of ale and beer to produce given limits on ingredients. This is formulated as a linear program to maximize profit subject to constraints. The problem is converted to standard form by introducing slack variables and an objective variable to represent the goal of maximizing profit. Geometry concepts are also briefly discussed, such as how the feasible region for this problem forms a convex polygon and the optimal solution occurs at an extreme point.

Uploaded by

Fadugba
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Linear Programming

 brewer’s problem
 simplex algorithm
 implementation
 linear programming

References:
The Allocation of Resources by Linear Programming,
Scientific American, by Bob Bland
Algs in Java, Part 5
1
Overview: introduction to advanced topics

Main topics
• linear programming: the ultimate practical problem-solving model
• reduction: design algorithms, prove limits, classify problems
• NP: the ultimate theoretical problem-solving model
• combinatorial search: coping with intractability

Shifting gears
• from linear/quadratic to polynomial/exponential scale
• from individual problems to problem-solving models
• from details of implementation to conceptual framework

Goals
• place algorithms we’ve studied in a larger context
• introduce you to important and essential ideas
• inspire you to learn more about algorithms!
2
Linear Programming
see ORF 307
What is it?
•Quintessential tool for optimal allocation of scarce resources, among
a number of competing activities.
•Powerful and general problem-solving method that encompasses:
shortest path, network flow, MST, matching, assignment...
Ax = b, 2-person zero sum games

Why significant?
•Widely applicable problem-solving model Ex: Delta claims that LP

•Dominates world of industry. saves $100 million per year.

•Fast commercial solvers available: CPLEX, OSL.


•Powerful modeling languages available: AMPL, GAMS.
•Ranked among most important scientific advances of 20th century.

3
Applications

Agriculture. Diet problem.


Computer science. Compiler register allocation, data mining.
Electrical engineering. VLSI design, optimal clocking.
Energy. Blending petroleum products.
Economics. Equilibrium theory, two-person zero-sum games.
Environment. Water quality management.
Finance. Portfolio optimization.
Logistics. Supply-chain management.
Management. Hotel yield management.
Marketing. Direct mail advertising.
Manufacturing. Production line balancing, cutting stock.
Medicine. Radioactive seed placement in cancer treatment.
Operations research. Airline crew assignment, vehicle routing.
Physics. Ground states of 3-D Ising spin glasses.
Plasma physics. Optimal stellarator design.
Telecommunication. Network design, Internet routing.
Sports. Scheduling ACC basketball, handicapping horse races.
4
 brewer’s problem
 simplex algorithm
 implementation
 linear programming

5
Toy LP example: Brewer’s problem

Small brewery produces ale and beer.


• Production limited by scarce resources: corn, hops, barley malt.
• Recipes for ale and beer require different proportions of resources.

corn (lbs) hops (oz) malt (lbs) profit ($)


available 480 160 1190
ale (1 barrel) 5 4 35 13
beer (1 barrel) 15 4 20 23

Brewer’s problem: choose product mix to maximize profits.

all ale
179 136 1190 442
(34 barrels)
34 barrels times 35 lbs malt
all beer
480 128 640 736 per barrel is 1190 lbs
(32 barrels) [ amount of available malt ]
20 barrels ale
400 160 1100 720
20 barrels beer
12 barrels ale
480 160 980 800
28 barrels beer
more profitable
? ? ? >800 ?
product mix?
6
Brewer’s problem: mathematical formulation

Small brewery produces ale and beer.


• Production limited by scarce resources:
corn, hops, barley malt.
• Recipes for ale and beer require
different proportions of resources.

Mathematical formulation
• let A be the number of barrels of beer
• and B be the number of barrels of ale

ale beer
maximize 13A + 23B profit
5A + 15B  480 corn
subject
to the 4A + 4B  160 hops
constraints
35A + 20B  1190 malt
A  0
B  0
7
Brewer’s problem: Feasible region

Hops Malt
4A + 4B  160 35A + 20B  1190

(0, 32)

(12, 28)

Corn
5A + 15B  480
(26, 14)

Beer

(0, 0) Ale (34, 0)

8
Brewer’s problem: Objective function

Pr
of
it

(0, 32)

(12, 28)

13A + 23B = $1600

(26, 14)

Beer 13A + 23B = $800

(0, 0) Ale (34, 0)


13A + 23B = $442
9
7
Brewer’s problem: Geometry

Brewer’s problem observation. Regardless of objective function


coefficients, an optimal solution occurs at an extreme point.

(0, 32)

(12, 28)

extreme point

(26, 14)

Beer

(0, 0) Ale (34, 0)

10
7
Standard form linear program

Input: real numbers aij, cj, bi.


Output: real numbers xj.
n = # nonnegative variables, m = # constraints.
Maximize linear objective function subject to linear equations.

n variables matrix version


maximize c1 x 1 + c 2 x 2 + . . . + c n x n maximize cT x
a11 x1 + a12 x2 + . . . + a1n xn = b1 subject to the Ax = b
m equations

subject to the
constraints constraints x  0
a21 x1 + a22 x2 + . . . + a2n xn = b2

...

am1 x1 + am2 x2 + . . . + amn xn = bm

x1 , x2 ,... , xn  0

“Linear” No x2, xy, arccos(x), etc.


“Programming” “ Planning” (term predates computer programming).
11
Converting the brewer’s problem to the standard form

Original formulation

maximize 13A + 23B


5A + 15B  480
subject
to the 4A + 4B  160
constraints
35A + 20B  1190
A, B  0

Standard form
• add variable Z and equation corresponding to objective function
• add slack variable to convert each inequality to an equality.
• now a 5-dimensional problem.

maximize Z
subject 13A + 23B  Z = 0
to the
5A + 15B + SC = 480
constraints
4A + 4B + SH = 160
35A + 20B + SM = 1190
A, B, SC, SH, SM  0
12
Geometry

A few principles from geometry:


• inequality: halfplane (2D), hyperplane (kD).
• bounded feasible region: convex polygon (2D), convex polytope (kD).

Convex set. If two points a and b are in the set, then so is (a + b).

Extreme point. A point in the set that can't be written as (a + b),
where a and b are two distinct points in the set.

extreme
point

convex not convex

13
Geometry (continued)

Extreme point property. If there exists an optimal solution to (P),


then there exists one that is an extreme point.

Good news. Only need to consider finitely many possible solutions.

Bad news. Number of extreme points can be exponential !

Ex: n-dimensional hypercube

Greedy property. Extreme point is optimal


iff no neighboring extreme point is better.

local optima are global optima

14
 brewer’s problem
 simplex algorithm
 implementation
 linear programming

15
Simplex Algorithm

Simplex algorithm. [George Dantzig, 1947]


• Developed shortly after WWII in response to logistical problems,
including Berlin airlift.
• One of greatest and most successful algorithms of all time.

Generic algorithm.

never decreasing objective function
Start at some extreme point.
• Pivot from one extreme point to a neighboring one.
• Repeat until optimal.

How to implement? Linear algebra.

16
Simplex Algorithm: Basis

Basis. Subset of m of the n variables.

Basic feasible solution (BFS).


• Set n - m nonbasic variables to 0, solve for remaining m variables.
• Solve m equations in m unknowns.
• If unique and feasible solution  BFS.
• BFS  extreme point.

Basis
{B, SH, SM } {A, B, SM }
(0, 32) (12, 28)

maximize Z Infeasible
{A, B, SH }
subject 13A + 23B  Z = 0 (19.41, 25.53)
to the
5A + 15B + SC = 480 Beer {A, B, SC }
constraints
4A + 4B + SH = 160 (26, 14)

35A + 20B + SM = 1190

A, B, SC, SH, SM  0
{SH, SM, SC } Ale {A, SH, SC }
(0, 0) (34, 0)
17
Simplex Algorithm: Initialization

Start with slack variables as the basis.

Initial basic feasible solution (BFS).


• set non-basis variables A = 0, B = 0 (and Z = 0).
• 3 equations in 3 unknowns give SC = 480, SC = 160, SC = 1190 (immediate).
• extreme point on simplex: origin

maximize Z
basis = {SC, SH, SM}
subject 13A + 23B  Z = 0
A=B=0
to the
5A + 15B + SC = 480 Z=0
constraints
4A + 4B + SH = 160 SC = 480
SH = 160
35A + 20B + SM = 1190
SM = 1190
A, B, SC, SH, SM  0

18
Simplex Algorithm: Pivot 1

maximize Z
basis = {SC, SH, SM}
subject 13A + 23B  Z = 0
A=B=0
to the
5A + 15B + SC = 480 Z=0
constraints
4A + 4B + SH = 160 SC = 480
SH = 160
35A + 20B + SM = 1190
SM = 1190
A, B, SC, SH, SM  0

which variable
Substitution B = (1/15)(480 – 5A – SC ) puts B into the basis does it replace?
( rewrite 2nd equation, eliminate B in 1st, 3rd, and 4th equations)

maximize Z
basis = {B, SH, SM}
subject (16/3)A - (23/15) SC  Z = -736
A = SC = 0
to the
(1/3) A + B + (1/15) SC = 32 Z = 736
constraints
(8/3) A - (4/15) SC + SH = 32 B = 32
SH = 32
(85/3) A - (4/3) SC + SM = 550
SM = 550
A, B, SC, SH, SM  0

19
Simplex Algorithm: Pivot 1

maximize Z
basis = {SC, SH, SM}
subject 13A + 23B  Z = 0 A=B=0
to the Z=0
5A + 15B + SC = 480
constraints SC = 480
4A + 4B + SH = 160
SH = 160
35A + 20B + SM = 1190
SM = 1190
A, B, SC, SH, SM  0

Why pivot on B?
•Its objective function coefficient is positive
(each unit increase in B from 0 increases objective value by $23)
•Pivoting on column 1 also OK.

Why pivot on row 2?


•Preserves feasibility by ensuring RHS  0.
•Minimum ratio rule: min { 480/15, 160/4, 1190/20 }.
20
Simplex Algorithm: Pivot 2

maximize Z
basis = {B, SH, SM}
subject (16/3)A - (23/15) SC  Z = -736
A = SC = 0
to the
(1/3) A + B + (1/15) SC = 32 Z = 736
constraints
(8/3) A - (4/15) SC + SH = 32 B = 32
SH = 32
(85/3) A - (4/3) SC + SM = 550
SM = 550
A, B, SC, SH, SM  0

Substitution A = (3/8)(32 + (4/15) SC – SH ) puts A into the basis


( rewrite 3nd equation, eliminate A in 1st, 2rd, and 4th equations)

maximize Z
basis = {A, B, SM}
subject - SC - 2SH  Z = -800
SC = SH = 0
to the
B + (1/10) SC + (1/8) SH = 28 Z = 800
constraints
A - (1/10) SC + (3/8) SH = 12 B = 28
A = 12
- (25/6) SC - (85/8) SH + SM = 110
SM = 110
A, B, SC, SH, SM  0

21
Simplex algorithm: Optimality

Q. When to stop pivoting?


A. When all coefficients in top row are non-positive.

Q. Why is resulting solution optimal?


A. Any feasible solution satisfies system of equations in tableaux.
• In particular: Z = 800 – SC – 2 SH
• Thus, optimal objective value Z*  800 since S , S C H  0.
• Current BFS has value 800  optimal.

maximize Z
basis = {A, B, SM}
subject - SC - 2SH  Z = -800
SC = SH = 0
to the
B + (1/10) SC + (1/8) SH = 28 Z = 800
constraints
A - (1/10) SC + (3/8) SH = 12 B = 28
A = 12
- (25/6) SC - (85/8) SH + SM = 110
SM = 110
A, B, SC, SH, SM  0

22
 brewer’s problem
 simplex algorithm
 implementation
 linear programming

23
Simplex tableau

Encode standard form LP in a single Java 2D array

maximize Z
subject 13A + 23B  Z = 0
to the
5A + 15B + SC = 480
constraints
4A + 4B + SH = 160

35A + 20B + SM = 1190

A, B, SC, SH, SM  0

5 15 1 0 0 480
4 4 0 1 0 160 m A I b

35 20 0 0 1 1190
1 c 0 0
13 23 0 0 0 0 n m 1

24
Simplex tableau

Encode standard form LP in a single Java 2D array (solution)

maximize Z
subject - SC - 2SH  Z = -800
to the
B + (1/10) SC + (1/8) SH = 28
constraints
A - (1/10) SC + (3/8) SH = 12
- (25/6) SC - (85/8) SH + SM = 110

A, B, SC, SH, SM  0

0 1 1/10 1/8 0 28

1 0 1/10 3/8 0 12
m A I b
0 0 25/6 85/8 1 110

0 0 -1 -2 0 -800 1 c 0 0
n m 1

Simplex algorithm transforms initial array into solution 25


Simplex algorithm: Bare-bones implementation

Construct the simplex tableau.

m A I b

1 c 0 0
n m 1

public class Simplex


{
private double[][] a; // simplex tableaux constructor
private int M, N;

public Simplex(double[][] A, double[] b, double[] c)


{
M = b.length;
N = c.length;
a = new double[M+1][M+N+1];
for (int i = 0; i < M; i++) put A[][] into tableau
for (int j = 0; j < N; j++)
a[i][j] = A[i][j];
for (int j = N; j < M + N; j++) a[j-N][j] = 1.0; put I[] into tableau
for (int j = 0; j < N; j++) a[M][j] = c[j]; put c[] into tableau
for (int i = 0; i < M; i++) a[i][M+N] = b[i]; put b[] into tableau
}

26
Simplex algorithm: Bare-bones Implementation

Pivot on element (p, q). q

public void pivot(int p, int q)


{
for (int i = 0; i <= M; i++)
for (int j = 0; j <= M + N; j++) scale all elements but
if (i != p && j != q) row p and column q
a[i][j] -= a[p][j] * a[i][q] / a[p][q];

for (int i = 0; i <= M; i++)


if (i != p) a[i][q] = 0.0; zero out column q

for (int j = 0; j <= M + N; j++)


if (j != q) a[p][j] /= a[p][q]; scale row p
a[p][q] = 1.0;
}

27
Simplex Algorithm: Bare Bones Implementation
q

Simplex algorithm.
p + +

public void solve()


{
while (true)
{
int p, q;
for (q = 0; q < M + N; q++)
if (a[M][q] > 0) break; find entering variable q
if (q >= M + N) break; (positive objective function coefficient)

for (p = 0; p < M; p++)


if (a[p][q] > 0) break;
for (int i = p+1; i < M; i++)
if (a[i][q] > 0) find row p according
if (a[i][M+N] / a[i][q] to min ratio rule
< a[p][M+N] / a[p][q])
p = i;
min ratio test
pivot(p, q);
}
}

28
Simplex Algorithm: Running Time

Remarkable property. In practice, simplex algorithm typically


terminates after at most 2(m+n) pivots.
• No pivot rule that is guaranteed to be polynomial is known.
• Most pivot rules known to be exponential (or worse) in worst-case.

Pivoting rules. Carefully balance the cost of finding an entering


variable with the number of pivots needed.

29
Simplex algorithm: Degeneracy

Degeneracy. New basis, same extreme point.

"stalling" is common in practice

Cycling. Get stuck by cycling through different bases that all


correspond to same extreme point.
• Doesn't occur in the wild.
• Bland's least index rule guarantees finite # of pivots.

30
Simplex Algorithm: Implementation Issues

To improve the bare-bones implementation


• Avoid stalling.
• Choose the pivot wisely.
• Watch for numerical stability.
• Maintain sparsity. requires fancy data structures

• Detect infeasiblity
• Detect unboundedness.
• Preprocess to reduce problem size.

Basic implementations available in many programming environments.

Commercial solvers routinely solve LPs with millions of variables.

31
LP solvers: basic implementations

Ex. 1: OR-Objects Java library


import drasys.or.mp.*;
import drasys.or.mp.lp.*;

public class LPDemo


{
public static void main(String[] args) throws Exception
{
Problem prob = new Problem(3, 2);
prob.getMetadata().put("lp.isMaximize", "true");
prob.newVariable("x1").setObjectiveCoefficient(13.0);
prob.newVariable("x2").setObjectiveCoefficient(23.0);
prob.newConstraint("corn").setRightHandSide( 480.0);
prob.newConstraint("hops").setRightHandSide( 160.0);
prob.newConstraint("malt").setRightHandSide(1190.0);

prob.setCoefficientAt("corn", "x1", 5.0);


prob.setCoefficientAt("corn", "x2", 15.0);
prob.setCoefficientAt("hops", "x1", 4.0);
prob.setCoefficientAt("hops", "x2", 4.0);
prob.setCoefficientAt("malt", "x1", 35.0);
prob.setCoefficientAt("malt", "x2", 20.0);

DenseSimplex lp = new DenseSimplex(prob);


System.out.println(lp.solve());
System.out.println(lp.getSolution());
}
}

Ex. 2: MS Excel (!) 32


LP solvers: commercial strength

AMPL. [Fourer, Gay, Kernighan] An algebraic modeling language.


CPLEX solver. Industrial strength solver.

ale beer set INGR; beer.mod


set PROD;
maximize 13A + 23B profit param profit {PROD};
param supply {INGR};
subject 5A + 15B  480 corn param amt {INGR, PROD};
to the 4A + 4B  160 hops var x {PROD} >= 0;
constraints maximize total_profit:
35A + 20B  1190 malt sum {j in PROD} x[j] * profit[j];
A  0 subject to constraints {i in INGR}:
sum {j in PROD} amt[i,j] * x[j] <= supply[i];
B  0

separate data from model

set PROD := beer ale;


set INGR := corn hops malt;
param: profit :=
ale 13
beer 23;
param: supply :=
corn 480
hops 160
malt 1190;
param amt: ale beer :=
corn 5 15
hops 4 4
malt 35 20;
beer.dat
33
History

1939. Production, planning. [Kantorovich]


1947. Simplex algorithm. [Dantzig]
1950. Applications in many fields.
1979. Ellipsoid algorithm. [Khachian]
1984. Projective scaling algorithm. [Karmarkar]
1990. Interior point methods.
• Interior point faster when polyhedron smooth like disco ball.
• Simplex faster when polyhedron spiky like quartz crystal.

200x. Approximation algorithms, large scale optimization.


34
 brewer’s problem
 simplex algorithm
 implementation
 linear programming

35
Linear programming

Linear “programming”
• process of formulating an LP model for a problem
• solution to LP for a specific problem gives solution to the problem

1. Identify variables
2. Define constraints (inequalities and equations)
3. Define objective function

easy part [omitted]:


convert to standard form
Examples:
• shortest paths
• maxflow stay tuned [this lecture]

• bipartite matching
• .
• .
• .
• [ a very long list ]
36
Single-source shortest-paths problem (revisited)

Given. Weighted digraph, single source s.

Distance from s to v: length of the shortest path from s to v .

Goal. Find distance (and shortest path) from s to every other vertex.

2 24 3
9
s
18
14 6
2
6
30 4 19
11
15 5
5
6
20 16

7 44 t

37
LP formulation of single-source shortest-paths problem

One variable per vertex, one inequality per edge.

minimize xt
subject xs + 9  x2
to the xs + 14  x6 9
2 24 3
constraints xs + 15  x7 s
18
14 6
x2 + 24  x3 6
2

x3 + 2  x5 30
11
4 19
5
x3 + 19  xt 15
5
6
x4 + 6  x3 20 16

x4 + 6  xt 7 44 t
x5 + 11  x4
x5 + 16  xt
x6 + 18  x3
x6 + 30  x5
x6 + 5  x7
x7 + 20  x5
x7 + 44  xt
xs = 0
x2 , ... , xt  0

38
LP formulation of single-source shortest-paths problem

One variable per vertex, one inequality per edge.

minimize xt
subject xs + 9  x2 9 32
to the xs + 14  x6 0 9
2 24 3
constraints xs + 15  x7 s
18
14 14 6
x2 + 24  x3 6
2
45
x3 + 2  x5 30
11
4 19
5
x3 + 19  xt 15
5
34 6
x4 + 6  x3 20 16

x4 + 6  xt 7 44 t
x5 + 11  x4 15 50
x5 + 16  xt solution
x6 + 18  x3 xs = 0
x6 + 30  x5 x2 = 9
x3 = 32
x6 + 5  x7
x4 = 45
x7 + 20  x5
x5 = 34
x7 + 44  xt
x6 = 14
xs = 0 x7 = 15
x2 , ... , xt  0 xt = 50

39
Maxflow problem

Given: Weighted digraph, source s, destination t. s


2 3

Interpret edge weights as capacities 1 2

• Models material flowing through network


1 1
3 1

• Ex: oil flowing through pipes


• Ex: goods in trucks on roads 3 4


2 3
[many other examples] t

Flow: A different set of edge weights flow out of s is 3 flow in


• flow does not exceed capacity in any edge equals

• flow at every vertex satisfies equilibrium flow out


1 s 2

at each
[ flow in equals flow out ] 1 2 vertex
0 1

flow  capacity 1 1
in every edge
3 2 1 4

Goal: Find maximum flow from s to t t

flow in to t is 3 40
LP formulation of maxflow problem

One variable per edge. s


One inequality per edge, one equality per vertex. 2 3

1 2
maximize xts 1 1
3 1

subject xs1  2
to the xs2  3 3 4
constraints x13  3 2 3

x14  1 capacity
t

x23  1 constraints
add dummy
x24  1 edge from
x3t  2 t to s
s
x4t  3
xts = xs1 + xs2 1 2
xs1 = x13 + x14
equilibrium xs2 = x23 + x24
constraints x13 + x23 = x3t 3 4
x14 + x24 = x4t
x3t + x4t = xts t

all xij  0
41
LP formulation of maxflow problem

One variable per edge. s


One inequality per edge, one equality per vertex. 2 3

1 2
maximize xts 1 1
3 1

subject xs1  2
to the xs2  3 3 4
constraints x13  3 2 3

x14  1 capacity
t

x23  1 constraints
add dummy
x24  1 edge from
x3t  2 t to s
2 s 2
x4t  3 solution
xts = xs1 + xs2 xs1 = 2 1 2
1 1
xs1 = x13 + x14 xs2 = 2
x13 = 1 1
xs2 = x23 + x24
1
equilibrium x14 = 1
constraints x13 + x23 = x3t x23 = 1 3 2 2 4
x14 + x24 = x4t x24 = 1
x3t = 2
x3t + x4t = xts t
x4t = 2
all xij  0 xts = 4
maxflow value 42
Maximum cardinality bipartite matching problem

Given: Two sets of vertices, set of edges A B C D E F

(each connecting one vertex in each set)


0 1 2 3 4 5

Matching: set of edges Alice Adobe


with no vertex appearing twice Adobe, Apple, Google Alice, Bob, Dave
Bob Apple
Adobe, Apple, Yahoo Alice, Bob, Dave
Carol Google
Interpretation: mutual preference constraints Google, IBM, Sun Alice, Carol, Frank

• Ex: people to jobs Dave IBM


Adobe, Apple Carol, Eliza
Ex: medical students to residence positions Eliza Sun


IBM, Sun, Yahoo Carol, Eliza, Frank
Ex: students to writing seminars Frank Yahoo

• [many other examples]


Google, Sun, Yahoo Bob, Eliza, Frank

Example: Job offers

A B C D E F

Goal: find a maximum cardinality matching


0 1 2 3 4 5

43
LP formulation of maximum cardinality bipartite matching problem

One variable per edge, one equality per vertex. A B C D E F

xA0 + xA1 + xA2 + xB0 + xB1 + xB5


maximize + xC2 + xC3 + xC4 + xD0 + xD1 0 1 2 3 4 5
+ xE3 + xE4 + xE5 + xF2 + xF4 + xF5
subject xA0 + xA1 + xA2 = 1
to the xB0 + xB1 + xB5 = 1
constraints xC2 + xC3 + xC4 = 1 constraints on
xD0 + xD1 = 1 top vertices
xE3 + xE4 + xE5 = 1
xF2 + xF4 + xF5 = 1
xA0 + xB0 + xD0 = 1
xA1 + xB1 + xD1 = 1
xA2 + xC2 + xF2 = 1 constraints on
xC3 + xE3 = 1 bottom vertices
xC4 + xE4 + xF4 = 1
xB5 + xE5 + xF5 = 1 Crucial point:
all xij  0 not always so lucky!

Theorem. [Birkhoff 1946, von Neumann 1953]


All extreme points of the above polyhedron have integer (0 or 1) coordinates

Corollary. Can solve bipartite matching problem by solving LP 44


LP formulation of maximum cardinality bipartite matching problem

One variable per edge, one equality per vertex. A B C D E F

xA0 + xA1 + xA2 + xB0 + xB1 + xB5


maximize + xC2 + xC3 + xC4 + xD0 + xD1 0 1 2 3 4 5
+ xE3 + xE4 + xE5 + xF2 + xF4 + xF5
subject xA0 + xA1 + xA2 = 1
to the xB0 + xB1 + xB5 = 1
constraints xC2 + xC3 + xC4 = 1 solution
xD0 + xD1 = 1 xA1 = 1
xE3 + xE4 + xE5 = 1 xB5 = 1
xF2 + xF4 + xF5 = 1 xC2 = 1
xA0 + xB0 + xD0 = 1 xD0 = 1
xA1 + xB1 + xD1 = 1 xE3 = 1
xA2 + xC2 + xF2 = 1 xF4 = 1
xC3 + xE3 = 1 all other xij = 0
xC4 + xE4 + xF4 = 1
xB5 + xE5 + xF5 = 1
all xij  0
A B C D E F

0 1 2 3 4 5

45
Linear programming perspective

Got an optimization problem?


ex: shortest paths, maxflow, matching, . . . [many, many, more]

Approach 1: Use a specialized algorithm to solve it


• Algs in Java
• vast literature on complexity
• performance on real problems not always well-understood

Approach 2: Use linear programming


• a direct mathematical representation of the problem often works
• immediate solution to the problem at hand is often available
• might miss specialized solution, but might not care

Got an LP solver? Learn to use it!

46
LP: the ultimate problem-solving model (in practice)

Fact 1: Many practical problems are easily formulated as LPs


Fact 2: Commercial solvers can solve those LPs quickly

More constraints on the problem?


•specialized algorithm may be hard to fix Ex. Mincost maxflow and


other generalized versions
can just add more inequalities to LP

New problem?
•may not be difficult to formulate LP
•may be very difficult to develop specialized algorithm

Today’s problem?
•similar to yesterday’s Ex. Airline scheduling


[ similar to vast number of other business processes ]
edit tableau, run solver

Too slow?
•could happen Want to learn more?

•doesn’t happen ORFE 307


47
Ultimate problem-solving model (in theory)

Is there an ultimate problem-solving model?


• Shortest paths
• Maximum flow
• Bipartite matching tractable
• ...
• Linear programming
• .
• .
• .
• NP-complete problems intractable ?

• .
• .
• . [see next lecture]

Does P = NP? No universal problem-solving model exists unless P = NP.

Want to learn more?


COS 423
48
LP perspective

LP is near the deep waters of intractability.

Good news:
• LP has been widely used for large practical problems for 50+ years
• Existence of guaranteed poly-time algorithm known for 25+ years.

constrain variables to have integer values


Bad news:
• Integer linear programming is NP-complete
• (existence of guaranteed poly-time algorithm is highly unlikely).
• [stay tuned]

An unsuspecting MBA student transitions to


the world of intractability with a single mouse click.
49

You might also like