CS 312: Algorithm Analysis - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

CS 312: Algorithm Analysis

Description:

Project Guidelines and scaffolding code available on the ... Save the sum of those costs in the bound (as a rough draft). Can we find a tighter lower bound? ... – PowerPoint PPT presentation

Number of Views:53
Avg rating:3.0/5.0
Slides: 30
Provided by: ericri4
Category:

less

Transcript and Presenter's Notes

Title: CS 312: Algorithm Analysis


1
CS 312 Algorithm Analysis
  • Lecture 33 Solving the Traveling Salesperson
    Problem with Branch and Bound

2
Announcements
  • Homework 22 due today
  • Project 6 Solving the TSP using Branch and
    Bound
  • Project Guidelines and scaffolding code available
    on the schedule (as of Friday)
  • Helpful notes available on the schedule (actually
    required reading for today)
  • Due date Monday 4/16
  • No Improvement
  • This project report is worth 10 of final grade
  • Give this project your best effort!
  • Help Session
  • Tuesday (tomorrow)
  • 5-6pm
  • 164 TNRB

3
Objectives
  • Lecture 33 Solving the TSP with Branch and
    Bound
  • Review the TSP
  • Learn a sophisticated bounding function for the
    TSP
  • Reason about Tight Bounds
  • Review general BB algorithm
  • Lecture 32 Branch and Bound
  • Understand the difference between backtracking
    and branch and bound
  • Understand bounding functions
  • Implement branch and bound algorithm for Job
    Assignment Problem (high level)
  • Contrast Iterative DFS, BFS, and BB in
    Pseudo-code

4
Traveling Salesperson Problem
  • Rudrata or Hamiltonian Cycle
  • Cycle in the graph that passes through each
    vertex exactly once
  • Least Cost or shortest

5
Bound on TSP Tour
1
9
8
2
10
6
5
3
12
7
4
Every tour must leave every vertex and and arrive
at every vertex.
6
Bound on TSP Tour
1
9
8
2
10
6
5
3
12
7
4
Whats the cheapest way to leave each vertex?
7
Bound on TSP Tour
bound86321
1
9
8
2
10
6
5
3
12
7
4
Save the sum of those costs in the bound (as a
rough draft). Can we find a tighter lower bound?
8
Bound on TSP Tour
bound20
1
9-81
8-80
2
10
6
4
3
12
7
4
For a given vertex, subtract the least cost
departure from each edge leaving that vertex.
9
Bound on TSP Tour
bound20
0
1
0
0
9
0
2
0
6
1
1
Repeat for the other vertices.
10
Bound on TSP Tour
bound20
0
1
0
0
9
0
2
0
6
1
1
Does that set of edges now having 0 residual cost
arrive at every vertex? In this case, the edges
never arrive at vertex 3.
11
Bound on TSP Tour
bound21
0
1
0
0
9
0
1
0
6
0
1
We have to take an edge to vertex 3 from
somewhere. Assume we take the cheapest.
Subtract its cost from other edges entering
vertex 3 and add the cost to the bound. We have
just tightened the bound.
12
The Bound
  • It will cost at least this much to visit all the
    vertices in the graph.
  • theres no cheaper way to get in and out of each
    vertex.
  • the edges are now labeled with the extra cost of
    choosing another edge.

13
Bound on TSP Tour
Algorithms do this using a cost matrix.
14
Bound on TSP Tour
Reduce all rows.
15
Bound on TSP Tour
Then reduce column 3. Now we have a tight bound.
16
Pause
  • Lets start the search
  • Arbitrarily start at vertex 1
  • Ignore the BSSF for now
  • Focus on the bound function and on the reduced
    cost matrix

17
Using this bound for TSP in BB
bound 21
1to2
1to3
1to4
1to5
bound 211
18
Focus going from 1 to 2
bound 21
1to2
0
1
0
1
0
0
0
9
9
0
1
0
1
6
6
0
0
bound 211
1
1
Add extra cost from 1 to 2, exclude edges from 1
or into 2.
19
Focus going from 1 to 2
bound 21
1to2
0
1
0
1
0
0
0
9
9
0
1
0
1
6
6
0
0
bound 2111
1
1
No edges into vertex 4 w/ 0 reduced cost.
20
Focus going from 1 to 2
bound 21
1to2
0
1
0
8
1
6
0
bound 2111
0
Add cost of reducing edge into vertex 4.
21
Bounds for other choices.
bound 21
1to2(23),1to4(21)
1to2
1to3
1to4
1to5
bound 23
bound 999
bound 21
bound 999
22
Leaves us with Two Possibilities on Priority Queue
0
1
0
0
0
0
9
0
1
1
0
6
6
0
0
1
bound 23
bound 21
23
Leaving Vertex 4
0
0
4to2(22), 4to3(21) 4to5(28),1to2(23),
bound 21
0
0
1
0
6
0
4to2
4to3
4to5
bound 22
bound 21
bound 28
24
Leaving Vertex 3
0
bound 21
0
4to2(22), 3to2(21) 1to2(23),
0
0
6
0
3to5
3to2
bound 21
bound 999
25
Search Tree for This Problem
b21
b23
b999
b21
b999
b22
b21
b28
b21
b999
26
Review Elements of BB Algorithm
  • Generating child states from parent state
  • Determines the structure of the search tree
  • Managing the priority queue and the best solution
    so far
  • Deciding when to terminate the algorithm

27
Review Branch and Bound
function BandB(state) BSSF ? quick-solution(state
) // BSSF.c holds cost Q ? empty-priority-queue
state.c ? cost(state) Q.enqueue(state,
c) while !Q.empty() and time remains do s ?
Q.first() Q.dequeue() if s.c lt BSSF.c
then children generate_children(s) for
each child in children do child.c ?
cost(child) if (criterion(child) and (child.c
lt BSSF.c)) then BSSF ? child else if
(partial_criterion(child) and (child.c lt BSSF.c))
then Q.enqueue(child, child.c) else
break return BSSF
28
Review Branch and Bound
function BandB(state) BSSF ? quick-solution(state
) // BSSF.c holds cost Q ? empty-priority-queue
state.c ? cost(state) Q.enqueue(state,
c) while !Q.empty() and time remains do s ?
Q.first() Q.dequeue() children
generate_children(s) for each child in children
do child.c ? cost(child) if
(criterion(child) and (child.c lt BSSF.c))
then BSSF ? child Q.trim(BSSF) else if
(partial_criterion(child) and (child.c lt BSSF.c))
then Q.enqueue(child, child.c) return BSSF
29
Assignment
  • HW 23 See schedule.
Write a Comment
User Comments (0)
About PowerShow.com