SlideShare a Scribd company logo
1 of 30
Heuristic algorithms
for solving TSP
——Ant algorithms
LUO 、ZHANG
CONTENTS
0
1
Limitations of classical algorithms
Ant colony algorithm
Comparative experiment
Conclusion
0
2
0
3
0
4
01 Limitations of classical algorithms
Classical algorithms
Exact algorithms for solving TSP
Brute Force
 Method: try all possible
permutations of the city,
calculate the total distance
travelled for each combination,
and then choose the shortest
path.
 Time complexity: O(n!),
where n is the number of cities.
This is because it is necessary
to iterate through all possible
city permutations.
 Applicability: only works for
very small problem instances
(e.g. n<10).
Dynamic Programming
 Method: The core of the algorithm is
to recursively calculate the shortest
path from each subset to a certain
point, and finally get the shortest path
of the whole set.
 Time complexity: O(n2*2n), where n
is the number of cities. Although an
improvement over the violent
method, the time complexity is still
exponential, limiting its application to
medium- to large-scale problems.
 Applicability: suitable for medium-
sized problem instances (e.g., n < 20).
Branch and Bound
 Method: A tree structure is used to
systematically enumerate all
possible solutions, and the number
of paths to be explored is reduced
by bounding and pruning.
 Time complexity: O(n!) in the worst
case, but may be lower than this in
practice, as the number of paths to
be considered is massively reduced
by pruning.
 Applicability: can be applied to
medium-sized problems, and the
actual performance depends on the
effectiveness of the bounding and
pruning strategies. (Experienced)
Integer linear programming(ILP)
 
ij ij
ij trips
dist
min
This method utilizes the cut-plane method of integer
programming, which involves solving a linear program
formed by the two constraints in the model, and then solving
for the cut-plane by adding inequality constraints that
gradually converge to the optimal solution. People applying
this method to find the cutting plane often rely on
experience, so this method is rarely used as a generalized
method.
So, in the last semester's question on tsp containing 200
U.S. cities. The cut plane in question, i.e., a linear
inequality that can exclude current illegal solutions (e.g.,
those containing subloops) without excluding any
possible integer solutions. We got the relevant tangent
plane settings from the matlab website, otherwise we
would not have been able to set the tangent plane by
ourselves
02 Ant colony algorithm
The ants are able to leave pheromones on the paths it passes through during its movement, and the
ants are able to sense the presence and strength of pheromones and use them to guide the direction
of their movement, the ants tend to move in the direction of high pheromone strength.The ants tend
to move in the direction of high pheromone strength.
The collective behavior of a large number of ants in a colony shows a positive feedback
phenomenon: the more ants that pass on a certain path, the higher the probability that later ants will
choose that path. It is through this exchange of information that individual ants search for food.This
exchange of information between individual ants leads to the fastest search for food.
heuristic algorithm
Ant colony algorithm
Ant colony algorithm
positive feedback effect
Assuming that the pheromone left behind by the ants at
each point they pass through is one unit, then after 36
time units, all the ants that started to leave together
obtained food from point D through different paths. At
this time, the route of ABD made 2 round trips, and the
pheromone of each place was 4 units, and the ants of the
route of ACD returned only once, and the pheromone of
each place was 2 units, and the ratio was 2:1.
The search for food continues, and as guided by the pheromone, the colony sends additional ants on the
ABD route. The pheromone gap between the two routes will get bigger and bigger and eventually all
the ants will abandon the ACD route!
Ant colony algorithm
Ant colony foraging Ant colony algorithm
ant colony
foraging space
pheromone
A path from the nest to the food
Shortest path found
A set of valid solutions in the search space
(expressed as a population size N)
The search space of the problem (expressed as
dimension D)
Pheromone concentration variables
An effective solution
Optimal solution of the problem
Ant colony algorithm
The ACO algorithm for solving TSP has two main steps: path construction and
pheromone updating
1. Path construction
Each ant randomly selects a city as its starting city and maintains a path memory
vector to hold the cities that the ant passes through sequentially.
At each step of the path construction, the ant chooses the next city to be reached
according to a randomized proportionality rule.
Ant colony algorithm
 Randomized proportionality rules
For each ant k, the path memory vector Rk, records the serial numbers of all the cities that k has passed through
in the order of visit. Let the current city of ant k be i,then the probability that it chooses city j as its next visit is
the above rule.
where allowedk is the set of nodes that have not been visited yet; α,β are two constants, weighted by
pheromone and visibility, respectively
:visibility
:pheromone intensity
(inverse of distance)
Ant colony algorithm
2.Pheromone updating
Pheromone updating is at the heart of the ant algorithm. The algorithm has a fixed concentration value
during the initial period, and after each iteration is completed, all the ants that go out and come back
will calculate the routes they have traveled, and then update the pheromone concentration of the
corresponding edges.
Obviously, this value must be related to the length of the ants traveled, and after one iteration, the
concentration will be high for close routes, thus obtaining a near-optimal solution.
Initialize the pheromone concentration C(0), if it is too small, the algorithm is easy to precocious, the
ants will quickly concentrate on a locally optimal path,; if C is too large, the guiding effect of the
pheromone on the search direction is reduced, affecting the algorithm performance.
In general, we can use the greedy algorithm to obtain a path value Cnn, and then according to the
number of ants to calculate C(0) = m/Cnn ,m is the number of ants
Ant colony algorithm
To simulate ants leaving more pheromone on shorter paths, when all ants reach the end point, the
pheromone concentration of each path must be re-updated once, and the pheromone updating is also
divided into two steps.The updating of pheromone is also divided into two steps:
 First, after each round, the pheromone on all paths in the problem space evaporates.
 Then, all ants release pheromone on the edges they pass through this round according to
the length of the paths they constructed.
In the formula, m is the number of ants, 0 < ρ ≤ 1 is the pheromone evaporation rate,
which is usually set to 0.5 in the algorithm, and Δτk
ij is the pheromone left behind by the
kth ant in the path i to j
Ant colony algorithm
 Definition of
Ck is the total path length obtained after the kth ant has traveled the whole path
Ant colony algorithm
The ants search for paths
in the graph and
pheromones are used to
guide the search process,
the pheromones evaporate
over time and are updated
based on the quality of the
paths found by the ants.
This continuous process
allows the algorithm to
find solutions that are
close to the shortest
possible path.
Ant colony algorithm
Simple Application of ACO
The TSP problem for four cities, with the distance matrix and cities illustrated below:
Ant colony algorithm
Step 1 :Initialize pheromone
Assuming a total of m = 3 ants and the parameters α = 1, β = 2 and ρ = 0.5 (from
internet experience)
Firstly,we use the greedy algorithm to get the (ACDBA) of the path,
then Cnn = 1+2+4+3 = 10, and find τ0 =m/Cnn =0.3
Step 2:Randomly select a departure city for each ant, assuming that ant 1 selects
city A, ant 2 selects city B, and ant 3 selects city D.
Ant colony algorithm
Step 3.1: Select the next city to visit for each ant (ant 1 only)
Ant 1 is in the current city i=A and can visit the set of cities
J1(i)={B,C,D}, Calculate the probability that ant 1 visits each
city
Use roulette to select the next city to visit. We get that ant 1 will choose city B.
Similarly, suppose Ant 2 chooses city D and Ant 3 chooses city A.
Ant colony algorithm
Step 3.2: Select the next city to visit for each ant (ant 1 only)
Ant 1 is in the current city i=B ,The path memory vector
Rl=(AB), and the ant 1 can visit the set of cities J1(i)={C,D},
Calculate the probability that ant 1 visits cities C,D:
Use roulette to select the next city to visit. We get that ant 1 will choose city D.
Similarly, suppose Ant 2 chooses city C and Ant 3 chooses city D.
Ant colony algorithm
At this point, so the ants' paths have been constructed
Ant 1:A→B →D →C →A
Ant 2:B→D →C →A →B
Ant 3:D→A →C →B →D
Ant colony algorithm
Step 4: Pheromone updating
Calculate the length of the path constructed by each ant: C1=3+4+2+1=10;
C2=4+2+1+3=10; C3=2+1+5+4=12. updating the pheromone on each edge.
Step 5:
If the end condition is satisfied, output the globally optimal result and end the
program.
Otherwise, it turns to step 2 to continue execution.
03 Comparative experiment
First, I used the rand function to generate a 31*2 two-dimensional variable of type double in
the range [0,5000].That's 31 cities. Also 30 ants were set up with parameter variables α = 1, β
= 5 and ρ = 0.1.And find the globally optimal path and draw.
Also, I plotted a line graph of the change in shortest distance and average distance with
increasing number of iterations.
Programming
Programming
With the limit of 200 iterations, we can see that the algorithm finds a good solution at the 92nd
iteration, with the shortest distance being 15833.2 units of length. And the fluctuation of the average
distance after that indicates that the ants are still exploring new possible optimal solutions.
Comparative experiment
Particle Swarm Algorithms Genetic Algorithm
Comparative experiment
Ant colony algorithm (iterations extended to 2000)
The ACO algorithm stabilizes after
about 100 iterations, finding a better
path at 394 iterations. The shortest
distance of 15601.9 units of length
reached at this point (not much
different from the previous 15833.2)
remains almost unchanged for the
next 1500 iterations. In reality, we
just need to find a better solution in
as little time consumption (iterations)
as possible.
Compare this to the PSO and GA
algorithms, which both find a better
solution around 1000 iterations at
around 18500 unit lengths. Both are
inferior to ACO algorithm (in this
TSP problem)
04 Conclusion
Traditional :
 Accuracy: Traditional optimization methods, such as linear
programming and integer programming, can provide exact solutions,
which is necessary for application scenarios that require precise results.
 Computational complexity: for smaller problem instances, these
methods are usually feasible. However, TSP is NP-hard problem, which
means that an increase in problem size leads to an exponential increase
in solution time, making traditional methods impractical for large-scale
problems.
 Resource requirements: finding an exact solution often requires
significant computational resources, including time and memory,
especially when the problem size is large.
Traditional vs. Heuristics
 Efficiency: Heuristic methods, such as ant colony algorithms, genetic algorithms, and
particle swarm optimization algorithms, usually find good enough solutions in an
acceptable amount of time, especially for large-scale problems.
 Flexibility: these methods are well adapted to various variants of TSPs, and the
performance can be optimized by tuning the parameters.
 Quality of solutions: while heuristics may not be guaranteed to find an optimal
solution, they are often able to find very close to optimal solutions in practical
applications.
 Ease of implementation: Heuristics tend to be easier to implement and debug than
complex exact algorithms.(Less math)
 Scalability: Heuristic methods can be easily extended to other complex multi-
objective optimization problems, combinatorial optimization problems.
Traditional vs. Heuristics
Heuristics:
THANK_YOU
—— LUO 、ZHANG

More Related Content

Similar to Heuristic algorithms for solving TSP.doc.pptx

Ant colony optimization
Ant colony optimizationAnt colony optimization
Ant colony optimizationMeenakshi Devi
 
An improved ant colony algorithm based on
An improved ant colony algorithm based onAn improved ant colony algorithm based on
An improved ant colony algorithm based onIJCI JOURNAL
 
Travelling and salesman problem using ant colony optimization
Travelling and salesman problem using ant colony optimizationTravelling and salesman problem using ant colony optimization
Travelling and salesman problem using ant colony optimizationAkash Sethiya
 
Ant Colony Algorithm
Ant Colony AlgorithmAnt Colony Algorithm
Ant Colony Algorithmguest4c60e4
 
Robot Three Dimensional Space Path-planning Applying the Improved Ant Colony ...
Robot Three Dimensional Space Path-planning Applying the Improved Ant Colony ...Robot Three Dimensional Space Path-planning Applying the Improved Ant Colony ...
Robot Three Dimensional Space Path-planning Applying the Improved Ant Colony ...Nooria Sukmaningtyas
 
Swarm Intelligence Technique ACO and Traveling Salesman Problem
Swarm Intelligence Technique ACO and Traveling Salesman ProblemSwarm Intelligence Technique ACO and Traveling Salesman Problem
Swarm Intelligence Technique ACO and Traveling Salesman ProblemIRJET Journal
 
53564379-Ant-Colony-Optimization.ppt
53564379-Ant-Colony-Optimization.ppt53564379-Ant-Colony-Optimization.ppt
53564379-Ant-Colony-Optimization.pptAhmedSalimJAlJawadi
 
Path Planning of Mobile aco fuzzy-presentation.pptx
Path Planning of Mobile aco fuzzy-presentation.pptxPath Planning of Mobile aco fuzzy-presentation.pptx
Path Planning of Mobile aco fuzzy-presentation.pptxssuserf6b378
 
Seminer-Merve AYDIN-4802220035-SUNUM.pptx
Seminer-Merve AYDIN-4802220035-SUNUM.pptxSeminer-Merve AYDIN-4802220035-SUNUM.pptx
Seminer-Merve AYDIN-4802220035-SUNUM.pptxssuserf6b378
 
Microscopic Image Analysis of Nanoparticles by Edge Detection Using Ant Colon...
Microscopic Image Analysis of Nanoparticles by Edge Detection Using Ant Colon...Microscopic Image Analysis of Nanoparticles by Edge Detection Using Ant Colon...
Microscopic Image Analysis of Nanoparticles by Edge Detection Using Ant Colon...IOSR Journals
 
A NOVEL ANT COLONY ALGORITHM FOR MULTICAST ROUTING IN WIRELESS AD HOC NETWORKS
A NOVEL ANT COLONY ALGORITHM FOR MULTICAST ROUTING IN WIRELESS AD HOC NETWORKS A NOVEL ANT COLONY ALGORITHM FOR MULTICAST ROUTING IN WIRELESS AD HOC NETWORKS
A NOVEL ANT COLONY ALGORITHM FOR MULTICAST ROUTING IN WIRELESS AD HOC NETWORKS cscpconf
 

Similar to Heuristic algorithms for solving TSP.doc.pptx (20)

Ant colony optimization
Ant colony optimizationAnt colony optimization
Ant colony optimization
 
An improved ant colony algorithm based on
An improved ant colony algorithm based onAn improved ant colony algorithm based on
An improved ant colony algorithm based on
 
Travelling and salesman problem using ant colony optimization
Travelling and salesman problem using ant colony optimizationTravelling and salesman problem using ant colony optimization
Travelling and salesman problem using ant colony optimization
 
aco-3a.ppt
aco-3a.pptaco-3a.ppt
aco-3a.ppt
 
aco-3a.ppt
aco-3a.pptaco-3a.ppt
aco-3a.ppt
 
aco-3a.ppt
aco-3a.pptaco-3a.ppt
aco-3a.ppt
 
Ant Colony Algorithm
Ant Colony AlgorithmAnt Colony Algorithm
Ant Colony Algorithm
 
Ant colony algorithm
Ant colony algorithm Ant colony algorithm
Ant colony algorithm
 
Robot Three Dimensional Space Path-planning Applying the Improved Ant Colony ...
Robot Three Dimensional Space Path-planning Applying the Improved Ant Colony ...Robot Three Dimensional Space Path-planning Applying the Improved Ant Colony ...
Robot Three Dimensional Space Path-planning Applying the Improved Ant Colony ...
 
Ant colony Optimization
Ant colony OptimizationAnt colony Optimization
Ant colony Optimization
 
ANT-presentation.ppt
ANT-presentation.pptANT-presentation.ppt
ANT-presentation.ppt
 
Swarm Intelligence Technique ACO and Traveling Salesman Problem
Swarm Intelligence Technique ACO and Traveling Salesman ProblemSwarm Intelligence Technique ACO and Traveling Salesman Problem
Swarm Intelligence Technique ACO and Traveling Salesman Problem
 
53564379-Ant-Colony-Optimization.ppt
53564379-Ant-Colony-Optimization.ppt53564379-Ant-Colony-Optimization.ppt
53564379-Ant-Colony-Optimization.ppt
 
Path Planning of Mobile aco fuzzy-presentation.pptx
Path Planning of Mobile aco fuzzy-presentation.pptxPath Planning of Mobile aco fuzzy-presentation.pptx
Path Planning of Mobile aco fuzzy-presentation.pptx
 
Seminer-Merve AYDIN-4802220035-SUNUM.pptx
Seminer-Merve AYDIN-4802220035-SUNUM.pptxSeminer-Merve AYDIN-4802220035-SUNUM.pptx
Seminer-Merve AYDIN-4802220035-SUNUM.pptx
 
K046036367
K046036367K046036367
K046036367
 
Microscopic Image Analysis of Nanoparticles by Edge Detection Using Ant Colon...
Microscopic Image Analysis of Nanoparticles by Edge Detection Using Ant Colon...Microscopic Image Analysis of Nanoparticles by Edge Detection Using Ant Colon...
Microscopic Image Analysis of Nanoparticles by Edge Detection Using Ant Colon...
 
A NOVEL ANT COLONY ALGORITHM FOR MULTICAST ROUTING IN WIRELESS AD HOC NETWORKS
A NOVEL ANT COLONY ALGORITHM FOR MULTICAST ROUTING IN WIRELESS AD HOC NETWORKS A NOVEL ANT COLONY ALGORITHM FOR MULTICAST ROUTING IN WIRELESS AD HOC NETWORKS
A NOVEL ANT COLONY ALGORITHM FOR MULTICAST ROUTING IN WIRELESS AD HOC NETWORKS
 
Ant colony optimization
Ant colony optimizationAnt colony optimization
Ant colony optimization
 
Final project
Final projectFinal project
Final project
 

Recently uploaded

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Heuristic algorithms for solving TSP.doc.pptx

  • 1. Heuristic algorithms for solving TSP ——Ant algorithms LUO 、ZHANG
  • 2. CONTENTS 0 1 Limitations of classical algorithms Ant colony algorithm Comparative experiment Conclusion 0 2 0 3 0 4
  • 3. 01 Limitations of classical algorithms
  • 4. Classical algorithms Exact algorithms for solving TSP Brute Force  Method: try all possible permutations of the city, calculate the total distance travelled for each combination, and then choose the shortest path.  Time complexity: O(n!), where n is the number of cities. This is because it is necessary to iterate through all possible city permutations.  Applicability: only works for very small problem instances (e.g. n<10). Dynamic Programming  Method: The core of the algorithm is to recursively calculate the shortest path from each subset to a certain point, and finally get the shortest path of the whole set.  Time complexity: O(n2*2n), where n is the number of cities. Although an improvement over the violent method, the time complexity is still exponential, limiting its application to medium- to large-scale problems.  Applicability: suitable for medium- sized problem instances (e.g., n < 20). Branch and Bound  Method: A tree structure is used to systematically enumerate all possible solutions, and the number of paths to be explored is reduced by bounding and pruning.  Time complexity: O(n!) in the worst case, but may be lower than this in practice, as the number of paths to be considered is massively reduced by pruning.  Applicability: can be applied to medium-sized problems, and the actual performance depends on the effectiveness of the bounding and pruning strategies. (Experienced)
  • 5. Integer linear programming(ILP)   ij ij ij trips dist min This method utilizes the cut-plane method of integer programming, which involves solving a linear program formed by the two constraints in the model, and then solving for the cut-plane by adding inequality constraints that gradually converge to the optimal solution. People applying this method to find the cutting plane often rely on experience, so this method is rarely used as a generalized method. So, in the last semester's question on tsp containing 200 U.S. cities. The cut plane in question, i.e., a linear inequality that can exclude current illegal solutions (e.g., those containing subloops) without excluding any possible integer solutions. We got the relevant tangent plane settings from the matlab website, otherwise we would not have been able to set the tangent plane by ourselves
  • 6. 02 Ant colony algorithm
  • 7. The ants are able to leave pheromones on the paths it passes through during its movement, and the ants are able to sense the presence and strength of pheromones and use them to guide the direction of their movement, the ants tend to move in the direction of high pheromone strength.The ants tend to move in the direction of high pheromone strength. The collective behavior of a large number of ants in a colony shows a positive feedback phenomenon: the more ants that pass on a certain path, the higher the probability that later ants will choose that path. It is through this exchange of information that individual ants search for food.This exchange of information between individual ants leads to the fastest search for food. heuristic algorithm Ant colony algorithm
  • 8. Ant colony algorithm positive feedback effect Assuming that the pheromone left behind by the ants at each point they pass through is one unit, then after 36 time units, all the ants that started to leave together obtained food from point D through different paths. At this time, the route of ABD made 2 round trips, and the pheromone of each place was 4 units, and the ants of the route of ACD returned only once, and the pheromone of each place was 2 units, and the ratio was 2:1. The search for food continues, and as guided by the pheromone, the colony sends additional ants on the ABD route. The pheromone gap between the two routes will get bigger and bigger and eventually all the ants will abandon the ACD route!
  • 9. Ant colony algorithm Ant colony foraging Ant colony algorithm ant colony foraging space pheromone A path from the nest to the food Shortest path found A set of valid solutions in the search space (expressed as a population size N) The search space of the problem (expressed as dimension D) Pheromone concentration variables An effective solution Optimal solution of the problem
  • 10. Ant colony algorithm The ACO algorithm for solving TSP has two main steps: path construction and pheromone updating 1. Path construction Each ant randomly selects a city as its starting city and maintains a path memory vector to hold the cities that the ant passes through sequentially. At each step of the path construction, the ant chooses the next city to be reached according to a randomized proportionality rule.
  • 11. Ant colony algorithm  Randomized proportionality rules For each ant k, the path memory vector Rk, records the serial numbers of all the cities that k has passed through in the order of visit. Let the current city of ant k be i,then the probability that it chooses city j as its next visit is the above rule. where allowedk is the set of nodes that have not been visited yet; α,β are two constants, weighted by pheromone and visibility, respectively :visibility :pheromone intensity (inverse of distance)
  • 12. Ant colony algorithm 2.Pheromone updating Pheromone updating is at the heart of the ant algorithm. The algorithm has a fixed concentration value during the initial period, and after each iteration is completed, all the ants that go out and come back will calculate the routes they have traveled, and then update the pheromone concentration of the corresponding edges. Obviously, this value must be related to the length of the ants traveled, and after one iteration, the concentration will be high for close routes, thus obtaining a near-optimal solution. Initialize the pheromone concentration C(0), if it is too small, the algorithm is easy to precocious, the ants will quickly concentrate on a locally optimal path,; if C is too large, the guiding effect of the pheromone on the search direction is reduced, affecting the algorithm performance. In general, we can use the greedy algorithm to obtain a path value Cnn, and then according to the number of ants to calculate C(0) = m/Cnn ,m is the number of ants
  • 13. Ant colony algorithm To simulate ants leaving more pheromone on shorter paths, when all ants reach the end point, the pheromone concentration of each path must be re-updated once, and the pheromone updating is also divided into two steps.The updating of pheromone is also divided into two steps:  First, after each round, the pheromone on all paths in the problem space evaporates.  Then, all ants release pheromone on the edges they pass through this round according to the length of the paths they constructed. In the formula, m is the number of ants, 0 < ρ ≤ 1 is the pheromone evaporation rate, which is usually set to 0.5 in the algorithm, and Δτk ij is the pheromone left behind by the kth ant in the path i to j
  • 14. Ant colony algorithm  Definition of Ck is the total path length obtained after the kth ant has traveled the whole path
  • 15. Ant colony algorithm The ants search for paths in the graph and pheromones are used to guide the search process, the pheromones evaporate over time and are updated based on the quality of the paths found by the ants. This continuous process allows the algorithm to find solutions that are close to the shortest possible path.
  • 16. Ant colony algorithm Simple Application of ACO The TSP problem for four cities, with the distance matrix and cities illustrated below:
  • 17. Ant colony algorithm Step 1 :Initialize pheromone Assuming a total of m = 3 ants and the parameters α = 1, β = 2 and ρ = 0.5 (from internet experience) Firstly,we use the greedy algorithm to get the (ACDBA) of the path, then Cnn = 1+2+4+3 = 10, and find τ0 =m/Cnn =0.3 Step 2:Randomly select a departure city for each ant, assuming that ant 1 selects city A, ant 2 selects city B, and ant 3 selects city D.
  • 18. Ant colony algorithm Step 3.1: Select the next city to visit for each ant (ant 1 only) Ant 1 is in the current city i=A and can visit the set of cities J1(i)={B,C,D}, Calculate the probability that ant 1 visits each city Use roulette to select the next city to visit. We get that ant 1 will choose city B. Similarly, suppose Ant 2 chooses city D and Ant 3 chooses city A.
  • 19. Ant colony algorithm Step 3.2: Select the next city to visit for each ant (ant 1 only) Ant 1 is in the current city i=B ,The path memory vector Rl=(AB), and the ant 1 can visit the set of cities J1(i)={C,D}, Calculate the probability that ant 1 visits cities C,D: Use roulette to select the next city to visit. We get that ant 1 will choose city D. Similarly, suppose Ant 2 chooses city C and Ant 3 chooses city D.
  • 20. Ant colony algorithm At this point, so the ants' paths have been constructed Ant 1:A→B →D →C →A Ant 2:B→D →C →A →B Ant 3:D→A →C →B →D
  • 21. Ant colony algorithm Step 4: Pheromone updating Calculate the length of the path constructed by each ant: C1=3+4+2+1=10; C2=4+2+1+3=10; C3=2+1+5+4=12. updating the pheromone on each edge. Step 5: If the end condition is satisfied, output the globally optimal result and end the program. Otherwise, it turns to step 2 to continue execution.
  • 23. First, I used the rand function to generate a 31*2 two-dimensional variable of type double in the range [0,5000].That's 31 cities. Also 30 ants were set up with parameter variables α = 1, β = 5 and ρ = 0.1.And find the globally optimal path and draw. Also, I plotted a line graph of the change in shortest distance and average distance with increasing number of iterations. Programming
  • 24. Programming With the limit of 200 iterations, we can see that the algorithm finds a good solution at the 92nd iteration, with the shortest distance being 15833.2 units of length. And the fluctuation of the average distance after that indicates that the ants are still exploring new possible optimal solutions.
  • 25. Comparative experiment Particle Swarm Algorithms Genetic Algorithm
  • 26. Comparative experiment Ant colony algorithm (iterations extended to 2000) The ACO algorithm stabilizes after about 100 iterations, finding a better path at 394 iterations. The shortest distance of 15601.9 units of length reached at this point (not much different from the previous 15833.2) remains almost unchanged for the next 1500 iterations. In reality, we just need to find a better solution in as little time consumption (iterations) as possible. Compare this to the PSO and GA algorithms, which both find a better solution around 1000 iterations at around 18500 unit lengths. Both are inferior to ACO algorithm (in this TSP problem)
  • 28. Traditional :  Accuracy: Traditional optimization methods, such as linear programming and integer programming, can provide exact solutions, which is necessary for application scenarios that require precise results.  Computational complexity: for smaller problem instances, these methods are usually feasible. However, TSP is NP-hard problem, which means that an increase in problem size leads to an exponential increase in solution time, making traditional methods impractical for large-scale problems.  Resource requirements: finding an exact solution often requires significant computational resources, including time and memory, especially when the problem size is large. Traditional vs. Heuristics
  • 29.  Efficiency: Heuristic methods, such as ant colony algorithms, genetic algorithms, and particle swarm optimization algorithms, usually find good enough solutions in an acceptable amount of time, especially for large-scale problems.  Flexibility: these methods are well adapted to various variants of TSPs, and the performance can be optimized by tuning the parameters.  Quality of solutions: while heuristics may not be guaranteed to find an optimal solution, they are often able to find very close to optimal solutions in practical applications.  Ease of implementation: Heuristics tend to be easier to implement and debug than complex exact algorithms.(Less math)  Scalability: Heuristic methods can be easily extended to other complex multi- objective optimization problems, combinatorial optimization problems. Traditional vs. Heuristics Heuristics: