Algorithms

Spring 2007
course
navigation

april 30

backtracking

Textbook algorithm generates one child, then examines that one; algorithm as stated is recursive.
See n_queens/backtrack.py for a sample python n-queens program.

best-first branch-and-bound

Textbook algorithm here generates all children if node is under some bound or within constraints, and adds them to the fringe of "live" nodes. The one with the lowest bound (whichever level of the tree its at) is the one considered next. (And therefore the fringe should be implemented as a heap.)

approximations

Define an "accuracy ratio" of how close a polynomial time approximation comes to the exact answer.

traveling salesman

Text proves that there can't be a polynomial time approximation that does within a constant ratio of exact answer on all cases.
cities 1...N edges E[i,j] lower_bound = sum_i (E[i,j] + E[i,k] ) /2 for two closest cities (j,k) to i
and for a bound that includes any specific edge E[p,q], use that edge in the sum for city p and q along with shortest other to that city
Note that the formulation of this problem typically assumes that you have a "complete weighted graph", that is, you can get from any city to any other.

nearest neighbor algorithm

1. start anywhere 2. go to closest neighbor 3. keep grabbing closest unvisited (greedy) 4. until all are seen; then jump back to original
Not very good; last leg can be very long.

multifragment-heuristic algorithm

1. Sort edges by increasing weight. 2. Initialize "answer" as a set of empty edges. 3. Repeat: Add shortest edge left if i) it doesn't create a vertex of order 3, and ii) it doesn't create a cycle of length less than number of cities
Better than nearest neighbor. Can compare accuracy explicity for "Euclidean" versions of the problem.

twice around the tree algorithm

1. Find minimum spanning tree. 2. Construct "twice around" path, including duplicate over-and-back pieces. 3. Elimate duplicates by using shortcuts

Christofides algorithm

1. assumes Euclidian distances 2. similar to "twice around" but smarter

local search or iterative improvement algorithms

Examples: - 2-opt (delete 2 edges; reconnect differently) - 3-opt (delete 3 edges; reconnect differently) - Lin-Kernighan (well-known, complicated version that uses both of these) Idea is to start with any path and try to make it better by replacing a few edges with other edges.

empirical results

This problem has been studied extensively, and is important in many fields including circuit design.
Held-Karp lower bound for traveling salesman http://www.math.sfu.ca/~goddyn/Courses/820/TSPlowerbounds.pdf is similar to sum; treats as linear programming problem (each city gets a "weight" subject to some constraints") and allow ourselves to violate some of the constraints.
See table of empirical results, pg 447
http://cs.marlboro.edu/ courses/ spring2007/algorithms/ notes/ april_30
last modified Monday April 30 2007 1:51 am EDT