grade 11/12 math circles -...

10
1 Faculty of Mathematics Centre for Education in Waterloo, Ontario Mathematics and Computing Grade 11/12 Math Circles Fall 2014 - Nov. 26 Optimization and Operations Research, Part 2 Shortest Path A graph, G =(V,E), is a set of vertices, V , which are connected by a set of edges, E. Given G =(V,E), with costs c e > 0 for all e E, and two vertices s and t, find the shortest path s - t. Vertices (circles): A,B,C,D,E,F,G Edges (lines): {A,B}, {B,F}, {A,F}, {B,C},... Path is a sequence of adjacent non-repeated vertices Example: (A,B,F,G,E) is an A - E path Cost of path is the sum of the cost of edges Example: Path (A,B,F,G,E) has cost 18

Upload: dangdien

Post on 28-Jul-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

1

Faculty of Mathematics Centre for Education in

Waterloo, Ontario Mathematics and Computing

Grade 11/12 Math Circles

Fall 2014 - Nov. 26

Optimization and Operations Research, Part 2

Shortest Path

A graph, G = (V,E), is a set of vertices, V , which are connected by a set of edges, E. Given

G = (V,E), with costs ce > 0 for all e ∈ E, and two vertices s and t, find the shortest path s− t.

• Vertices (circles): A,B,C,D,E,F,G

• Edges (lines): {A,B}, {B,F}, {A,F}, {B,C},...

• Path is a sequence of adjacent non-repeated vertices

Example: (A,B,F,G,E) is an A− E path

• Cost of path is the sum of the cost of edges

Example: Path (A,B,F,G,E) has cost 18

2

Dijkstra’s Shortest Path Algorithm

Given G = (V,E), with costs ce > 0 for all e ∈ E, and initial vertex s, find the shortest s− v path

for all v ∈ V .

Dijkstra’s algoritme: Maintain a set S for which we know the shorts s− v path of cost d(v) for all

v ∈ S.

1. Let S = {s}, d(s) = 0

2. For all v 6∈ S that are adjacent to some vertex in S do

1. Compute d′(v) = min{d(u) + cuv : u ∈ S, {u, v} ∈ E}

3. Let w be the vertex with smallest d′(v).

4. Let S ← S ∪ {w} and d(w) = d′(w).

Also, the shortest s−w path will be the shortest s− u path in w appended (where u was the

vertex that determined d′(w))

5. If S 6= V , go to step 2.

* See exercises in slideshow for demonstrations of the algorithm.

Guaranteeing Optimality

Question:

Suppose you give me a path that you claim is the shortest possible. If I don’t trust you (or how

you implemented Dijkstra’s algorithm), how can you convince me that you are right (i.e. you

found the optimal solution)?

This is in general a hard question to answer without looking through EVERY single possible

solution (or in this instance running Dijkstra’s algorithm myself).

It is much easier to prove that a solution is NOT optimal than to prove that it is.

3

Introducing Barriers

Suppose I want to claim that the path (s, a, c, b, t) is the shortest s− t path.

A barrier is defined by a set S ⊂ V such that s ∈ S and t 6∈ S.

Let δ(S) be the set of edges that go from a vertex in S to a vertex not in S.

Let w(S) be a given weight associated to barrier S.

Suppose we define w(S) = 3 for S = {s}.

Any path from s to t must cross the above barrier and have length at least w(S).

Shortest path must have length ≥ 3.

4

Suppose we define w(S) = 2 for S = {s, a, c}.

Any path from s to t must cross BOTH barriers and have length at least the sum of the weights of

the barriers.

Shortest path must have length ≥ 5.

Suppose we define w(S) = 1 for S = {s, a, b, c, d}.

Any path from s to t must cross ALL barriers above and have length at least the sum of the weights

of the barriers.

Shortest path must have length ≥ 6.

5

Shortest Path With Barriers

• If the length of each edge is at least the sum of the weights of the barriers that it crosses, then

we have a set of “feasible barriers”

• Let l(P ) be the length of a path P and w(B) be the weight of a set of feasible barriers B.

• We argued that:

l(P ) ≥ w(B), for all paths P and feasible barriers B

• Hence we have a min-max relationship:

min{l(P ) : P is a path} ≥ max{w(B) : B is a set of feasible barriers}

Theorem

If

min{l(P ) : P is a path} = max{w(B) : B is a set of feasible barriers}

Then we have found the optimal solution for the shortest path. This is called a certificate of

optimality.

Give a certificate of optimality for shortest 1 − 15 path (1,2,6,10,14,15). * See solution in

slideshow.

6

Linear Programming

Let’s say we have an optimization problem of producing trains and soldiers subject to carpentry

and finishing hours.

max 3x1 +3x2

s.t. 2x1 +x2 ≤ 8

x1 +3x2 ≤ 9

x1 ≥ 0

x2 ≥ 0

If we graph our constraints we get:

Where the bounds for the inequalities 2x1 + x2 ≤ 8 and x1 + 3x2 ≤ 9 intersect, we have a feasible

solution. * Any points in the white space are feasible.

7

Bounding the Objective Function

Question:

How can we bound the value 3x1+3x2 for any values of (x1, x2) satisfying the constraints below?

max 3x1 +3x2

s.t. 2x1 +x2 ≤ 8

x1 +3x2 ≤ 9

x1 ≥ 0

x2 ≥ 0

Let’s add together multiples of our inequality constraints to see if we can find any bounds:

• 3 × 2nd constraint + 6 × 4th constraint:

3x1 + 3x2 ≤ 27

• 3 × 1nd constraint + 3 × 3rd constraint:

3x1 + 3x2 ≤ 24

• 1st constraint + 2nd constraint + 4th constraint:

3x1 + 3x2 ≤ 17

In general, for any y1, y2, y3, y4 ≥ 0:

3x1 + 3x2 = y1(2x1 + x2) + y2(x1 + 3x2) + y3(−x1) + y4(−x2)

= (2y1 + y2 − y3)x1 + (y1 + 3y2 − y4)x2

≤ 8y1 + 9y2

as long as

(2y1 + y2 − y3) = 3

(y1 + 3y2 − y4) = 3

So any solution must have objective value at most 8y1 + 9y2

8

Duality

This leads to the following related optimization problems:

PRIMAL (P)

max 3x1 +3x2

s.t. 2x1 +x2 ≤ 8

x1 +3x2 ≤ 9

x1 ≥ 0

x2 ≥ 0

DUAL (D)

min 8y1 +9y2

s.t. 2y1 +y2 −y3 = 3

y1 +3y2 − y4 = 3

y1 ≥ 0

y2 ≥ 0

y3 ≥ 0

−y4 ≥ 0

Theorem (Weak Duality)

Let zP be the objective value of a feasible solution to (P) and zD be the objective value of a

feasible solution to (D). Then

zP ≤ zD

Theorem (Strong Duality)

Let zP be the objective value of the optimal solution to (P) and zD be the objective value of

the optimal solution to (D). Then

zP = zD

Using these theorems we know that if we find an objective value zD that equals an objective value

for zP , we have found upper and lower bounds for (P) and (D) respectively.

For the optimization problem above, we know a feasible solution to (P) is x1 = 3, x2 = 2, with

objective value 15. We can for instance find y1 = 1.2, y2 = 0.6, y3 = y4 = 0 which gives an objective

value of 15 for (D). So 15 is an upper bound for (P) and a lower bound for (D).

9

Exercises

Write the dual optimization problem and optimal primal and dual solutions for the linear program-

ming problems below

10