Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

TSP Branch-and-Bound Algorithm: Solving Optimal Tour Problems, Study notes of Algorithms and Programming

The implementation of the tsp (traveling salesman problem) branch-and-bound algorithm, a popular optimization technique used to find the shortest possible tour visiting each node in a graph exactly once and returning to the origin. The algorithm uses a priority queue to expand paths with the best estimated cost, prunes branches that cannot lead to an improvement over the current best tour, and recursively generates extensions of promising paths until the optimal solution is found.

Typology: Study notes

Pre 2010

Uploaded on 08/16/2009

koofers-user-9m3
koofers-user-9m3 ๐Ÿ‡บ๐Ÿ‡ธ

4.5

(2)

10 documents

1 / 1

Toggle sidebar

Related documents


Partial preview of the text

Download TSP Branch-and-Bound Algorithm: Solving Optimal Tour Problems and more Study notes Algorithms and Programming in PDF only on Docsity! COMP157 Fall 2007 TSP Branch-and-Bound Algorithm ALGORITHM tsp_branch_and_bound(graph) Inputs: graph, the graph Output: the best (cheapest) tour, possibly null best_tour ๏ƒŸ null // priority queue stores paths in ascending order of their lower bound on potential tour cost queue ๏ƒŸ new priority queue initial_path ๏ƒŸ path containing only node โ€˜aโ€™ compute lower bound for initial_path queue.enqueue(initial_path) while queue is not empty do: // get the path with best estimated cost path_to_expand ๏ƒŸ queue.dequeue // If lower bound on best path_to_expand is worse than best tour, there's no point in continuing if best_tour is not null and path_to_expand.lower_bound >= best_tour.cost do: return best_tour // Is path_to_expand a nearly completed tour? if path_to_expand is complete except for a return to the start node do: // Can we complete the tour? if there is an edge in the graph to complete path_to_expand do: // complete this tour tour ๏ƒŸ copy of path_to_expand tour.add(edge back to start) // is this tour better than best weโ€™ve seen so far? if best_tour is null or tour.cost < best_tour.cost do: best_tour ๏ƒŸ tour else do: // Generate all extensions from path_to_expand and put them in the queue. for node ๏ƒŸ 'a' .. graph.lastNode do: if path_to_expand does not already visit node and graph has an edge from last node in path_to_expand to node do: // create extended path extended_path ๏ƒŸ copy of path_to_extend extended_path.add(node) compute lower bound for extended_path // only put extended path in queue if it is potentially better than best tour if best_tour is null or extended_path.lower_bound < best_tour.cost do: queue.enqueue(extended_path) return best_tour
Docsity logo



Copyright ยฉ 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved