Download presentation
Presentation is loading. Please wait.
Published byFay Charles Modified over 9 years ago
1
Object Oriented Programming Assignment Introduction Dr. Mike Spann m.spann@bham.ac.uk
2
Assignment Introduction Aims/Objectives Aims/Objectives To produce a C# implementation of the ANT colony optimisation algorithm (ACO) and derivatives To apply to the Travelling Salesman Problem
3
ANT algorithms
4
Ants are practically blind but they still manage to find their way to and from food. How do they do it? Ants are practically blind but they still manage to find their way to and from food. How do they do it? These observations inspired a new type of algorithm called ant algorithms (or ant systems) These observations inspired a new type of algorithm called ant algorithms (or ant systems) These algorithms are very new (Dorigo, 1996) and is still very much a research area where they are applied to the solution of hard discrete optimization problems These algorithms are very new (Dorigo, 1996) and is still very much a research area where they are applied to the solution of hard discrete optimization problems
5
ANT algorithms Ant systems are a population based approach. In this respect they is similar to genetic algorithms Ant systems are a population based approach. In this respect they is similar to genetic algorithms There is a population of ants, with each ant finding a solution and then communicating with the other ants There is a population of ants, with each ant finding a solution and then communicating with the other ants Communication is not peer to peer but indirect with the use of pheromone
6
ANT algorithms Real ants can find the shortest path to a food source by laying a pheromone trail Real ants can find the shortest path to a food source by laying a pheromone trail The ants which take the shortest path, lay the largest amount of pheromone per unit time The ants which take the shortest path, lay the largest amount of pheromone per unit time Positive feedback reinforces this behaviour and more ants take the shortest path resulting in more pheromone being laid Positive feedback reinforces this behaviour and more ants take the shortest path resulting in more pheromone being laid
7
Travelling Salesman Problem Classic discrete optimisation problem Classic discrete optimisation problem Salesman needs to visit all cities just once and return back home Find the best route (minimum route length)
8
Travelling Salesman Problem The TSP is a NP-hard problem The TSP is a NP-hard problem Essentially it means there is no polynomial time solution (complexity O(N k ) ) nor can a solution be verified in polynomial time Essentially it means there is no polynomial time solution (complexity O(N k ) ) nor can a solution be verified in polynomial time We would need to check the solution over all possible routes to verify it One of many NP hard problems One of many NP hard problems
9
Travelling Salesman Problem N cities -> (N-1)!/2 routes N cities -> (N-1)!/2 routes Small problem involving 29 cities in Western Sahara has 2x10 28 routes! Currently TSP’s involving 1000’s cities are being studied Currently TSP’s involving 1000’s cities are being studied You should restrict your algorithm to problems with <1000 cities! You should restrict your algorithm to problems with <1000 cities! The ACO algorithm has proved to be an effective approach with performances close to optimal The ACO algorithm has proved to be an effective approach with performances close to optimal
10
Applying the ACO algorithm to the TSP ACO is an iterative algorithm ACO is an iterative algorithm During each iteration a number of ants are released to search the ‘solution space’ During each iteration a number of ants are released to search the ‘solution space’ Typically the number of ants ~ number of cities Each ant makes a probabilistic choice about its route Each ant makes a probabilistic choice about its route The higher the pheromone on an edge in the TSP graph, the higher the chance of selecting that edge
11
Applying the ACO algorithm to the TSP i j d ij distance between cities i and j d ij distance between cities i and j τ ij the amount of pheremone between cities i and j τ ij the amount of pheremone between cities i and j β determines influence of arc length over accumulated pheromone β determines influence of arc length over accumulated pheromone
12
Applying the ACO algorithm to the TSP After each ant has completed it’s route, the route length for each ant is computed After each ant has completed it’s route, the route length for each ant is computed Assumes each ant has a local memory of where it’s been unlike biological ants! The pheromone on the edges of each route are updated according to the route length The pheromone on the edges of each route are updated according to the route length Also, it is assumed that a certain amount of pheromone ‘evaporation’ takes place so that old routes are forgotten
13
Applying the ACO algorithm to the TSP
14
Improvements to the basic ACO algorithm The performance of the basic ACO is not great The performance of the basic ACO is not great But definitely better than the Greedy algorithm! A number of improvements are possible which produce closer to optimal solutions A number of improvements are possible which produce closer to optimal solutions These include: These include: Min-Max algorithm Rank order algorithm Elitist algorithm Non-probabilistic transition Also ‘local search’ algorithms can refine the solution Also ‘local search’ algorithms can refine the solution
15
Improvements to the basic ACO algorithm ‘Elitist’ algorithm ‘Elitist’ algorithm Only update the pheromone on the currently optimum route The pheromone on all edges still undergoes evaporation Makes a big difference in performance over the basic ACO Makes a big difference in performance over the basic ACO
16
Improvements to the basic ACO algorithm Non probablistic transition Non probablistic transition Choose a non-probabilistic transition rule according to some ‘annealing’ schedule Choose a random number 0<q<1 and some threshold parameter q 0 (t) q< q 0 (t) probabilistic transition rule applied as before Otherwise, a deterministic transition rule is applied :
17
Improvements to the basic ACO algorithm q 0 (t) defines an annealing schedule q 0 (t) defines an annealing schedule q 0 (t) small for small t, the normal probabilistic transition rule is favoured Exploration q 0 (t) approaches 1 for increasing t, the deterministic transition rule is favoured Exploitation
18
Improvements to the basic ACO algorithm Local search Local search Exchanges edges to reduce the edge length ‘k-opt’ algorithms Can impose a huge computational burden for k>3 I implemented a simple approach which requires a single comparison at each node
19
Improvements to the basic ACO algorithm a b c d e f
20
Assessment Programming report (deadlines are on the handout) Programming report (deadlines are on the handout) Follow closely the marking pro-forma Follow closely the marking pro-forma The report should contain discussions about object orientation, code re-useability, object interaction, algorithm performance and comparisons (close to ‘optimal’?) The report should contain discussions about object orientation, code re-useability, object interaction, algorithm performance and comparisons (close to ‘optimal’?) A formal design discussion is not expected but informal class/object diagrams and pseudo-code should be used A formal design discussion is not expected but informal class/object diagrams and pseudo-code should be used
21
Demo
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.