Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 312: Algorithm Analysis

Similar presentations


Presentation on theme: "CS 312: Algorithm Analysis"— Presentation transcript:

1 CS 312: Algorithm Analysis
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. CS 312: Algorithm Analysis Lecture #34: Branch and Bound Design Options for Solving the Traveling Salesman Problem: Tight Bounds Slides by: Eric Ringger, with contributions from Mike Jones, Eric Mercer, and Sean Warnick

2 Announcements Homework #24 due now Homework #25 due Friday
Project #7: TSP ASAP: Read the helpful “B&B for TSP Notes” linked from the schedule Read Project Instructions Today: We continue discussing main ideas Next Wednesday: Early day Week from Friday: due

3 Objectives Review the Traveling Salesman Problem (TSP)
Develop a good bound function for the TSP Reason about Tight Bounds Augment general B&B algorithm

4 Traveling Salesman (Optimization) Problem
Rudrata or Hamiltonian Cycle Cycle in the graph that passes through each vertex exactly once + Find the least cost or “shortest” cycle 1 2 3 4 5 8 6 7 9 10 12 Distinguish from the TSP search problem and the TSP decision problem

5 How to solve? If with B&B, what do we need?

6 How to solve? If with B&B, what do we need?

7 Initial BSSF How to compute? Should be quick.
1 2 3 4 5 How to compute? Should be quick. What if you have a complete graph? What if you don’t? 9 1 8 2 10 6 5 3 7 12 4 If not, think SCC algorithm

8 Simple-Minded Initial BSSF
1 2 3 4 5 Cost of BSSF = = 31 9 1 8 2 10 6 5 3 7 12 4

9 A Bound on Possible TSP Tours
We need a bound function. Lower or Upper? How to compute? 1 2 3 4 5 8 6 7 9 10 12 One good idea not pursued here: MST

10 A Bound on Possible TSP Tours
We need a bound function. Lower or Upper? How to compute? 1 2 3 4 5 8 6 7 9 10 12 One good idea not pursued here: MST

11 A Bound on Possible TSP Tours
1 2 3 4 5 9 1 8 2 10 6 5 3 7 12 4 What’s the cheapest way to leave each vertex?

12 Bound on Possible TSP Tours
1 2 3 4 5 Rough draft bound = = 20 9 1 8 2 10 6 5 3 7 12 4 Save the sum of those costs in the bound (as a rough draft).

13 Bound on Possible TSP Tours
1 2 3 4 5 Rough draft bound = 20 9-8=1 1 8-8=0 2 10 6 4 3 7 12 4 For a given vertex, subtract the least cost departure from each edge leaving that vertex.

14 Bound on Possible TSP Tours
1 2 3 4 5 Rough draft bound = 20 1 9 2 1 6 1 Repeat for the other vertices. What do the numbers on the edges mean now?

15 Bound on Possible TSP Tours
1 2 3 4 5 Rough draft bound = 20 1 9 2 1 6 1 Now, can we find a tighter lower bound?

16 Bound on Possible TSP Tours
1 2 3 4 5 Rough draft bound = 20 1 9 2 1 6 1 Does that set of edges now having 0 residual cost arrive at every vertex?

17 Bound on Possible TSP Tours
1 2 3 4 5 Rough draft bound = 20 1 9 2 1 6 1 In this case, those edges never arrive at vertex #3.

18 Bound on Possible TSP Tours
1 2 3 4 5 Rough draft bound = 20 1 9 2 1 6 1 We have to take an edge to vertex 3 from somewhere. Assume we take the cheapest.

19 Bound on Possible TSP Tours
1 2 3 4 5 Bound = 21 1 9 1 6 1 Subtract its cost from other edges entering vertex 3 and add the cost to the bound. We have just tightened the bound.

20 This Bound It will cost at least this much to visit all the vertices in the graph. There’s no cheaper way to get in and out of each vertex. Each edge is now labeled with the extra cost of choosing that edge. The bound is not a solution; it’s a bound! Why are tight bounds desirable?

21 Bound on Possible TSP Tours
From: 1 2 3 4 5 1 2 3 4 5 8 6 7 9 10 12 Our algorithm can do this reasoning using a cost matrix.

22 Bound on Possible TSP Tours
From: 1 2 3 4 5 1 2 3 4 5 9 6 Reduce all rows.

23 Bound on Possible TSP Tours
From: 1 2 3 4 5 1 2 3 4 5 9 6 Then reduce column #3. Now we have a tighter bound.

24 Search Let’s start the search Arbitrarily start at vertex 1 Focus on:
Why is this OK? Focus on: the bound function and the reduced cost matrix representation of states

25 Using this bound for TSP in B&B
Start at vertex 1 in graph (arbitrary) bound = 21 BSSF=31 What should our state expansion strategy be?

26 Using this bound for TSP in B&B
Start at vertex 1 in graph (arbitrary) bound = 21 BSSF=31 1-2 1-3 1-4 1-5 bound = 21+1 bound = 21

27 Add extra cost from 1 to 2, exclude edges from 1 or into 2.
Focus: going from 1 to 2 bound = 21 BSSF=31 Before After 1 2 3 4 5 1 2 3 4 5 1 1 1-2 9 9 1 1 6 6 1 1 bound = 22 Add extra cost from 1 to 2, exclude edges from 1 or into 2.

28 No edges into vertex 4 w/ 0 reduced cost.
Focus: going from 1 to 2 bound = 21 BSSF=31 Before After 1 2 3 4 5 1 2 3 4 5 1 1 1-2 9 9 1 1 6 6 1 1 bound = 22+1 No edges into vertex 4 w/ 0 reduced cost.

29 Add cost of reducing edge into vertex 4.
Focus: going from 1 to 2 bound = 21 BSSF=31 1 2 3 4 5 1 1-2 8 1 6 bound = Add cost of reducing edge into vertex 4.

30 Bounds for other choices
Agenda: bound = 21 BSSF=31 1-2(23),1-4(21) 1-2 1-3 1-4 1-5 bound = 23 bound = 21

31 Two Possibilities on the Agenda
1 2 3 4 5 1 2 3 4 5 1 9 1 1 6 6 1 bound = 23 bound = 21

32 Leaving Vertex 4 1 2 3 4 5 1 6 BSSF=31 1-4 bound = 21 1-4-2 1-4-3
bound = 21 1 6 1-4-2 1-4-3 1-4-5 bound = 22 bound = 21 bound = 28

33 Leaving Vertex 4 1 2 3 4 5 1 6 BSSF=31 1-4 bound = 21 1-4-2 1-4-3
Agenda: 1-4-2(22), 1-4-3(21) 1-4-5(28),1-2(23) bound = 21 1 6 1-4-2 1-4-3 1-4-5 bound = 22 bound = 21 bound = 28

34 Leaving Vertex 3 1-4-3 BSSF=31 1 2 3 4 5 bound = 21 bound = 21

35 Leaving Vertex 3 1 2 3 4 5 BSSF=31 1-4-3 bound = 21 4-2(22), 3-2(21)
Agenda: 4-2(22), 3-2(21) 4-5(28), 1-2(23), bound = 21 bound = 21

36 Search Tree for This Problem
1-to-2 1-to-4 b=23 b=21 4-to-2 4-to-3 4-to-5 b=22 b=21 b=28 3-to-2 b=21 2-to-5

37 Termination Criteria for a B&B Algorithm
Repeat until Agenda is empty Or time is up Or BSSF cost is equal to original LB

38 Update: Branch and Bound
function BandB(v) BSSF  quick-solution(v) // BSSF.cost holds cost Agenda.clear() v.b  bound(v) Agenda.add(v, v.b) while !Agenda.empty() and time remains and BSSF.cost != v.b do u  Agenda.first() Agenda.remove_first() children = generate_children_ascending(u) for each w in children do if ! time remains then break w.b  bound(w) if (w.b < BSSF.cost) then if criterion(w) then BSSF  w Agenda.prune(BSSF.cost) else if partial_criterion(w) then Agenda.add(w, w.b) return BSSF

39 Assignment HW #25: Compute bound for TSP instance using today’s method
Reason about search for TSP solution


Download ppt "CS 312: Algorithm Analysis"

Similar presentations


Ads by Google