SlideShare a Scribd company logo
1 of 40
Nadar saraswathi college of arts & science,theni.
Department of cs & it
data structures and algorithms
PRESENTED BY
G.KAVIYA
M.SC(IT)
TOPIC:TRAVELLING SALESMAN
PROBLEM.
TRAVELLING SALESMAN
PROBLEM
Travelling Salesman Problem using Branch and
Bound
Travelling salesman problem:
 A set of some cities.
 Distance between every pair of cities.
Travelling salesman problem states-
 A salesman has to visit every city exactly once.
 He has to come back to the city from where he starts his journey.
 What is the shortest possible route that the salesman must
follow to complete his tour?
EXAMPLE:
The following graph shows a set of cities and distances between every pair of
cities-
If salesman starting city is A, then a TSP tour in the given is-
A  B  D  C  A
Cost of the tour
= 10 + 25 + 30 + 15
=80 units.
PRACTICE PROBLEM BASED ON TRAVELLING
SALESMAN PROBLEM USING BRANCH AND BOUND
APPROACH-
Problem-
Solve Travelling Salesman Problem using Branch and Bound Algorithm in the
following graph-
Solution-
Step-01:
Write the initial cost matrix and reduce it-
Row Reduction-
Consider the rows of above matrix one by one.
If the row already contains an entry ‘0’, then-
 There is no need to reduce that row.
If the row does not contains an entry ‘0’, then-
 Reduce that particular row.
 Select the least value element from that row.
 Subtract that element from each element of that row.
 This will create an entry ‘0’ in the row, thus reducing that row.
Following this, we have-
• Reduce the elements of row-1 by 4.
• Reduce the elements of row-2 by 5.
• Reduce the elements of row-3 by 6.
• Reduce the elements of row-4 by 2.
Cont;
Cont;
Performing this, we obtain the following row-reduced matrix-
Column Reduction-
Consider the columns of above row-reduced matrix one by one.
If the contains already contains an entry ‘0’, then-
 There is no need to reduce that column.
Cont;
If the column does not contains an entry ’0’, then-
 Reduce that particular column.
 Select the least value element from that column.
 Subtract that element from each element of that column.
 This will create an entry ‘0’ in the row, thus reducing that column.
Following this, we have-
• There is no need to reduce column-1.
• There is no need to reduce column-2.
• Reduce the elements of column-3 by -1.
• There is no need to reduce column-4.
Cont;
Performing this, we obtain the following column-reduced matrix-
Finally, the initial distance matrix is completely reduced.
Now, we calculate the cost of node-1 by adding all the reduction elements.
Cost(1)
=sum of all reduction elements
=4 + 5 + 6 + 2 + 1
=18
Cont;
Step-02:
o We consider all other vertices one by one.
o We select the best vertex where we can land upon to minimize the tour cost.
Choosing To Go To Vertex-B: Node-2(Path A  B)
• From the reduced matrix of step-1, M[A,B] = 0
• Set row-A and column-B to ∞
• Set M[B,A] = ∞
Cont;
Now, resulting cost matrix is-
Now,
• We reduce this matrix.
• Then, we find out the cost of node-02.
Cont;
Row Reduction-
 We can not reduce row-1 as all its elements are ∞.
 Reduce all the elements of row-2 by 13.
 There is no need to reduce row-3.
 There is no need to reduce row-4.
Performing this, we obtain the following row-reduced matrix-
Cont;
Column Reduction-
 Reduction the elements of column-1 by -5.
 We can not reduce column-2 as all its elements are ∞.
 There is no need to reduce column-3.
 There is no need to reduce column-4.
Performing this, we obtain the following column-reduced matrix-
Cont;
Finally, the matrix is completely reduced.
Now, we calculate the cost of node-2.
Cost(2)
=Cost(1) + Sum of reduction elements + M[A,B]
=18 + (13 + 5) +0
=36
Choosing To Go To Vertex-C: Node-3 (Path A  C)
 From the reduced matrix of step-01,M[A,C]=7
 Set row-A and column-C to ∞.
 Set M[C,A] = ∞.
Cont;
Now, resulting cost matrix is-
Now,
• We reduce this matrix.
• Then, we find out the cost of node-03.
Cont;
Row Reduction-
 We can not reduce row-1 as all its elements are ∞.
 There is no need to reduce row-2.
 There is no need to reduce row-3.
 There is no need to reduce row-4.
Thus, the matrix is already row-reduced.
Column Reduction-
 There is no need to reduce column-1.
 There is no need to reduce column-2.
 We can not reduce column-3 as all its elements are ∞.
 There is no need to reduce column-4.
Thus, the matrix is already column-reduced.
Cont;
Finally, the matrix is completely reduced.
Now, we calculate the cost of node-3.
Cost(3)
=Cost(1) + Sum of reduction elements + M[A,C]
=18 + 0 + 7
=25
Choosing To Go To Vertex-D: Node-4 (Path A  D)
• From the reduced matrix of step-01,M[A,D] = 3
• Set row-A and column-D to ∞.
• Set M[D,A] = ∞.
Cont;
Now, resulting cost matrix is-
Now,
 We reduce this matrix.
 Then, we find out the cost of node-04.
Cont;
Row Reduction-
• We can not reduce row-1 as all its elements are ∞.
• There is no need to reduce row-2.
• Reduce all the elements of row-3 by 5.
• There is no need to reduce row-4.
Performing this, we obtain the following row-reduced matrix-
Cont;
Column Reduction-
• There is no need to reduce column-1.
• There is no need to reduce column-2.
• There is no need to reduce column-3.
• We can not reduce column-4 as all its elements are ∞.
Thus, the matrix is already column-reduced.
Finally, the matrix is completely reduced.
Now, we calculate the cost of node-4.
Cost(4)
=Cost(1) + Sum of reduction elements + M[A,D]
=18 + 5 + 3
=26
Cont;
Thus, we have-
 Cost (2) = 36 (for path A  B)
 Cost (3) = 25 (for path A  C)
 Cost (4) = 26 (for path A  D)
We choose the node with the lowest cost.
Since cost for node-3 is lowest, so we prefer to visit node-3.
Thus, we choose node-3 i.e, path A  C
Cont;
Step-03:
We explore the vertices B and D from node-3.
We now start from the cost matrix at node-3 which is-
Cost(3) = 25
Cont;
Choosing To Go To Vertex-B: Node-5 (Path A  C  B)
• From the reduce matrix of step-02,M[C,B] = ∞.
• Set row-C and column-B to ∞.
• Set M[B,A] = ∞.
Now, resulting cost matrix is-
Cont;
Now,
 We reduce this matrix.
 Then, we find out the cost of node-5.
Row Reduction:
• We can not reduce row-1 as all its elements are ∞.
• Reduce all the elements of row-2 by 13.
• We can not reduce row-3 as all its elements are ∞.
• Reduce all the elements of row-4 by 8.
Cont;
Performing this, we obtain the following row-reduced matrix-
Column Reduction:
• There is no need to reduce column-1.
• We can not reduce column-2 as all its elements are ∞.
• We can not reduce column-3 as all its elements are ∞.
Cont;
• There is no need to reduce column-4.
Thus, the matrix is already column reduced.
Finally, the matrix is completely reduced.
Now, we calculate the cost of node-5.
Cost(5)
=cost(3) + Sum of reduction elements + M[C,B]
=25 + (13 + 8) + ∞
= ∞.
Cont;
Choosing To Go To Vertex-D: Node-6 (Path A  C  D)
• From the reduced matrix of step-02,M[C,D] = ∞.
• Set row-C and column-D to ∞.
• Set M[D,A] = ∞.
Now, resulting cost matrix is-
Cont;
Now,
 We reduce this matrix.
 Then, we find out the cost of node-6.
Row Reduction:
• We can not reduce row-1 as all its elements are ∞.
• There is no need to reduce row-2.
• We can not reduce row-3 as all its elements are ∞.
• We can not reduce row-4 as all its elements are ∞.
Thus, the matrix is already row reduced.
Cont;
Column Reduction:
• There is no need to reduce column-1.
• We can not reduce column-2 as all its elements are ∞.
• We can not reduce column-3 as all its elements are ∞.
• We can not reduce column-4 as all its elements are ∞.
Thus, the matrix is already column reduced.
Finally, the matrix is completely reduced.
Now, we calculate the cost of node-6.
Cont;
Cos(6)
=cost(3) + Sum of reduction elements + M[C,D]
=25 + 0 + 0
=25
Thus, we have-
 Cost(5) = ∞ (for path A  C  B)
 Cost(6) = 25 (for path A  C  D)
We choose the node with the lowest cost.
Since cost for node-6 is lowest, so we prefer to visit node-6.
Thus, we choose node-6 i.e, path C  D
Cont;
Step-04:
We explore vertex B from node-6.
We start will the cost matrix at node-6 which is-
Cost(6) = 25
Cont;
Choosing To Go To Vertex-B: Node-7 (Path A  C  D  B)
• From the reduced matrix of step-03, M[D,B] = 0.
• Set row-D and column-B to ∞.
• Set M[B,A] = ∞.
Now, resulting cost matrix is-
Cont;
Now,
 We reduce the matrix.
 Then, we find out the cost of node-7.
Row Reduction:
• We can not reduce row reduce row-1 as all its elements are ∞.
• We can not reduce row reduce row-2 as all its elements are ∞.
• We can not reduce row reduce row-3 as all its elements are ∞.
• We can not reduce row reduce row-4 as all its elements are ∞.
Cont;
Column Reduction:
• We can not reduce column-1 as all its elements are ∞.
• We can not reduce column-2 as all its elements are ∞.
• We can not reduce column-3 as all its elements are ∞.
• We can not reduce column-4 as all its elements are ∞.
Thus, the matrix is already column reduce.
Finally, the matrix is completely reduced.
All the entries have become ∞.
Cont;
Now, we calculate the cost node-7
Cost(7)
=cost(6) + Sum of reduction elements + M[D,B]
=25 + 0 + 0
=25
Thus,
 Optimal path is: A C  D  B  A
 Cost of Optimal path is = 25 units.
EFFICIENCY
CONSIDERATIONS
EFFICIENCY CONSIDERATION:
 When doing branch and bound, efficiency considerations usually
demand that a priority queue be used to hold the nodes that have
been generated but not yet processed.
 The heap is often an ideal structure for implementing a large priority
queue.
 Branch and bound algorithms may be less than straightforward to
program. Also, it may not be tractable to calculate precise estimates of
the big -0 or big -0 of a branch and bound algorithm.
 Nevertheless, branch and bound techniques are well worth
considering and using in many applications, because they have the
potential to greatly reduce the amount of work involved in computing.
 A good bounding function is one that can be calculated quickly and
which has a high probability of diverting the search toward the
better solutions.
 It is something of an “art” to design a good bounding function.
Sometimes it requires considerable expertise. Consider the problem
of evaluating the worth of a board position in the game of chess, or of
evaluating the standing of a nation in the world’s economy.
Data structures and algorithms

More Related Content

What's hot

Bezeir curve na B spline Curve
Bezeir curve na B spline CurveBezeir curve na B spline Curve
Bezeir curve na B spline CurvePooja Dixit
 
Unit 2A Powerpoint
Unit 2A PowerpointUnit 2A Powerpoint
Unit 2A Powerpointptschep
 
Curve modeling bezier curves
Curve modeling bezier curvesCurve modeling bezier curves
Curve modeling bezier curvesjhansi1986
 
Bezier and Spline Curves and Surfaces
Bezier and Spline Curves and SurfacesBezier and Spline Curves and Surfaces
Bezier and Spline Curves and SurfacesSyed Zaid Irshad
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesOmprakash Chauhan
 
2.4 Linear Functions
2.4 Linear Functions2.4 Linear Functions
2.4 Linear Functionssmiller5
 
Transporataion method north waste corner
Transporataion method north waste cornerTransporataion method north waste corner
Transporataion method north waste cornerSmitaSonawane7
 
All pair shortest path
All pair shortest pathAll pair shortest path
All pair shortest pathArafat Hossan
 
Parametric equations
Parametric equationsParametric equations
Parametric equationsTarun Gehlot
 
11.4 slope intercept form of a linear equation
11.4 slope intercept form of a linear equation11.4 slope intercept form of a linear equation
11.4 slope intercept form of a linear equationGlenSchlee
 
Time series analysis 101
Time series analysis 101Time series analysis 101
Time series analysis 101Balvinder Hira
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsKetan Jani
 
Standard form solve equations
Standard form solve equationsStandard form solve equations
Standard form solve equationspfefferteacher
 
Hermite spline english_20161201_jintaeks
Hermite spline english_20161201_jintaeksHermite spline english_20161201_jintaeks
Hermite spline english_20161201_jintaeksJinTaek Seo
 
Algebra 1 Lesson Plan
Algebra 1 Lesson PlanAlgebra 1 Lesson Plan
Algebra 1 Lesson Planthoma3ca
 
Warehouse layout design
Warehouse layout designWarehouse layout design
Warehouse layout designchetan mitta
 
Bezier curve
Bezier curveBezier curve
Bezier curveamiyadash
 
Linear Functions
Linear FunctionsLinear Functions
Linear Functionskliegey524
 

What's hot (20)

Bezeir curve na B spline Curve
Bezeir curve na B spline CurveBezeir curve na B spline Curve
Bezeir curve na B spline Curve
 
Unit 2A Powerpoint
Unit 2A PowerpointUnit 2A Powerpoint
Unit 2A Powerpoint
 
Curve modeling bezier curves
Curve modeling bezier curvesCurve modeling bezier curves
Curve modeling bezier curves
 
Bezier and Spline Curves and Surfaces
Bezier and Spline Curves and SurfacesBezier and Spline Curves and Surfaces
Bezier and Spline Curves and Surfaces
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 
2.4 Linear Functions
2.4 Linear Functions2.4 Linear Functions
2.4 Linear Functions
 
Transporataion method north waste corner
Transporataion method north waste cornerTransporataion method north waste corner
Transporataion method north waste corner
 
All pair shortest path
All pair shortest pathAll pair shortest path
All pair shortest path
 
Parametric equations
Parametric equationsParametric equations
Parametric equations
 
Assignment problem
Assignment problemAssignment problem
Assignment problem
 
11.4 slope intercept form of a linear equation
11.4 slope intercept form of a linear equation11.4 slope intercept form of a linear equation
11.4 slope intercept form of a linear equation
 
Cochino’s math
Cochino’s mathCochino’s math
Cochino’s math
 
Time series analysis 101
Time series analysis 101Time series analysis 101
Time series analysis 101
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Standard form solve equations
Standard form solve equationsStandard form solve equations
Standard form solve equations
 
Hermite spline english_20161201_jintaeks
Hermite spline english_20161201_jintaeksHermite spline english_20161201_jintaeks
Hermite spline english_20161201_jintaeks
 
Algebra 1 Lesson Plan
Algebra 1 Lesson PlanAlgebra 1 Lesson Plan
Algebra 1 Lesson Plan
 
Warehouse layout design
Warehouse layout designWarehouse layout design
Warehouse layout design
 
Bezier curve
Bezier curveBezier curve
Bezier curve
 
Linear Functions
Linear FunctionsLinear Functions
Linear Functions
 

Similar to Data structures and algorithms

travelingsalesmanproblem-170122053648.pdf
travelingsalesmanproblem-170122053648.pdftravelingsalesmanproblem-170122053648.pdf
travelingsalesmanproblem-170122053648.pdfmounikanarra3
 
Traveling salesman problem
Traveling salesman problemTraveling salesman problem
Traveling salesman problemJayesh Chauhan
 
Data structure - traveling sales person and mesh algorithm
Data structure - traveling sales person and mesh algorithmData structure - traveling sales person and mesh algorithm
Data structure - traveling sales person and mesh algorithmlavanya marichamy
 
Decision Science.pdf
Decision Science.pdfDecision Science.pdf
Decision Science.pdfpandeyaman577
 
Matrices ,Basics, Determinant, Inverse, EigenValues, Linear Equations, RANK
Matrices ,Basics, Determinant, Inverse, EigenValues, Linear Equations, RANKMatrices ,Basics, Determinant, Inverse, EigenValues, Linear Equations, RANK
Matrices ,Basics, Determinant, Inverse, EigenValues, Linear Equations, RANKWaqas Afzal
 
Hungarian Assignment Problem
Hungarian Assignment ProblemHungarian Assignment Problem
Hungarian Assignment ProblemVivekSaurabh7
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functionsjoellivz
 
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxCSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxmydrynan
 
matrix algebra
matrix algebramatrix algebra
matrix algebrakganu
 
Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Randa Elanwar
 
Simplex Algorithm
Simplex AlgorithmSimplex Algorithm
Simplex AlgorithmAizaz Ahmad
 

Similar to Data structures and algorithms (20)

travelingsalesmanproblem-170122053648.pdf
travelingsalesmanproblem-170122053648.pdftravelingsalesmanproblem-170122053648.pdf
travelingsalesmanproblem-170122053648.pdf
 
Traveling salesman problem
Traveling salesman problemTraveling salesman problem
Traveling salesman problem
 
Branch and bound
Branch and boundBranch and bound
Branch and bound
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Simplex method
Simplex methodSimplex method
Simplex method
 
Assignment problem
Assignment problemAssignment problem
Assignment problem
 
Data structure - traveling sales person and mesh algorithm
Data structure - traveling sales person and mesh algorithmData structure - traveling sales person and mesh algorithm
Data structure - traveling sales person and mesh algorithm
 
Asssignment problem
Asssignment problemAsssignment problem
Asssignment problem
 
Decision Science.pdf
Decision Science.pdfDecision Science.pdf
Decision Science.pdf
 
Lec20
Lec20Lec20
Lec20
 
Matrices ,Basics, Determinant, Inverse, EigenValues, Linear Equations, RANK
Matrices ,Basics, Determinant, Inverse, EigenValues, Linear Equations, RANKMatrices ,Basics, Determinant, Inverse, EigenValues, Linear Equations, RANK
Matrices ,Basics, Determinant, Inverse, EigenValues, Linear Equations, RANK
 
Simplex algorithm
Simplex algorithmSimplex algorithm
Simplex algorithm
 
Hungarian Assignment Problem
Hungarian Assignment ProblemHungarian Assignment Problem
Hungarian Assignment Problem
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functions
 
cs 3351 dpco
cs 3351 dpcocs 3351 dpco
cs 3351 dpco
 
MATLAB - Arrays and Matrices
MATLAB - Arrays and MatricesMATLAB - Arrays and Matrices
MATLAB - Arrays and Matrices
 
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxCSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
 
matrix algebra
matrix algebramatrix algebra
matrix algebra
 
Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4
 
Simplex Algorithm
Simplex AlgorithmSimplex Algorithm
Simplex Algorithm
 

More from Kaviya452563

softcomputing.pptx
softcomputing.pptxsoftcomputing.pptx
softcomputing.pptxKaviya452563
 
Big Data Analytics.pptx
Big Data Analytics.pptxBig Data Analytics.pptx
Big Data Analytics.pptxKaviya452563
 
client server computing.pptx
client server computing.pptxclient server computing.pptx
client server computing.pptxKaviya452563
 
Internet of Things.pptx
Internet of Things.pptxInternet of Things.pptx
Internet of Things.pptxKaviya452563
 
python programming.pptx
python programming.pptxpython programming.pptx
python programming.pptxKaviya452563
 
Distributing computing.pptx
Distributing computing.pptxDistributing computing.pptx
Distributing computing.pptxKaviya452563
 
Artificial Intelligence.pptx
Artificial Intelligence.pptxArtificial Intelligence.pptx
Artificial Intelligence.pptxKaviya452563
 
Advanced java programming
Advanced java programmingAdvanced java programming
Advanced java programmingKaviya452563
 
Network and internet security
Network and internet securityNetwork and internet security
Network and internet securityKaviya452563
 
Advanced computer architecture
Advanced computer architectureAdvanced computer architecture
Advanced computer architectureKaviya452563
 

More from Kaviya452563 (14)

softcomputing.pptx
softcomputing.pptxsoftcomputing.pptx
softcomputing.pptx
 
OOAD.pptx
OOAD.pptxOOAD.pptx
OOAD.pptx
 
DIP.pptx
DIP.pptxDIP.pptx
DIP.pptx
 
Big Data Analytics.pptx
Big Data Analytics.pptxBig Data Analytics.pptx
Big Data Analytics.pptx
 
client server computing.pptx
client server computing.pptxclient server computing.pptx
client server computing.pptx
 
WE.pptx
WE.pptxWE.pptx
WE.pptx
 
Internet of Things.pptx
Internet of Things.pptxInternet of Things.pptx
Internet of Things.pptx
 
data mining.pptx
data mining.pptxdata mining.pptx
data mining.pptx
 
python programming.pptx
python programming.pptxpython programming.pptx
python programming.pptx
 
Distributing computing.pptx
Distributing computing.pptxDistributing computing.pptx
Distributing computing.pptx
 
Artificial Intelligence.pptx
Artificial Intelligence.pptxArtificial Intelligence.pptx
Artificial Intelligence.pptx
 
Advanced java programming
Advanced java programmingAdvanced java programming
Advanced java programming
 
Network and internet security
Network and internet securityNetwork and internet security
Network and internet security
 
Advanced computer architecture
Advanced computer architectureAdvanced computer architecture
Advanced computer architecture
 

Recently uploaded

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 

Recently uploaded (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 

Data structures and algorithms

  • 1. Nadar saraswathi college of arts & science,theni. Department of cs & it data structures and algorithms PRESENTED BY G.KAVIYA M.SC(IT) TOPIC:TRAVELLING SALESMAN PROBLEM.
  • 3. Travelling Salesman Problem using Branch and Bound Travelling salesman problem:  A set of some cities.  Distance between every pair of cities. Travelling salesman problem states-  A salesman has to visit every city exactly once.  He has to come back to the city from where he starts his journey.  What is the shortest possible route that the salesman must follow to complete his tour?
  • 4. EXAMPLE: The following graph shows a set of cities and distances between every pair of cities- If salesman starting city is A, then a TSP tour in the given is- A  B  D  C  A Cost of the tour = 10 + 25 + 30 + 15 =80 units.
  • 5. PRACTICE PROBLEM BASED ON TRAVELLING SALESMAN PROBLEM USING BRANCH AND BOUND APPROACH- Problem- Solve Travelling Salesman Problem using Branch and Bound Algorithm in the following graph-
  • 6. Solution- Step-01: Write the initial cost matrix and reduce it- Row Reduction- Consider the rows of above matrix one by one. If the row already contains an entry ‘0’, then-  There is no need to reduce that row.
  • 7. If the row does not contains an entry ‘0’, then-  Reduce that particular row.  Select the least value element from that row.  Subtract that element from each element of that row.  This will create an entry ‘0’ in the row, thus reducing that row. Following this, we have- • Reduce the elements of row-1 by 4. • Reduce the elements of row-2 by 5. • Reduce the elements of row-3 by 6. • Reduce the elements of row-4 by 2. Cont;
  • 8. Cont; Performing this, we obtain the following row-reduced matrix- Column Reduction- Consider the columns of above row-reduced matrix one by one. If the contains already contains an entry ‘0’, then-  There is no need to reduce that column.
  • 9. Cont; If the column does not contains an entry ’0’, then-  Reduce that particular column.  Select the least value element from that column.  Subtract that element from each element of that column.  This will create an entry ‘0’ in the row, thus reducing that column. Following this, we have- • There is no need to reduce column-1. • There is no need to reduce column-2. • Reduce the elements of column-3 by -1. • There is no need to reduce column-4.
  • 10. Cont; Performing this, we obtain the following column-reduced matrix- Finally, the initial distance matrix is completely reduced. Now, we calculate the cost of node-1 by adding all the reduction elements. Cost(1) =sum of all reduction elements =4 + 5 + 6 + 2 + 1 =18
  • 11. Cont; Step-02: o We consider all other vertices one by one. o We select the best vertex where we can land upon to minimize the tour cost. Choosing To Go To Vertex-B: Node-2(Path A  B) • From the reduced matrix of step-1, M[A,B] = 0 • Set row-A and column-B to ∞ • Set M[B,A] = ∞
  • 12. Cont; Now, resulting cost matrix is- Now, • We reduce this matrix. • Then, we find out the cost of node-02.
  • 13. Cont; Row Reduction-  We can not reduce row-1 as all its elements are ∞.  Reduce all the elements of row-2 by 13.  There is no need to reduce row-3.  There is no need to reduce row-4. Performing this, we obtain the following row-reduced matrix-
  • 14. Cont; Column Reduction-  Reduction the elements of column-1 by -5.  We can not reduce column-2 as all its elements are ∞.  There is no need to reduce column-3.  There is no need to reduce column-4. Performing this, we obtain the following column-reduced matrix-
  • 15. Cont; Finally, the matrix is completely reduced. Now, we calculate the cost of node-2. Cost(2) =Cost(1) + Sum of reduction elements + M[A,B] =18 + (13 + 5) +0 =36 Choosing To Go To Vertex-C: Node-3 (Path A  C)  From the reduced matrix of step-01,M[A,C]=7  Set row-A and column-C to ∞.  Set M[C,A] = ∞.
  • 16. Cont; Now, resulting cost matrix is- Now, • We reduce this matrix. • Then, we find out the cost of node-03.
  • 17. Cont; Row Reduction-  We can not reduce row-1 as all its elements are ∞.  There is no need to reduce row-2.  There is no need to reduce row-3.  There is no need to reduce row-4. Thus, the matrix is already row-reduced. Column Reduction-  There is no need to reduce column-1.  There is no need to reduce column-2.  We can not reduce column-3 as all its elements are ∞.  There is no need to reduce column-4. Thus, the matrix is already column-reduced.
  • 18. Cont; Finally, the matrix is completely reduced. Now, we calculate the cost of node-3. Cost(3) =Cost(1) + Sum of reduction elements + M[A,C] =18 + 0 + 7 =25 Choosing To Go To Vertex-D: Node-4 (Path A  D) • From the reduced matrix of step-01,M[A,D] = 3 • Set row-A and column-D to ∞. • Set M[D,A] = ∞.
  • 19. Cont; Now, resulting cost matrix is- Now,  We reduce this matrix.  Then, we find out the cost of node-04.
  • 20. Cont; Row Reduction- • We can not reduce row-1 as all its elements are ∞. • There is no need to reduce row-2. • Reduce all the elements of row-3 by 5. • There is no need to reduce row-4. Performing this, we obtain the following row-reduced matrix-
  • 21. Cont; Column Reduction- • There is no need to reduce column-1. • There is no need to reduce column-2. • There is no need to reduce column-3. • We can not reduce column-4 as all its elements are ∞. Thus, the matrix is already column-reduced. Finally, the matrix is completely reduced. Now, we calculate the cost of node-4. Cost(4) =Cost(1) + Sum of reduction elements + M[A,D] =18 + 5 + 3 =26
  • 22. Cont; Thus, we have-  Cost (2) = 36 (for path A  B)  Cost (3) = 25 (for path A  C)  Cost (4) = 26 (for path A  D) We choose the node with the lowest cost. Since cost for node-3 is lowest, so we prefer to visit node-3. Thus, we choose node-3 i.e, path A  C
  • 23. Cont; Step-03: We explore the vertices B and D from node-3. We now start from the cost matrix at node-3 which is- Cost(3) = 25
  • 24. Cont; Choosing To Go To Vertex-B: Node-5 (Path A  C  B) • From the reduce matrix of step-02,M[C,B] = ∞. • Set row-C and column-B to ∞. • Set M[B,A] = ∞. Now, resulting cost matrix is-
  • 25. Cont; Now,  We reduce this matrix.  Then, we find out the cost of node-5. Row Reduction: • We can not reduce row-1 as all its elements are ∞. • Reduce all the elements of row-2 by 13. • We can not reduce row-3 as all its elements are ∞. • Reduce all the elements of row-4 by 8.
  • 26. Cont; Performing this, we obtain the following row-reduced matrix- Column Reduction: • There is no need to reduce column-1. • We can not reduce column-2 as all its elements are ∞. • We can not reduce column-3 as all its elements are ∞.
  • 27. Cont; • There is no need to reduce column-4. Thus, the matrix is already column reduced. Finally, the matrix is completely reduced. Now, we calculate the cost of node-5. Cost(5) =cost(3) + Sum of reduction elements + M[C,B] =25 + (13 + 8) + ∞ = ∞.
  • 28. Cont; Choosing To Go To Vertex-D: Node-6 (Path A  C  D) • From the reduced matrix of step-02,M[C,D] = ∞. • Set row-C and column-D to ∞. • Set M[D,A] = ∞. Now, resulting cost matrix is-
  • 29. Cont; Now,  We reduce this matrix.  Then, we find out the cost of node-6. Row Reduction: • We can not reduce row-1 as all its elements are ∞. • There is no need to reduce row-2. • We can not reduce row-3 as all its elements are ∞. • We can not reduce row-4 as all its elements are ∞. Thus, the matrix is already row reduced.
  • 30. Cont; Column Reduction: • There is no need to reduce column-1. • We can not reduce column-2 as all its elements are ∞. • We can not reduce column-3 as all its elements are ∞. • We can not reduce column-4 as all its elements are ∞. Thus, the matrix is already column reduced. Finally, the matrix is completely reduced. Now, we calculate the cost of node-6.
  • 31. Cont; Cos(6) =cost(3) + Sum of reduction elements + M[C,D] =25 + 0 + 0 =25 Thus, we have-  Cost(5) = ∞ (for path A  C  B)  Cost(6) = 25 (for path A  C  D) We choose the node with the lowest cost. Since cost for node-6 is lowest, so we prefer to visit node-6. Thus, we choose node-6 i.e, path C  D
  • 32. Cont; Step-04: We explore vertex B from node-6. We start will the cost matrix at node-6 which is- Cost(6) = 25
  • 33. Cont; Choosing To Go To Vertex-B: Node-7 (Path A  C  D  B) • From the reduced matrix of step-03, M[D,B] = 0. • Set row-D and column-B to ∞. • Set M[B,A] = ∞. Now, resulting cost matrix is-
  • 34. Cont; Now,  We reduce the matrix.  Then, we find out the cost of node-7. Row Reduction: • We can not reduce row reduce row-1 as all its elements are ∞. • We can not reduce row reduce row-2 as all its elements are ∞. • We can not reduce row reduce row-3 as all its elements are ∞. • We can not reduce row reduce row-4 as all its elements are ∞.
  • 35. Cont; Column Reduction: • We can not reduce column-1 as all its elements are ∞. • We can not reduce column-2 as all its elements are ∞. • We can not reduce column-3 as all its elements are ∞. • We can not reduce column-4 as all its elements are ∞. Thus, the matrix is already column reduce. Finally, the matrix is completely reduced. All the entries have become ∞.
  • 36. Cont; Now, we calculate the cost node-7 Cost(7) =cost(6) + Sum of reduction elements + M[D,B] =25 + 0 + 0 =25 Thus,  Optimal path is: A C  D  B  A  Cost of Optimal path is = 25 units.
  • 38. EFFICIENCY CONSIDERATION:  When doing branch and bound, efficiency considerations usually demand that a priority queue be used to hold the nodes that have been generated but not yet processed.  The heap is often an ideal structure for implementing a large priority queue.  Branch and bound algorithms may be less than straightforward to program. Also, it may not be tractable to calculate precise estimates of the big -0 or big -0 of a branch and bound algorithm.  Nevertheless, branch and bound techniques are well worth considering and using in many applications, because they have the potential to greatly reduce the amount of work involved in computing.
  • 39.  A good bounding function is one that can be calculated quickly and which has a high probability of diverting the search toward the better solutions.  It is something of an “art” to design a good bounding function. Sometimes it requires considerable expertise. Consider the problem of evaluating the worth of a board position in the game of chess, or of evaluating the standing of a nation in the world’s economy.