Object Oriented Programming Assignment Introduction Dr Mike Spann
Object Oriented Programming Assignment Introduction Dr. Mike Spann m. spann@bham. ac. uk
Assignment Introduction n Aims/Objectives u To produce a C# implementation of the ANT colony optimisation algorithm (ACO) and derivatives u To apply to the Travelling Salesman Problem
ANT algorithms
ANT algorithms Ants are practically blind but they still manage to find their way to and from food. How do they do it? n These observations inspired a new type of algorithm called ant algorithms (or ant systems) n 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 n
ANT algorithms Ant systems are a population based approach. In this respect they is similar to genetic algorithms n There is a population of ants, with each ant finding a solution and then communicating with the other ants u Communication is not peer to peer but indirect with the use of pheromone n
ANT algorithms n Real ants can find the shortest path to a food source by laying a pheromone trail n 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 n
Travelling Salesman Problem n Classic discrete optimisation problem u Salesman needs to visit all cities just once and return back home u Find the best route (minimum route length)
Travelling Salesman Problem The TSP is a NP-hard problem n Essentially it means there is no polynomial time solution (complexity O(Nk) ) nor can a solution be verified in polynomial time u We would need to check the solution over all possible routes to verify it n One of many NP hard problems n
Travelling Salesman Problem N cities -> (N-1)!/2 routes u Small problem involving 29 cities in Western Sahara has 2 x 1028 routes! n Currently TSP’s involving 1000’s cities are being studied n You should restrict your algorithm to problems with <1000 cities! n The ACO algorithm has proved to be an effective approach with performances close to optimal n
Applying the ACO algorithm to the TSP n n n ACO is an iterative algorithm During each iteration a number of ants are released to search the ‘solution space’ u Typically the number of ants ~ number of cities Each ant makes a probabilistic choice about its route u 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 n j n i n dij distance between cities i and j τij the amount of pheremone between cities i and j β determines influence of arc length over accumulated pheromone
Applying the ACO algorithm to the TSP After each ant has completed it’s route, the route length for each ant is computed u Assumes each ant has a local memory of where it’s been unlike biological ants! n The pheromone on the edges of each route are updated according to the route length u Also, it is assumed that a certain amount of pheromone ‘evaporation’ takes place so that old routes are forgotten n
Applying the ACO algorithm to the TSP
Improvements to the basic ACO algorithm n n The performance of the basic ACO is not great u But definitely better than the Greedy algorithm! A number of improvements are possible which produce closer to optimal solutions These include: u Min-Max algorithm u Rank order algorithm u Elitist algorithm u Non-probabilistic transition Also ‘local search’ algorithms can refine the solution
Improvements to the basic ACO algorithm ‘Elitist’ algorithm u Only update the pheromone on the currently optimum route u The pheromone on all edges still undergoes evaporation n Makes a big difference in performance over the basic ACO n
Improvements to the basic ACO algorithm n Non probablistic transition u Choose a non-probabilistic transition rule according to some ‘annealing’ schedule t Choose a random number 0<q<1 and some threshold parameter q 0(t) t q< q 0(t) probabilistic transition rule applied as before t Otherwise, a deterministic transition rule is applied :
Improvements to the basic ACO algorithm n q 0(t) defines an annealing schedule q (t) small for small t, the normal probabilistic transition rule is favoured t Exploration u q 0(t) approaches 1 for increasing t, the deterministic transition rule is favoured t Exploitation u 0
Improvements to the basic ACO algorithm n Local search u Exchanges edges to reduce the edge length t ‘k-opt’ algorithms t Can impose a huge computational burden for k>3 u 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 n n 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
Demo
- Slides: 21