Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Review for final exam
1. Review for Final Exam
Math 20
January 15, 2008
Announcements
Final Friday, January 18, 9:15am
ML Office Hours Wednesday (tomorrow) 10–11 and 2–3 (SC
323)
Old exams (and solutions) on website
2. Outline
Strictly Determined Games
Linear Programming
Two-by-two
The Corner Principle
non-strictly-determined
Duality
games
The Simplex Method
Larger, non-strictly
The Assignment Problem determined games
Zero-sum Game Theory Review of older material
3. The Corner Principle
Learning Objectives
Formulate a linear programming problem
Use the corner principle to solve an LP problem
4. Linear Programming
The Corner Principle
Definition
A linear programming problem is a constrained optimization
problem where the objective function is linear and the constraints
are all linear inequalities.
Theorem (The Corner Principle)
In any linear programming problem, the extreme values of the
objective function, if achieved, will be achieved on a corner of the
feasibility set.
5. Example
A farmer who has a 120-acre farm plants corn and wheat. The
expenses are $12 for each acre of corn planted and $24 for each
acre of wheat planted. Each acre of corn requires 32 bushels of
storage and yields a profit of $40; each acre of wheat requires 8
bushels of storage and yields a profit of $50. If the total amount of
storage available is 160 bushels and the farmer has $1200 in
capital, how many acres of corn and how many acres of wheat
should be planted to maximize profit?
6. Formulating the Problem
Let x be the number of acres of corn planted and y the number of
acres of wheat planted. Then we want to maximize
z = 40x + 50y (profit)
subject to constraints
x+ y ≤ 120 (land)
32x+ 8y ≤ 160 (storage)
12x+24y ≤1200 (capital)
as well as x, y > 0.
7. Drawing the feasible set
120
x
+
y
≤
12
0
50
12x
+2
32x +
4y
≤1
20 200
8y ≤
160
5 100 120
9. Checking the corners
x y z = 40x + 50y
0 0 0
5 0 200
0 20 1000
We should plant 20 acres of wheat and no corn.
10. Duality
Learning Objectives
Given an LP problem, formulate its dual problem
Interpret the solutions to the dual problem in terms of the
primal problem
11. Duality
Definition
An LP problem is in standard form if it is expressed as
max z = c1 x1 + c2 x2 + · · · + cn xn
subject to the constraints
a11 x1 + a12 x2 + · · · + a1n xn ≤ b1
a21 x1 + a22 x2 + · · · + a2n xn ≤ b2
··· ···
am1 x1 + am2 x2 + · · · + amn xn ≤ bm
x1 , x2 , . . . , xn ≥ 0
In vector notation, an LP problem is in standard form it it reads
max z = c x subject to constraints Ax ≤ b, x ≥ 0
12. Definition
Given a linear programming problem in standard form, the dual
linear programming problem is
min w = b1 y1 + · · · + bm ym
subject to constraints
a11 y1 + a21 y2 + · · · + am1 ym ≥ p1
a12 y1 + a22 y2 + · · · + am2 ym ≥ p2
··· ···
a1n y1 + a2n y2 + · · · + amn ym ≥ pn
y1 , . . . , ym ≥ 0
or in vector notation,
min w = b y subject to constraints A y ≥ c, y ≥ 0.
13. Example
In a product-mix problem, the dual problem is to buy out the
producer’s materials while minimizing total payout
In a diet problem, the dual problem is to sell the nutrients
(kind of weird)
In any LP problem, the dual variables represent the marginal
objective of each variable
In some cases the primal problem is easier to solve.
14. Example
In a product-mix problem, the dual problem is to buy out the
producer’s materials while minimizing total payout
In a diet problem, the dual problem is to sell the nutrients
(kind of weird)
In any LP problem, the dual variables represent the marginal
objective of each variable
In some cases the primal problem is easier to solve.
Look at Lesson 30 for a good, worked out example.
15. The Simplex Method
Learning Objectives
Form tableaux and how to move between them
Given an LP problem in standard form, solve it using the
simplex method
Interpret the solutions to the dual problem in terms of the
simplex method solution for the primal problem
16. The Simplex Method
1. Set up the initial tableau.
2. Apply the optimality test. If the objective row has no negative
entries in the columns labeled with variables, then the
indicated solution is optimal; we can stop.
3. Choose a pivotal column by determining the column with the
most negative entry in the objective row. If there are several
candidates for a pivotal column, choose any one.
4. Choose a pivotal row. Form the ratios of the entries above the
objective row in the rightmost column by the corresponding
entries of the pivotal column for those entries in the pivotal
column which are positive. The pivotal row is the row for
which the smallest of these ratios occurs. If there is a tie,
choose any one of the qualifying rows. If none of the entries
in the pivotal column above the objective row is positive, the
problem has no finite optimum. We stop.
5. Perform pivotal elimination to construct a new tableau and
return to Step 2.
17. Example
We are going to solve the linear programming problem of
maximizing
z = 2x1 − 4x2 + 5x3
subject to constraints
3x1 + 2x2 + x3 ≤ 6
3x1 − 6x2 + 7x3 ≤ 9
and x1 , x2 , x3 ≥ 0.
18. Tableau
x1 x2 x3 u1 u2 z value
u1 3 2 1 1 0 0 6
u2 3 −6 7 0 1 0 9
z −2 4 −5 0 0 1 0
19. Tableau
x1 x2 x3 u1 u2 z value
u1 3 2 1 1 0 0 6
u2 3 −6 7 0 1 0 9
z −2 4 −5 0 0 1 0
largest negative
coefficient in ob-
jective row
20. Tableau
entering variable
x1 x2 x3 u1 u2 z value
u1 3 2 1 1 0 0 6
u2 3 −6 7 0 1 0 9
z −2 4 −5 0 0 1 0
largest negative
coefficient in ob-
jective row
21. Tableau
entering variable
x1 x2 x3 u1 u2 z value θ
u1 3 2 1 1 0 0 6 6
u2 3 −6 7 0 1 0 9 9/7
z −2 4 −5 0 0 1 0
largest negative
coefficient in ob-
jective row
22. Tableau
smallest positive
entering variable
θ-ratio
x1 x2 x3 u1 u2 z value θ
u1 3 2 1 1 0 0 6 6
u2 3 −6 7 0 1 0 9 9/7
z −2 4 −5 0 0 1 0
largest negative
coefficient in ob-
jective row
23. Tableau
departing variable smallest positive
entering variable
θ-ratio
x1 x2 x3 u1 u2 z value θ
u1 3 2 1 1 0 0 6 6
u2 3 −6 7 0 1 0 9 9/7
z −2 4 −5 0 0 1 0
largest negative
coefficient in ob-
jective row
24. Tableau
departing variable smallest positive
entering variable
θ-ratio
x1 x2 x3 u1 u2 z value θ
u1 3 2 1 1 0 0 6 6
u2 3 −6 7 0 1 0 9 9/7
z −2 4 −5 0 0 1 0
make this entry 1
and the rest of its
largest negative
column 0
coefficient in ob-
jective row
25. Tableau
x1 x2 x3 u1 u2 z value
u1 3 2 1 1 0 0 6
u2 3 −6 7 0 1 0 9 ×1/7
z −2 4 −5 0 0 1 0
make this entry 1
and the rest of its
column 0
26. Tableau
x1 x2 x3 u1 u2 z value
u1 3 2 1 1 0 0 6
x3 3/7 −6/7 1 0 1/7 0 9/7
z −2 4 −5 0 0 1 0
make this entry 1
and the rest of its
column 0
27. Tableau
x1 x2 x3 u1 u2 z value
u1 3 2 1 1 0 0 6 −1
x3 3/7 −6/7 1 0 1/7 0 9/7
z −2 4 −5 0 0 1 0 5
make this entry 1
and the rest of its
column 0
28. Tableau
x1 x2 x3 u1 u2 z value
u1 18/7 20/7 0 1 −1/7 0 33/7
x3 3/7 −6/7 1 0 1/7 0 9/7
z −2 4 −5 0 0 1 0
make this entry 1
and the rest of its
column 0
29. Tableau
x1 x2 x3 u1 u2 z value
u1 18/7 20/7 0 1 −1/7 0 33/7
x3 3/7 −6/7 1 0 1/7 0 9/7
z 1/7 −2/7 0 0 5/7 1 45/7
make this entry 1
and the rest of its
column 0
30. Tableau
x1 x2 x3 u1 u2 z value
u1 18/7 20/7 0 1 −1/7 0 33/7
x3 3/7 −6/7 1 0 1/7 0 9/7
z 1/7 −2/7 0 0 5/7 1 45/7
largest negative
coefficient in ob-
jective row
31. Tableau
entering variable
x1 x2 x3 u1 u2 z value
u1 18/7 20/7 0 1 −1/7 0 33/7
x3 3/7 −6/7 1 0 1/7 0 9/7
z 1/7 −2/7 0 0 5/7 1 45/7
largest negative
coefficient in ob-
jective row
32. Tableau
entering variable
x1 x2 x3 u1 u2 z value θ
u1 18/7 20/7 0 1 −1/7 0 33/7 33/20
x3 3/7 −6/7 1 0 1/7 0 9/7 −3/2
z 1/7 −2/7 0 0 5/7 1 45/7
largest negative
coefficient in ob-
jective row
33. Tableau
smallest positive
θ-ratio
entering variable
x1 x2 x3 u1 u2 z value θ
u1 18/7 20/7 0 1 −1/7 0 33/7 33/20
x3 3/7 −6/7 1 0 1/7 0 9/7 −3/2
z 1/7 −2/7 0 0 5/7 1 45/7
largest negative
coefficient in ob-
jective row
34. Tableau
smallest positive
departing variable θ-ratio
entering variable
x1 x2 x3 u1 u2 z value θ
u1 18/7 20/7 0 1 −1/7 0 33/7 33/20
x3 3/7 −6/7 1 0 1/7 0 9/7 −3/2
z 1/7 −2/7 0 0 5/7 1 45/7
largest negative
coefficient in ob-
jective row
35. Tableau
smallest positive
departing variable θ-ratio
entering variable
x1 x2 x3 u1 u2 z value θ
u1 18/7 20/7 0 1 −1/7 0 33/7 33/20
x3 3/7 −6/7 1 0 1/7 0 9/7 −3/2
z 1/7 −2/7 0 0 5/7 1 45/7
make this entry 1
largest negative
and the rest of its
coefficient in ob-
column 0
jective row
36. Tableau
x1 x2 x3 u1 u2 z value
u1 18/7 20/7 0 1 −1/7 0 33/7 ×7/20
x3 3/7 −6/7 1 0 1/7 0 9/7
z 1/7 −2/7 0 0 5/7 1 45/7
make this entry 1
and the rest of its
column 0
37. Tableau
x1 x2 x3 u1 u2 z value
x2 9/10 1 0 7/20 −1/20 0 33/20
x3 3/7 −6/7 1 0 1/7 0 9/7
z 1/7 −2/7 0 0 5/7 1 45/7
make this entry 1
and the rest of its
column 0
38. Tableau
x1 x2 x3 u1 u2 z value
x2 9/10 1 0 7/20 −1/20 0 33/20 6/7
x3 3/7 −6/7 1 0 1/7 0 9/7
2/7
z 1/7 −2/7 0 0 5/7 1 45/7
make this entry 1
and the rest of its
column 0
39. Tableau
x1 x2 x3 u1 u2 z value
x2 9/10 1 0 7/20 −1/20 0 33/20
x3 6/5 0 1 3/10 1/10 0 27/10
z 1/7 −2/7 0 0 5/7 1 45/7
make this entry 1
and the rest of its
column 0
40. Tableau
x1 x2 x3 u1 u2 z value
x2 9/10 1 0 7/20 −1/20 0 33/20
x3 6/5 0 1 3/10 1/10 0 27/10
z 2/5 0 0 1/10 7/10 1 69/10
41. Tableau
x1 x2 x3 u1 u2 z value
x2 9/10 1 0 7/20 −1/20 0 33/20
x3 6/5 0 1 3/10 1/10 0 27/10
z 2/5 0 0 1/10 7/10 1 69/10
No more negative coefficients.
We are done!
42. Tableau
x1 x2 x3 u1 u2 z value
x2 9/10 1 0 7/20 −1/20 0 33/20
x3 6/5 0 1 3/10 1/10 0 27/10
z 2/5 0 0 1/10 7/10 1 69/10
No more negative coefficients.
We are done!
43. Simplex Method and Duality
Once the problem is solved, the entries in the objective row
below the slack variables are the solutions to the dual problem!
This means we can solve some LP problems by finding their
duals and solving them instead.
44. Outline
Strictly Determined Games
Linear Programming
Two-by-two
The Corner Principle
non-strictly-determined
Duality
games
The Simplex Method
Larger, non-strictly
The Assignment Problem determined games
Zero-sum Game Theory Review of older material
45. The Assignment Problem
Learning Objectives
Formulate a (linear) assignment problem
Solve linear assignment problems using the Hungarian
algorithm
46. The Assignment Problem
Given:
A set of “jobs” to assign to “people” (start with the same of
each, can solve the general problem later)
A cost of assigning each job to each person
Find the assignment that minimizes total cost.
47. Mathematical Formulation
Let C = (cij ) be the costs of assigning job j to person i
Let X = (xij ) be 1 if person i does job j, 0 otherwise.
The problem is to minimize
n
cij xij
i,j=1
subject to constraint that there is exactly one 1 in each row and
column, and the rest of the entries in each row and column are
zero.
The goal is to replace C with an “ideal cost matrix” with the
properties that
All entries are nonnegative
There is a “sudoku pattern” of zeroes
Then the minimal assignment(s) are clear.
48. The Hungarian Algorithm
Work with C:
1. Find the minimum entry in each row and subtract it from
each row
2. Find the minimum entry in each column and subtract it from
each column. The resulting matrix is nonnegative
3. Using lines that go all the way across or all the way
up-and-down, cross out all zeros in the new cost matrix
4. If you can only do this with n lines, an assignment of zeroes is
possible.
5. Otherwise, determine the smallest entry not covered by any
line.
Subtract this entry from all uncovered entries
Add it to all double-covered entries
Return to Step 3
49. Example
A coin dealer is to sell four coins through a mail auction. Bids are
received for each of the four coins from five bidders with
instructions that at most one of his bids is to be honored. The bids
are:
Bids
Coin 1 Coin 2 Coin 3 Coin 4
Bidder 1 $150 $65 $210 $135
Bidder 2 175 75 230 155
Bidder 3 135 85 200 140
Bidder 4 140 70 190 130
Bidder 5 170 50 200 160
How should the dealer assign the four coins in order to maximize
the sum of the resulting bids?
50. Solution
We create a dummy coin for which each bidder bids nothing. The
maximum bid is $230, we replace all the entries with $230 minus
them. This changes our maximization problem into a minimization
problem. For the entries now represent not the amount bid but the
amount expected back from a $230 payment, and clearly the
dealer wants to minimize the amount given back.
53. The answer
Since we have the assignment of zeroes, we can read off the
solution:
Bidder 1 gets Coin 3
Bidder 2 gets Coin 1
Bidder 3 gets Coin 2
Bidder 4 gets the dummy coin (nothing)
Bidder 5 gets Coin 4
54. Outline
Strictly Determined Games
Linear Programming
Two-by-two
The Corner Principle
non-strictly-determined
Duality
games
The Simplex Method
Larger, non-strictly
The Assignment Problem determined games
Zero-sum Game Theory Review of older material
55. Zero-sum Game Theory
Learning Objectives
Formulate a game theory problem, finding strategies and
payoffs
Find the optimal strategies for games
strictly determined games
2 × 2 non-strictly-determined games
using the simplex method
56. Definitions
A game theory problem is a contest between two players who
“move” simultaneously
The row player chooses among m strategies and the column
player chooses among n strategies.
The payoff aij is the amount paid to the row player if R
chooses i and C chooses j (could be negative).
A strategy vector is a probability vector representing the
percentage of the time each strategy should be chosen:
row player’s strategy is a row vector p
column players strategy is a column vector q
The expected value of these strategies is the sum
n
E (p, q) = pi aij qj = pAq
i,j=1
57. Theorem (Fundamental Theorem of Zero-Sum Games)
There exist optimal strategies p∗ for R and q∗ for C such that for
all strategies p and q:
E (p∗ , q) ≥ E (p∗ , q∗ ) ≥ E (p, q∗ )
58. Theorem (Fundamental Theorem of Zero-Sum Games)
There exist optimal strategies p∗ for R and q∗ for C such that for
all strategies p and q:
E (p∗ , q) ≥ E (p∗ , q∗ ) ≥ E (p, q∗ )
E (p∗ , q∗ ) is called the value v of the game.
59. Theorem (Fundamental Theorem of Zero-Sum Games)
There exist optimal strategies p∗ for R and q∗ for C such that for
all strategies p and q:
E (p∗ , q) ≥ E (p∗ , q∗ ) ≥ E (p, q∗ )
E (p∗ , q∗ ) is called the value v of the game.
So the problem is to find p∗ and q∗ .
60. Strictly Determined Games
Definition
Let A be a payoff matrix.
A saddle point is an entry ars which is the minimum entry in
its row and the maximum entry in its column.
A game whose payoff matrix has a saddle point is called
strictly determined
Payoff matrices can have multiple saddle points
61. Strictly Determined Games
Definition
Let A be a payoff matrix.
A saddle point is an entry ars which is the minimum entry in
its row and the maximum entry in its column.
A game whose payoff matrix has a saddle point is called
strictly determined
Payoff matrices can have multiple saddle points
Theorem
Let A be a payoff matrix. If ars is a saddle point, then
er (choose r all the time) is an optimal strategy for R
es (choose s all the time) is an optimal strategy for C
62. Finding equilibria by gravity
If C chose strategy 2,
and R knew it, R would
definitely choose 2 1 3
This would make C
choose strategy 1
but (2, 1) is an
2 4
equilibrium, a saddle
point.
63. Finding equilibria by gravity
Here (1, 1) is an equilibrium 2 3
position; starting from there
neither player would want to
deviate from this.
1 4
64. Finding equilibria by gravity
2 3
What about this one?
4 1
65. Zero-sum Game Theory
Two-by-two non-strictly-determined games
In this case we can compute E (p, q) by hand in terms of p1 and q1
(see Lesson 34 for the details)
a22 − a21 a22 − a12
p1 = q1 =
a11 + a22 − a21 − a22 a11 + a22 − a21 − a12
p2 = 1 − p1 q2 = 1 − q1
These are in between 0 and 1 if there are no saddle points in the
matrix.
a11 a22 − a12 a21
v=
a11 + a22 − a21 − a12
To remember this, remember that q is the strategy for the column
player. So to get q1 we take the difference between the two entries
in the second column.
66. Examples
1 3
If A = , then p1 = 2 ? Doesn’t work because A has a
0
2 4
saddle point.
2 3
If A = , p1 = 3 ? Again, doesn’t work.
2
1 4
2 3
If A = , p1 = −3 = 3 , while q1 = −4 = 2 . So R
−4 4
−2 1
4 1
should pick 1 half the time and 2 the other half, while C
should pick 1 3/4 of the time and 2 the rest.
67. Larger, non-strictly determined games
Theorem
Consider a game with payoff matrix A, where each entry of A is
positive.
1
The column player’s optimal strategy q is z x, where x ≥ 0
satisfies the LP problem of maximizing z = x1 + · · · + xn
subject to the constraints Ax ≤ 1.
1
The row player’s optimal strategy p is is w y, where y ≥ 0
satisfies the LP problem of minimizing w = y1 + · · · + yn
subject to the constraint that A y ≥ 1.
The two problems are dual to each other, so the optimal
values of the objective are the same. The value of the game is
1 1
v = z = w.
68. Method
By adding a constant to every entry in the payoff matrix A,
make sure every entry is positive
Solve the LP problem of maximizing z = x1 + · · · + xn subject
to the constraints Ax ≤ 1.
1
Then v = z and the entries of q are the entries of x divided
by z
The values of the slack variables, again divided by z, are the
entries of p.
The value of the game is v , minus the quantity added at the
beginning
See Lesson 35 and the Game Theory problem set solutions for
details.