SlideShare a Scribd company logo
1 of 48
Approximation Algorithms
for NP – Hard Problems
Dr. P. Subathra
Professor
Dept. of IT
KAMARAJ College of Engg. & Tech.
(AUTONOMOUS)
Madurai
1
Approximation Algorithms
• We discuss a different approach to handling
difficult problems of combinatorial
optimization
• Traveling salesman problem and the knapsack
problem
• The decision versions of these problems are
NP-complete.
• The optimization versions fall in the class of
NP-hard problems
2
Approximation Algorithms
• There are no known polynomial-time
algorithms for these problems
• So how do we handle them?
• If an instance of the problem in question is
very small
– exhaustive-search algorithm
– dynamic programming technique
– branch-and-bound technique (comparatively
larger problems can be solved)
3
Approximation Algorithms
• There is a radically different way of dealing
with difficult optimization problems:
• solve them approximately by a fast algorithm.
• applications where a good but not necessarily
optimal solution will suffice
• approximation algorithms run based on some
problem-specific heuristic.
4
Approximation Algorithms
• A heuristic is a common-sense rule drawn
from experience rather than from a
mathematically proved assertion.
5
How accurate this approximation is?
• The accuracy of an approximate solution sa to
a problem of minimizing some function f by
the size of the relative error of this
approximation,
where s ∗ is an exact solution to the problem.
6
How accurate this approximation is?
• accuracy ratio
• Minimization Problem
• Maximization Problem
• The closer r(sa) is to 1, the better the
approximate solution is.
7
POLYNOMIAL-TIME APPROXIMATION
ALGORITHM
DEFINITION
• A polynomial-time approximation algorithm is said to
be a c-approximation algorithm, where c ≥ 1, if the
accuracy ratio of the approximation it produces does
not exceed c for any instance of the problem in
question:
• The best (i.e., the smallest) value of c is called the
performance ratio of the algorithm and denoted RA.
8
POLYNOMIAL-TIME APPROXIMATION
ALGORITHM
• We would like to have approximation
algorithms with RA as close to 1 as possible.
• Some approximation algorithms have infinitely
large performance ratios (RA=∞).
9
Travelling Salesman Problem
Approximation Algorithms
10
Travelling Salesman Problem
• There are more than a dozen approximation
algorithms that solve TSP in a reasonable
amount of time producing an approximate
solution.
• Example:
– Greedy Algorithms for the TSP
– Minimum-Spanning-Tree–Based Algorithms
– Local Search Heuristics
11
Travelling Salesman Problem
– Greedy Algorithms for the TSP
• Nearest-neighbor algorithm
• Multifragment-heuristic algorithm
– Minimum-Spanning-Tree–Based Algorithms
• Twice-around-the-tree algorithm
• Christofides Algorithm
– Local Search Heuristics
• 2-opt algorithms
• 3-opt algorithms
• Lin-Kernighan algorithms
12
Approximation Algorithm for TSP
Greedy Algorithms for the TSP
• Nearest-neighbor algorithm
• Multifragment-heuristic algorithm
13
Greedy Algorithms for the TSP:
Nearest-neighbor algorithm
Nearest-neighbor algorithm
• Algorithm:
Step 1 Choose an arbitrary city as the start.
Step 2 Repeat the following operation until
all the cities have been visited:
go to the unvisited city nearest the one
visited last (ties can be broken arbitrarily).
Step 3 Return to the starting city.
14
Nearest-neighbor algorithm
With a as the starting vertex,
the nearest-neighbor algorithm
yields the tour (Hamiltonian
circuit) sa:
a − b − c − d − a of length 10.
15
Nearest-neighbor algorithm
An optimal solution can be s*:
a − c − d − b − a of length 8.
16
Nearest-neighbor algorithm
The accuracy ratio of this
approximation is
• If the last links weight is ∞,
then the cost of the solution
will be infinity.
• Hence, RA =∞for this
algorithm
17
Greedy Algorithms for the TSP:
Multifragment-heuristic algorithm
Multifragment-heuristic algorithm
• It is problem of finding a minimum-weight
collection of edges in a given complete
weighted graph so that all the vertices have
degree 2.
18
Multifragment-heuristic algorithm
• Step 1
– Sort the edges in increasing order of their weights. (Ties
can be broken arbitrarily.)
– Initialize the set of tour edges to be constructed to the
empty set.
• Step 2
– Repeat this step n times, where n is the number of cities in
the instance being solved:
– add the next edge on the sorted edge list to the set of tour
edges, provided this addition does not create a vertex of
degree 3 or a cycle of length less than n;
– otherwise, skip the edge.
• Step 3
– Return the set of tour edges.
19
Multifragment-heuristic algorithm
• Sorted Edges as per weights:
{(a,b), (c,d), (b,c), (a,c), (b,d), (a,d)}
{ 1 , 1 , 2 , 3 , 3 , 6 }
• Initial Tour Set = {}
• Inset edge to Tour Set = {(a,b)} - OK
• Inset edge to Tour Set = {(c,d)} – OK
• Inset edge to Tour Set = {(b,c)} - OK
• Inset edge to Tour Set = {(a,c)} – NO
• Inset edge to Tour Set = {(b,d)} – NO
• Inset edge to Tour Set = {(a,d)} - OK
20
Multifragment-heuristic algorithm
• This method is applied to Eucledian Graphs
which follows the below conditions:
– triangle inequality d[i, j ]≤ d[i, k]+ d[k, j] for any
triple of cities i, j, and K
– symmetry d[i, j ]= d[j, i] for any pair of cities i and j
• Accuracy ratio satisfy the following inequality
21
Approximation Algorithm for TSP
Minimum-Spanning-Tree–Based Algorithms
• Twice-around-the-tree algorithm
• Christofides Algorithm
• There are approximation algorithms for the
traveling salesman problem that exploit a
connection between Hamiltonian circuits and
spanning trees of the same graph.
• Removing an edge from a Hamiltonian circuit
yields a spanning tree, so we use Min Span Tree
to produce a TSP tour
22
Minimum-Spanning-Tree–Based Algorithms
Twice-around-the-tree algorithm
• Step 1 Construct a minimum spanning tree of the graph
corresponding to a given instance of the traveling salesman
problem.
• Step 2 Starting at an arbitrary vertex, perform a walk around the
minimum spanning tree recording all the vertices passed by. (DFS
traversal.)
• Step 3 Scan the vertex list obtained in Step 2 and eliminate from it
all repeated occurrences of the same vertex except the starting one
at the end of the list. The vertices remaining on the list will form a
Hamiltonian circuit, which is the output of the algorithm.
23
Twice-around-the-tree algorithm
Initial Graph Minimum Spanning Tree
24
Twice-around-the-tree algorithm
Minimum Spanning Tree DFS - a, b, c, b, d, e, d, b, a.
25
Twice-around-the-tree algorithm
DFS - a, b, c, b, d, e, d, b, a. Eliminating the Second
Occurrences
a – b – c – d – e - a
26
Twice-around-the-tree algorithm
Initial Graph TSP : Cost = 4+6+10+7+12 = 39
27
Minimum-Spanning-Tree–Based Algorithms
Christofides Algorithm
• It also uses a minimum spanning tree like twice-
around-the-tree algorithm
• Eulerian circuit exists in a connected multigraph if and
only if all its vertices have even degrees.
• The Christofides algorithm obtains such a multigraph
by adding to the graph the edges of a minimum-weight
matching of all the odd-degree vertices in its minimum
spanning tree.
• Then the algorithm finds an Eulerian circuit in the
multigraph and transforms it into a Hamiltonian circuit
28
Christofides Algorithm
Algorithm
Step 1. Find a minimum spanning tree T
Step 2. Find a minimum matching M for the odd-
degree vertices in T
Step 3. Add M to T
Step 4. Find an Euler tour
Step 5. Cut short
29
Christofides Algorithm – Step 1
Initial Graph Minimum Spanning Tree
30
Christofides Algorithm – Step 2
• Odd degree edges:
a, b, c, e
• Possible matching pairs
with cost are :
(a,b) & (c,e) = 4+11 = 15
(a,c) & (b,e) = 8+ 9 = 17
(a,e) & (b,c) = 12+ 6 = 18
• Minimum of it is:
(a,b) & (c,e) = 4+11 = 15
31
Christofides Algorithm – Step 2
• Odd degree edges:
a, b, c, e
• Possible matching pairs
with cost are :
(a,b) & (c,e) = 4+11 = 15
(a,c) & (b,e) = 8+ 9 = 17
(a,e) & (b,c) = 12+ 6 = 18
• Minimum of it is:
(a,b) & (c,e) = 4+11 = 15
32
Christofides Algorithm – Step 3
Minimum Spanning Tree Matching Pair Added to MST
33
Christofides Algorithm – Step 4
Matching Pair Added to MST Euler Tour / Euler Circuit
a – b- c – e – d – b - a
34
Christofides Algorithm – Step 5
Initial Graph Cut Short - Eliminate Repetition
a – b- c – e – d – b - a
a – b - c – e – d - a
Hamiltonian Circuit
35
Approximation Algorithm for TSP
Local Search Heuristics
• 2-opt algorithms
• 3-opt algorithms
• Lin-Kernighan algorithms
• Good approximations to optimal tours can be
obtained by iterative-improvement algorithms,
which are also called local search heuristics.
36
LOCAL SEARCH HEURISTICS
• These algorithms start with some initial tour
• On each iteration, the algorithm explores a
neighborhood around the current tour by replacing a
few edges in the current tour by other edges.
• If the changes produce a shorter tour, the algorithm
makes it the current tour and continues by exploring its
neighborhood in the same manner
• otherwise, the current tour is returned as the
algorithm’s output and the algorithm stops
37
LOCAL SEARCH HEURISTICS
2-OPT ALGORITHMS
• The 2-opt algorithm works by deleting a pair
of nonadjacent edges in a tour and
reconnecting their endpoints by the different
pair of edges to obtain another Tour
• This operation is called the 2-change.
38
2-OPT ALGORITHMS
39
2-OPT ALGORITHM
• Choice 1
40
2-OPT ALGORITHM
• Choice 2
41
2-OPT ALGORITHM
• Choice 3
42
2-OPT ALGORITHM
• Choice 4
43
3-OPT ALGORITHMS
• 2 different options
44
Lin-Kernighan algorithm
• The Lin-Kernighan algorithm is a variable-opt
algorithm: its move can be viewed as a 3-opt
move followed by a sequence of 2-opt moves.
45
Approximation Algorithms for TSP
– Greedy Algorithms for the TSP
• Nearest-neighbor algorithm
• Multifragment-heuristic algorithm
– Minimum-Spanning-Tree–Based Algorithms
• Twice-around-the-tree algorithm
• Christofides Algorithm
– Local Search Heuristics
• 2-opt algorithms
• 3-opt algorithms
• Lin-Kernighan algorithms
46
Approximation Algorithms for TSP
47
APPLICATIONS OF TSP
• Circuit Board and VLSI – chip fabrication
• X-ray crystallography
• Genetic Engineering
48

More Related Content

What's hot (20)

Kruskal & Prim's Algorithm
Kruskal & Prim's AlgorithmKruskal & Prim's Algorithm
Kruskal & Prim's Algorithm
 
Network flow problems
Network flow problemsNetwork flow problems
Network flow problems
 
SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS
 
Vertex cover Problem
Vertex cover ProblemVertex cover Problem
Vertex cover Problem
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's Algorithm
 
Travelling salesman dynamic programming
Travelling salesman dynamic programmingTravelling salesman dynamic programming
Travelling salesman dynamic programming
 
convex hull
convex hullconvex hull
convex hull
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentation
 
Branch & bound
Branch & boundBranch & bound
Branch & bound
 
Heuristc Search Techniques
Heuristc Search TechniquesHeuristc Search Techniques
Heuristc Search Techniques
 
Branch and bound
Branch and boundBranch and bound
Branch and bound
 
Approximation algorithms
Approximation  algorithms Approximation  algorithms
Approximation algorithms
 
Dijkstra’S Algorithm
Dijkstra’S AlgorithmDijkstra’S Algorithm
Dijkstra’S Algorithm
 
Shortest path algorithms
Shortest path algorithmsShortest path algorithms
Shortest path algorithms
 
Backtracking
BacktrackingBacktracking
Backtracking
 
Solution of N Queens Problem genetic algorithm
Solution of N Queens Problem genetic algorithm  Solution of N Queens Problem genetic algorithm
Solution of N Queens Problem genetic algorithm
 
Optimal binary search tree dynamic programming
Optimal binary search tree   dynamic programmingOptimal binary search tree   dynamic programming
Optimal binary search tree dynamic programming
 
Traveling salesman problem
Traveling salesman problemTraveling salesman problem
Traveling salesman problem
 
Travelling salesman problem
Travelling salesman problemTravelling salesman problem
Travelling salesman problem
 
Lecture optimal binary search tree
Lecture optimal binary search tree Lecture optimal binary search tree
Lecture optimal binary search tree
 

Similar to Approximation Algorithms TSP

Data Analysis and Algorithms Lecture 1: Introduction
 Data Analysis and Algorithms Lecture 1: Introduction Data Analysis and Algorithms Lecture 1: Introduction
Data Analysis and Algorithms Lecture 1: IntroductionTayyabSattar5
 
Undecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsUndecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsMuthu Vinayagam
 
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWERUndecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWERmuthukrishnavinayaga
 
unit-4-dynamic programming
unit-4-dynamic programmingunit-4-dynamic programming
unit-4-dynamic programminghodcsencet
 
Least Square Optimization and Sparse-Linear Solver
Least Square Optimization and Sparse-Linear SolverLeast Square Optimization and Sparse-Linear Solver
Least Square Optimization and Sparse-Linear SolverJi-yong Kwon
 
Computer algorithm(Dynamic Programming).pdf
Computer algorithm(Dynamic Programming).pdfComputer algorithm(Dynamic Programming).pdf
Computer algorithm(Dynamic Programming).pdfjannatulferdousmaish
 
10_support_vector_machines (1).pptx
10_support_vector_machines (1).pptx10_support_vector_machines (1).pptx
10_support_vector_machines (1).pptxshyedshahriar
 
Chapter 5.pptx
Chapter 5.pptxChapter 5.pptx
Chapter 5.pptxTekle12
 
Discrete Computaional Geometry
Discrete Computaional GeometryDiscrete Computaional Geometry
Discrete Computaional GeometrySaurav Mistry
 
AAC ch 3 Advance strategies (Dynamic Programming).pptx
AAC ch 3 Advance strategies (Dynamic Programming).pptxAAC ch 3 Advance strategies (Dynamic Programming).pptx
AAC ch 3 Advance strategies (Dynamic Programming).pptxHarshitSingh334328
 
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdfCS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdfOpenWorld6
 
Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Muhammad Hammad Waseem
 
Particle Swarm Optimization to Solve Multiple Traveling Salesman Problem
Particle Swarm Optimization to Solve Multiple Traveling Salesman ProblemParticle Swarm Optimization to Solve Multiple Traveling Salesman Problem
Particle Swarm Optimization to Solve Multiple Traveling Salesman ProblemIRJET Journal
 
Introduction to dynamic programming
Introduction to dynamic programmingIntroduction to dynamic programming
Introduction to dynamic programmingAmisha Narsingani
 

Similar to Approximation Algorithms TSP (20)

Data Analysis and Algorithms Lecture 1: Introduction
 Data Analysis and Algorithms Lecture 1: Introduction Data Analysis and Algorithms Lecture 1: Introduction
Data Analysis and Algorithms Lecture 1: Introduction
 
Undecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsUndecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation Algorithms
 
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWERUndecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
 
unit-4-dynamic programming
unit-4-dynamic programmingunit-4-dynamic programming
unit-4-dynamic programming
 
Algorithms Lab PPT
Algorithms Lab PPTAlgorithms Lab PPT
Algorithms Lab PPT
 
Least Square Optimization and Sparse-Linear Solver
Least Square Optimization and Sparse-Linear SolverLeast Square Optimization and Sparse-Linear Solver
Least Square Optimization and Sparse-Linear Solver
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Computer algorithm(Dynamic Programming).pdf
Computer algorithm(Dynamic Programming).pdfComputer algorithm(Dynamic Programming).pdf
Computer algorithm(Dynamic Programming).pdf
 
10_support_vector_machines (1).pptx
10_support_vector_machines (1).pptx10_support_vector_machines (1).pptx
10_support_vector_machines (1).pptx
 
Chapter 5.pptx
Chapter 5.pptxChapter 5.pptx
Chapter 5.pptx
 
Discrete Computaional Geometry
Discrete Computaional GeometryDiscrete Computaional Geometry
Discrete Computaional Geometry
 
Unit3_1.pdf
Unit3_1.pdfUnit3_1.pdf
Unit3_1.pdf
 
Na ch02
Na ch02Na ch02
Na ch02
 
AAC ch 3 Advance strategies (Dynamic Programming).pptx
AAC ch 3 Advance strategies (Dynamic Programming).pptxAAC ch 3 Advance strategies (Dynamic Programming).pptx
AAC ch 3 Advance strategies (Dynamic Programming).pptx
 
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdfCS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
 
Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Particle Swarm Optimization to Solve Multiple Traveling Salesman Problem
Particle Swarm Optimization to Solve Multiple Traveling Salesman ProblemParticle Swarm Optimization to Solve Multiple Traveling Salesman Problem
Particle Swarm Optimization to Solve Multiple Traveling Salesman Problem
 
Simplex Algorithm
Simplex AlgorithmSimplex Algorithm
Simplex Algorithm
 
Introduction to dynamic programming
Introduction to dynamic programmingIntroduction to dynamic programming
Introduction to dynamic programming
 

More from P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai

More from P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai (20)

TestFile
TestFileTestFile
TestFile
 
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
 
2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS
 
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
2.2 stack applications Infix to Postfix & Evaluation of Post Fix2.2 stack applications Infix to Postfix & Evaluation of Post Fix
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
 
1. 6 doubly linked list
1. 6 doubly linked list1. 6 doubly linked list
1. 6 doubly linked list
 
1. 5 Circular singly linked list
1. 5 Circular singly linked list1. 5 Circular singly linked list
1. 5 Circular singly linked list
 
1. 4 Singly linked list deletion
1. 4 Singly linked list deletion1. 4 Singly linked list deletion
1. 4 Singly linked list deletion
 
1. 3 singly linked list insertion 2
1. 3 singly linked list   insertion 21. 3 singly linked list   insertion 2
1. 3 singly linked list insertion 2
 
1. 2 Singly Linked List
1. 2 Singly Linked List1. 2 Singly Linked List
1. 2 Singly Linked List
 
1. C Basics for Data Structures Bridge Course
1. C Basics for Data Structures   Bridge Course1. C Basics for Data Structures   Bridge Course
1. C Basics for Data Structures Bridge Course
 
The stable marriage problem iterative improvement method
The stable marriage problem iterative improvement methodThe stable marriage problem iterative improvement method
The stable marriage problem iterative improvement method
 
Maximum matching in bipartite graphs iterative improvement method
Maximum matching in bipartite graphs   iterative improvement methodMaximum matching in bipartite graphs   iterative improvement method
Maximum matching in bipartite graphs iterative improvement method
 
Knapsack dynamic programming formula top down (1)
Knapsack dynamic programming formula top down (1)Knapsack dynamic programming formula top down (1)
Knapsack dynamic programming formula top down (1)
 
Knapsack dynamic programming formula bottom up
Knapsack dynamic programming formula bottom upKnapsack dynamic programming formula bottom up
Knapsack dynamic programming formula bottom up
 
Huffman tree coding greedy approach
Huffman tree coding  greedy approachHuffman tree coding  greedy approach
Huffman tree coding greedy approach
 
Simplex method
Simplex methodSimplex method
Simplex method
 
Simplex method
Simplex methodSimplex method
Simplex method
 
Multiplication of integers & strassens matrix multiplication subi notes
Multiplication of integers & strassens matrix multiplication   subi notesMultiplication of integers & strassens matrix multiplication   subi notes
Multiplication of integers & strassens matrix multiplication subi notes
 
Multiplication of large integers problem subi notes
Multiplication of large integers  problem  subi notesMultiplication of large integers  problem  subi notes
Multiplication of large integers problem subi notes
 
Huffman tree coding
Huffman tree codingHuffman tree coding
Huffman tree coding
 

Recently uploaded

VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 

Recently uploaded (20)

VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 

Approximation Algorithms TSP

  • 1. Approximation Algorithms for NP – Hard Problems Dr. P. Subathra Professor Dept. of IT KAMARAJ College of Engg. & Tech. (AUTONOMOUS) Madurai 1
  • 2. Approximation Algorithms • We discuss a different approach to handling difficult problems of combinatorial optimization • Traveling salesman problem and the knapsack problem • The decision versions of these problems are NP-complete. • The optimization versions fall in the class of NP-hard problems 2
  • 3. Approximation Algorithms • There are no known polynomial-time algorithms for these problems • So how do we handle them? • If an instance of the problem in question is very small – exhaustive-search algorithm – dynamic programming technique – branch-and-bound technique (comparatively larger problems can be solved) 3
  • 4. Approximation Algorithms • There is a radically different way of dealing with difficult optimization problems: • solve them approximately by a fast algorithm. • applications where a good but not necessarily optimal solution will suffice • approximation algorithms run based on some problem-specific heuristic. 4
  • 5. Approximation Algorithms • A heuristic is a common-sense rule drawn from experience rather than from a mathematically proved assertion. 5
  • 6. How accurate this approximation is? • The accuracy of an approximate solution sa to a problem of minimizing some function f by the size of the relative error of this approximation, where s ∗ is an exact solution to the problem. 6
  • 7. How accurate this approximation is? • accuracy ratio • Minimization Problem • Maximization Problem • The closer r(sa) is to 1, the better the approximate solution is. 7
  • 8. POLYNOMIAL-TIME APPROXIMATION ALGORITHM DEFINITION • A polynomial-time approximation algorithm is said to be a c-approximation algorithm, where c ≥ 1, if the accuracy ratio of the approximation it produces does not exceed c for any instance of the problem in question: • The best (i.e., the smallest) value of c is called the performance ratio of the algorithm and denoted RA. 8
  • 9. POLYNOMIAL-TIME APPROXIMATION ALGORITHM • We would like to have approximation algorithms with RA as close to 1 as possible. • Some approximation algorithms have infinitely large performance ratios (RA=∞). 9
  • 11. Travelling Salesman Problem • There are more than a dozen approximation algorithms that solve TSP in a reasonable amount of time producing an approximate solution. • Example: – Greedy Algorithms for the TSP – Minimum-Spanning-Tree–Based Algorithms – Local Search Heuristics 11
  • 12. Travelling Salesman Problem – Greedy Algorithms for the TSP • Nearest-neighbor algorithm • Multifragment-heuristic algorithm – Minimum-Spanning-Tree–Based Algorithms • Twice-around-the-tree algorithm • Christofides Algorithm – Local Search Heuristics • 2-opt algorithms • 3-opt algorithms • Lin-Kernighan algorithms 12
  • 13. Approximation Algorithm for TSP Greedy Algorithms for the TSP • Nearest-neighbor algorithm • Multifragment-heuristic algorithm 13
  • 14. Greedy Algorithms for the TSP: Nearest-neighbor algorithm Nearest-neighbor algorithm • Algorithm: Step 1 Choose an arbitrary city as the start. Step 2 Repeat the following operation until all the cities have been visited: go to the unvisited city nearest the one visited last (ties can be broken arbitrarily). Step 3 Return to the starting city. 14
  • 15. Nearest-neighbor algorithm With a as the starting vertex, the nearest-neighbor algorithm yields the tour (Hamiltonian circuit) sa: a − b − c − d − a of length 10. 15
  • 16. Nearest-neighbor algorithm An optimal solution can be s*: a − c − d − b − a of length 8. 16
  • 17. Nearest-neighbor algorithm The accuracy ratio of this approximation is • If the last links weight is ∞, then the cost of the solution will be infinity. • Hence, RA =∞for this algorithm 17
  • 18. Greedy Algorithms for the TSP: Multifragment-heuristic algorithm Multifragment-heuristic algorithm • It is problem of finding a minimum-weight collection of edges in a given complete weighted graph so that all the vertices have degree 2. 18
  • 19. Multifragment-heuristic algorithm • Step 1 – Sort the edges in increasing order of their weights. (Ties can be broken arbitrarily.) – Initialize the set of tour edges to be constructed to the empty set. • Step 2 – Repeat this step n times, where n is the number of cities in the instance being solved: – add the next edge on the sorted edge list to the set of tour edges, provided this addition does not create a vertex of degree 3 or a cycle of length less than n; – otherwise, skip the edge. • Step 3 – Return the set of tour edges. 19
  • 20. Multifragment-heuristic algorithm • Sorted Edges as per weights: {(a,b), (c,d), (b,c), (a,c), (b,d), (a,d)} { 1 , 1 , 2 , 3 , 3 , 6 } • Initial Tour Set = {} • Inset edge to Tour Set = {(a,b)} - OK • Inset edge to Tour Set = {(c,d)} – OK • Inset edge to Tour Set = {(b,c)} - OK • Inset edge to Tour Set = {(a,c)} – NO • Inset edge to Tour Set = {(b,d)} – NO • Inset edge to Tour Set = {(a,d)} - OK 20
  • 21. Multifragment-heuristic algorithm • This method is applied to Eucledian Graphs which follows the below conditions: – triangle inequality d[i, j ]≤ d[i, k]+ d[k, j] for any triple of cities i, j, and K – symmetry d[i, j ]= d[j, i] for any pair of cities i and j • Accuracy ratio satisfy the following inequality 21
  • 22. Approximation Algorithm for TSP Minimum-Spanning-Tree–Based Algorithms • Twice-around-the-tree algorithm • Christofides Algorithm • There are approximation algorithms for the traveling salesman problem that exploit a connection between Hamiltonian circuits and spanning trees of the same graph. • Removing an edge from a Hamiltonian circuit yields a spanning tree, so we use Min Span Tree to produce a TSP tour 22
  • 23. Minimum-Spanning-Tree–Based Algorithms Twice-around-the-tree algorithm • Step 1 Construct a minimum spanning tree of the graph corresponding to a given instance of the traveling salesman problem. • Step 2 Starting at an arbitrary vertex, perform a walk around the minimum spanning tree recording all the vertices passed by. (DFS traversal.) • Step 3 Scan the vertex list obtained in Step 2 and eliminate from it all repeated occurrences of the same vertex except the starting one at the end of the list. The vertices remaining on the list will form a Hamiltonian circuit, which is the output of the algorithm. 23
  • 25. Twice-around-the-tree algorithm Minimum Spanning Tree DFS - a, b, c, b, d, e, d, b, a. 25
  • 26. Twice-around-the-tree algorithm DFS - a, b, c, b, d, e, d, b, a. Eliminating the Second Occurrences a – b – c – d – e - a 26
  • 27. Twice-around-the-tree algorithm Initial Graph TSP : Cost = 4+6+10+7+12 = 39 27
  • 28. Minimum-Spanning-Tree–Based Algorithms Christofides Algorithm • It also uses a minimum spanning tree like twice- around-the-tree algorithm • Eulerian circuit exists in a connected multigraph if and only if all its vertices have even degrees. • The Christofides algorithm obtains such a multigraph by adding to the graph the edges of a minimum-weight matching of all the odd-degree vertices in its minimum spanning tree. • Then the algorithm finds an Eulerian circuit in the multigraph and transforms it into a Hamiltonian circuit 28
  • 29. Christofides Algorithm Algorithm Step 1. Find a minimum spanning tree T Step 2. Find a minimum matching M for the odd- degree vertices in T Step 3. Add M to T Step 4. Find an Euler tour Step 5. Cut short 29
  • 30. Christofides Algorithm – Step 1 Initial Graph Minimum Spanning Tree 30
  • 31. Christofides Algorithm – Step 2 • Odd degree edges: a, b, c, e • Possible matching pairs with cost are : (a,b) & (c,e) = 4+11 = 15 (a,c) & (b,e) = 8+ 9 = 17 (a,e) & (b,c) = 12+ 6 = 18 • Minimum of it is: (a,b) & (c,e) = 4+11 = 15 31
  • 32. Christofides Algorithm – Step 2 • Odd degree edges: a, b, c, e • Possible matching pairs with cost are : (a,b) & (c,e) = 4+11 = 15 (a,c) & (b,e) = 8+ 9 = 17 (a,e) & (b,c) = 12+ 6 = 18 • Minimum of it is: (a,b) & (c,e) = 4+11 = 15 32
  • 33. Christofides Algorithm – Step 3 Minimum Spanning Tree Matching Pair Added to MST 33
  • 34. Christofides Algorithm – Step 4 Matching Pair Added to MST Euler Tour / Euler Circuit a – b- c – e – d – b - a 34
  • 35. Christofides Algorithm – Step 5 Initial Graph Cut Short - Eliminate Repetition a – b- c – e – d – b - a a – b - c – e – d - a Hamiltonian Circuit 35
  • 36. Approximation Algorithm for TSP Local Search Heuristics • 2-opt algorithms • 3-opt algorithms • Lin-Kernighan algorithms • Good approximations to optimal tours can be obtained by iterative-improvement algorithms, which are also called local search heuristics. 36
  • 37. LOCAL SEARCH HEURISTICS • These algorithms start with some initial tour • On each iteration, the algorithm explores a neighborhood around the current tour by replacing a few edges in the current tour by other edges. • If the changes produce a shorter tour, the algorithm makes it the current tour and continues by exploring its neighborhood in the same manner • otherwise, the current tour is returned as the algorithm’s output and the algorithm stops 37
  • 38. LOCAL SEARCH HEURISTICS 2-OPT ALGORITHMS • The 2-opt algorithm works by deleting a pair of nonadjacent edges in a tour and reconnecting their endpoints by the different pair of edges to obtain another Tour • This operation is called the 2-change. 38
  • 44. 3-OPT ALGORITHMS • 2 different options 44
  • 45. Lin-Kernighan algorithm • The Lin-Kernighan algorithm is a variable-opt algorithm: its move can be viewed as a 3-opt move followed by a sequence of 2-opt moves. 45
  • 46. Approximation Algorithms for TSP – Greedy Algorithms for the TSP • Nearest-neighbor algorithm • Multifragment-heuristic algorithm – Minimum-Spanning-Tree–Based Algorithms • Twice-around-the-tree algorithm • Christofides Algorithm – Local Search Heuristics • 2-opt algorithms • 3-opt algorithms • Lin-Kernighan algorithms 46
  • 48. APPLICATIONS OF TSP • Circuit Board and VLSI – chip fabrication • X-ray crystallography • Genetic Engineering 48