210 likes | 232 Views
This assignment aims to implement the Ant Colony Optimization (ACO) algorithm in C# for solving the Traveling Salesman Problem (TSP). The ACO algorithm mimics the behavior of ants to find the shortest path. Various improvements to the basic algorithm will also be explored.
E N D
Object Oriented Programming Assignment Introduction Dr. Mike Spann m.spann@bham.ac.uk
Assignment Introduction • Aims/Objectives • To produce a C# implementation of the ANT colony optimisation algorithm (ACO) and derivatives • To apply to the Travelling Salesman Problem
ANT algorithms • 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 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
ANT 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 • Communication is not peer to peer but indirect with the use of pheromone
ANT algorithms • 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 • Positive feedback reinforces this behaviour and more ants take the shortest path resulting in more pheromone being laid
Travelling Salesman Problem • Classic discrete optimisation problem • Salesman needs to visit all cities just once and return back home • Find the best route (minimum route length)
Travelling Salesman Problem • The TSP is a NP-hard problem • Essentially it means there is no polynomial time solution (complexity O(Nk) ) 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
Travelling Salesman Problem • N cities -> (N-1)!/2 routes • Small problem involving 29 cities in Western Sahara has 2x1028 routes! • Currently TSP’s involving 1000’s cities are being studied • 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
Applying the ACO algorithm to the TSP • ACO is an iterative algorithm • 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 • The higher the pheromone on an edge in the TSP graph, the higher the chance of selecting that edge
Applying the ACO algorithm to the TSP • dijdistance between cities iand j • τijthe amount of pheremone between cities iand j • βdetermines influence of arc length over accumulated pheromone j i
Applying the ACO algorithm to the TSP • 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 • Also, it is assumed that a certain amount of pheromone ‘evaporation’ takes place so that old routes are forgotten
Improvements to the basic ACO algorithm • 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 • These include: • Min-Max algorithm • Rank order algorithm • Elitist algorithm • Non-probabilistic transition • Also ‘local search’ algorithms can refine the solution
Improvements to the basic ACO 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
Improvements to the basic ACO algorithm • Non probablistic transition • Choose a non-probabilistic transition rule according to some ‘annealing’ schedule • Choose a random number 0<q<1and some threshold parameter q0(t) • q< q0(t) probabilistic transition rule applied as before • Otherwise, a deterministic transition rule is applied :
Improvements to the basic ACO algorithm • q0(t) defines an annealing schedule • q0(t) small for small t, the normal probabilistic transition rule is favoured • Exploration • q0(t) approaches 1 for increasing t, the deterministic transition rule is favoured • Exploitation
Improvements to the basic ACO algorithm • 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
Improvements to the basic ACO algorithm a e c d b f
Assessment • Programming report (deadlines are on the handout) • 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’?) • A formal design discussion is not expected but informal class/object diagrams and pseudo-code should be used