a study of ant colony algorithms and a potential ... · i introduction a the ant colony heuristics...

20
A study of Ant Colony Algorithms and a potential application in Graph Drawing Student Name: A.G. Stewart Supervisor Name: D. Paulusma Submitted as part of the degree of B.Sc. Natural Sciences to the Board of Examiners in the School of Engineering and Computing Sciences, Durham University Abstract — Context: Emergence is a term used to describe complex patterns or systems which are formed from very basic rules or agents. Once such example which has intrigued scientists across several fields has been ant colonies. Computer scientists are particularly interested in ant colonies as although each individual ant acts in a very simple manor, the ant colony as a whole is able to find shortest paths between the nest and food sources. Modelling this can provide approximate solutions to many NP –Hard problems. Aims: The purpose of this research is firstly to compare various ant colony optimization algorithms against each other, as well as against other well know heuristics, including Simulated Annealing and Genetic Algorithms on the Travelling Salesman problem which is a typical graph based problem. Secondly, to look at applying an ant colony algorithm in graph drawing. The force–directed graph drawing algorithms are a class of algorithms which are commonly used, however, they only perform a local search so the results on large graphs can be poor. This research looks at using a force–directed graph drawing algorithm as a local search with a modified ant–colony algorithm to achieve better results. Method: Several ant colony algorithms; Ant System, MAX - MIN Ant System and Ant Colony Sys- tem; Simulated Annealing and the Genetic Algorithm were implemented, tuned and tested on the Travelling Salesman problem. This was done to determine how the various parameters effected performance on different problems and how the algorithms compared against each other. Each algorithm outputs its performance in csv format, as well as optionally as a series of svg images. A force–directed graph drawing algorithm, a basic ant colony algorithm and an ant colony algorithm using a force–directed local search method were implemented. The ant colony algorithms were modified to work with the graph drawing problem and tests were done to determine the best set of parameters and to see how the ant colony algorithms compared against the well known force–directed graph drawing algorithm. Results: The ant colony algorithms were tested and optimal parameters were found as the influence parameter β =3.0 and the decay constant ρ =0.15 for Ant System; the decay constants ρ = χ =0.11 and the probability of exploitation q 0 =0.65 for Ant Colony System and the lower pheromone limit τ min = 0.05 for MAX - MIN Ant System. The well known 2-opt, 2.5-opt and 3-opt local search methods were tested with the best results coming from 2.5-opt with the MMAS . The algorithms were then tested against Simulated Annealing and the basic genetic algorithm. Overall MMAS with 2.5-opt was the closest to Simulated Annealing which gave the best final results. When taking into account time considerations, Ant System provided good results very quickly so was best for very large graphs or situations with very tight time constraints. Given moderate time constraints MMAS with 2.5-opt provided the best results with Simulated Annealing coming out best with reasonable time. The graph drawing tests showed that an ant colony algorithm could be paired with a force–directed graph drawing algorithm to achieve better results with the ant colony algorithm’s solutions being 11% better on average. This advantage was lost, however, on very small graphs and came with a severe time penalty with the ant colony algorithm being over 200 times slower, although of comparable time complexity. Conclusion: Three variations on the ant colony algorithm have been implemented and compared along with Simulated Annealing and a genetic algorithm. We have investigated the family and proposed a new hybrid algorithm which combines the force–directed graph drawing algorithm with an ant colony algorithm and in doing so produces better results than the force–directed graph algorithm alone. Keywords — Any Colony Optimization, Artificial Intelligence, Meta-heuristics, Graph Drawing 1

Upload: docong

Post on 01-Aug-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

A study of Ant Colony Algorithms and a potentialapplication in Graph Drawing

Student Name: A.G. StewartSupervisor Name: D. Paulusma

Submitted as part of the degree of B.Sc. Natural Sciences to the

Board of Examiners in the School of Engineering and Computing Sciences, Durham University

Abstract —Context: Emergence is a term used to describe complex patterns or systems which are formed from very

basic rules or agents. Once such example which has intrigued scientists across several fields has been antcolonies. Computer scientists are particularly interested in ant colonies as although each individual ant actsin a very simple manor, the ant colony as a whole is able to find shortest paths between the nest and foodsources. Modelling this can provide approximate solutions to many NP–Hard problems.

Aims: The purpose of this research is firstly to compare various ant colony optimization algorithmsagainst each other, as well as against other well know heuristics, including Simulated Annealing and GeneticAlgorithms on the Travelling Salesman problem which is a typical graph based problem. Secondly, to look atapplying an ant colony algorithm in graph drawing. The force–directed graph drawing algorithms are a classof algorithms which are commonly used, however, they only perform a local search so the results on largegraphs can be poor. This research looks at using a force–directed graph drawing algorithm as a local searchwith a modified ant–colony algorithm to achieve better results.

Method: Several ant colony algorithms; Ant System,MAX −MIN Ant System and Ant Colony Sys-tem; Simulated Annealing and the Genetic Algorithm were implemented, tuned and tested on the TravellingSalesman problem. This was done to determine how the various parameters effected performance on differentproblems and how the algorithms compared against each other. Each algorithm outputs its performance incsv format, as well as optionally as a series of svg images.

A force–directed graph drawing algorithm, a basic ant colony algorithm and an ant colony algorithmusing a force–directed local search method were implemented. The ant colony algorithms were modified towork with the graph drawing problem and tests were done to determine the best set of parameters and to seehow the ant colony algorithms compared against the well known force–directed graph drawing algorithm.

Results: The ant colony algorithms were tested and optimal parameters were found as the influenceparameter β = 3.0 and the decay constant ρ = 0.15 for Ant System; the decay constants ρ = χ = 0.11and the probability of exploitation q0 = 0.65 for Ant Colony System and the lower pheromone limit τmin =0.05 forMAX −MIN Ant System. The well known 2-opt, 2.5-opt and 3-opt local search methods weretested with the best results coming from 2.5-opt with theMMAS. The algorithms were then tested againstSimulated Annealing and the basic genetic algorithm. Overall MMAS with 2.5-opt was the closest toSimulated Annealing which gave the best final results. When taking into account time considerations, AntSystem provided good results very quickly so was best for very large graphs or situations with very tight timeconstraints. Given moderate time constraintsMMAS with 2.5-opt provided the best results with SimulatedAnnealing coming out best with reasonable time.

The graph drawing tests showed that an ant colony algorithm could be paired with a force–directed graphdrawing algorithm to achieve better results with the ant colony algorithm’s solutions being 11% better onaverage. This advantage was lost, however, on very small graphs and came with a severe time penalty withthe ant colony algorithm being over 200 times slower, although of comparable time complexity.

Conclusion: Three variations on the ant colony algorithm have been implemented and compared alongwith Simulated Annealing and a genetic algorithm. We have investigated the family and proposed a newhybrid algorithm which combines the force–directed graph drawing algorithm with an ant colony algorithmand in doing so produces better results than the force–directed graph algorithm alone.

Keywords — Any Colony Optimization, Artificial Intelligence, Meta-heuristics, Graph Drawing

1

Page 2: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

I INTRODUCTION

A The Ant Colony Heuristics

Ant Colony Optimization is a relatively recent meta heuristic, joining more established algo-rithms such as the genetic algorithm and Simulated Annealing in trying to find good approximatesolutions to NP–hard problems. Ant colony algorithms were first proposed by Marco Dorigo inhis 1991 Ph.D dissertation with contributions from Alberto Colorni and Vittorio Maniezzo (Dorigo& Stutzle 2004, pxiiv) (Dorigo et al. 1996, p29). Since then, many other people have worked onthe algorithm and its derivations (Pedemonte et al. 2011, p5182), applying the algorithm to a hugerange of problems (Dorigo et al. 2006, p32).

The basic principals behind the any colony optimization algorithms, unsurprisingly, draw strongparallels to the way in which ant colonies operate in nature. Initially the ants run blind until onemanages to find food, upon doing so it then returns to the nest, leaving a trail of pheromones alongthe path it takes. Once a pheromone trail has been established, rather than running around randomly,other ants within the colony will prefer to follow the pheromone trail, leaving their own pheromonesif they find food reinforcing the trail (Dorigo et al. 2006, p29) (Dorigo & Stutzle 2004, p2).

There are three significant characteristics with ant colony algorithms which contribute to itsperformance (Dorigo et al. 1996, p29).

1. The better paths get more pheromones deposited on them and hence become more attractiveto future ants (Dorigo et al. 1996, p31). This positive feedback results in a quick divergenceon good solutions.

2. The algorithm is distributed over a colony of ants (agents) which helps prevent the algorithmfrom converging too soon on a local minima (Dorigo et al. 1996, p29). It also means thatthe algorithms are very easy to implement in parallel (Dorigo & Socha 2007, p13) to makeuse of modern hardware such as multi-core CPUs or GPUs (Dorigo & Stutzle 2004, p82)(Pedemonte et al. 2011, p5181).

3. A greedy heuristic results in good solutions being found early on, giving the algorithm a goodstarting point from which to build upon (Dorigo et al. 1996, p40).

Over the past 20 years, many new optimizations have been found and derivative algorithmscreated (Dorigo et al. 2006, p32). A popular addition is known as local search whereby beforeapplying the pheromones to the best tour, a simple local search is run to find the nearest localminima, and hence improve the results even further (Dorigo et al. 2006, p31) (Dorigo & Stutzle2004, p92). Other optimizations include limiting the minimum and maximum pheromone levels(Dorigo & Socha 2007, p11) or the implementation of a local pheromone system used to allowant to communicate within each round (Dorigo et al. 2006, p32). The major optimizations anddevelopments will be looked at within this report.

The purpose of the project is firstly to understand better the ant colony family of algorithms. Itcompares a selection of algorithms from the family; Ant System (AS), Ant Colony System (ACS)andMAX −MIN Ant System (MMAS) against each other, as well as against other well knownheuristics including Simulated Annealing and a genetic algorithm. The testing is done over a rangeof different sized graphs and focuses on the Travelling Salesman problem.

B Deliverables

In order to investigate all the aspects of the research, it was split up into three tiers, referred toas basic, intermediate and advanced objectives.

Basic Objectives:

2

Page 3: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

BO.1 Implement the Ant System algorithm to solve to the Travelling Salesman problem.BO.2 Test and tune the parameters to determine which give the best results.

Intermediate Objectives:IO.1 Implement two other ant colony algorithms and two other similar heuristics such as, AnyColony System,MAX −MIN Ant System, Simulated Annealing and the genetic algorithm.IO.2 Compare their performance with each other and the “Ant System” algorithm from BO.1 overa range of different sized graphs.

Advanced Objectives:AO.1 Implement a force–directed graph drawing algorithm and an ant colony algorithm to rendergraphs.AO.2 Experiment using the force–directed graph drawing algorithm as a local search with the algo-rithm developed in AO.1.AO.3 Test the ant colony algorithm against the force–directed graph drawing algorithm with variousdifferent sized graphs.

II RELATED WORK

A Ant System

The ant colony optimization family of algorithms were originally proposed by Marco Dorigo inhis 1991 Ph.D dissertation with contributions from Alberto Colorni and Vittorio Maniezzo (Dorigo& Stutzle 2004, pxiiv) (Dorigo et al. 1996, p29). They submitted a paper later that year which waspublished in 1996. In this paper three variations of the “Ant System” algorithm are put forward; ant–cycle, ant–density and ant–quantity (Dorigo et al. 1996, p32) of which ant-cycle was proposed to bethe most promising (Dorigo et al. 1996, p33). The paper also looks at the values of the parametersand puts forward values of α = 1.0, β = 5.0 for the influence parameters and ρ = 0.5 for the decayconstant (Dorigo et al. 1996, p33) and suggests the the optimal colony size is approximately equalto the dimension of the problem (Dorigo et al. 1996, p35). We will discuss the meaning of theseparameters later in this paper.

In addition to this, on Marco Dorigo also wrote a book with Thomas Stutze, “Ant Colony Opti-mization” (Dorigo & Stutzle 2004). This covers a huge area, starting off with a chapter on the back-ground, going on to cover implementations for different problems, as well as various extensionsof the algorithms before going on to look at the theory and current developments. The book givessuggestions for the starting pheromone levels. It suggests setting the pheromones to the amountwhich you would expect to be deposited in one iteration (Dorigo & Stutzle 2004, p70) as well assuggesting values for the parameters consistent with the initial paper; α = 1.0, 2.0 ≤ β ≤ 5.0 andρ = 0.5 (Dorigo & Stutzle 2004, p71).

The basic implementation is given in its most basic form in “An Introduction to Ant ColonyOptimization” (Dorigo & Socha 2007, p6).

Set parameters, initialize pheromone trailswhile termination conditions not met do

ConstructAntSolutionsApplyLocalSearch {optional}UpdatePheromones

end while

This is also given in similar forms in several other publications (Dorigo et al. 1996, p32) (Dorigo& Stutzle 2004, p68) (Dorigo et al. 2006, p29) etc.

3

Page 4: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

ConstructAntSolutions is also covered in several papers but is explained clearly in the book(Dorigo & Stutzle 2004, p70) and (Dorigo et al. 2006, p32). Initially the ants are put on randomcities, then at each step, each ant chooses the next city to travel to according to the following rule:

pkij =

[τij ]

α[ηij ]β∑

l∈Nki[τij ]

α[ηij ]β if j ∈ N k

i

0 otherwise(1)

Whilst this looks complicated, in essence all it says is that an ant k on vertex i will move toan unvisited vertex j according to the probability pkij ∝ [τij]

α [ηij]β . τij is the pheromone scent on

the arc between i and j and ηij is the heuristic information which is given by ηij = 1dij

where dijis the heuristic cost or distance between the two vertices (Dorigo et al. 2006, p32). The influenceparameters α and β control the relative influence of these two sources of information (Dorigo et al.2006, p32). Since generally α = 1.0 (Dorigo et al. 1996, p33)(Dorigo & Stutzle 2004, p71) it ispossible to ignore this parameter when implementing the Ant System algorithm.

The equation for laying pheromones is as follows (Dorigo et al. 2006, p32).

τij ← (1− ρ) · τij +m∑k=1

∆τ kij (2)

∆τ kij =

{Q/Lk if ant k used edge (i, j) in its tour0 otherwise

(3)

B Derivative algorithms

Since the Ant System was published, there have been several other algorithms which have ex-tended it. The first to be looked at in this report is Ant Colony System, proposed by Dorigo andGambardella (Dorigo & Gambardella 1997a) (Dorigo & Gambardella 1997b).

ACS introduces three new aspects which differ from the AS algorithm (Dorigo & Gambardella1997b, p55), the first of which is the state transition rule. The next arc in the tour is chosen accordingto the rule (Dorigo & Gambardella 1997a, p3).

s =

{argmaxj∈N ki [τij] · [ηij]β ifq ≤ q0 (exploitation)

S otherwise (exploration)(4)

S is the rule used by the Ant System algorithm. The result of this is that not all ants will choose thenext arc with a random probability, some will just choose the most attractive one and move to that.This rule implements a new parameter q0. In the book the suggested value is q0 = 0.9 (Dorigo &Stutzle 2004, p71) which is also the value used in the paper (Dorigo & Gambardella 1997b, p56).

In addition to this there are two changes to the way the pheromones work. Firstly, at then endof each round, the pheromones are laid on the global best tour, rather than by every ant or even theround best ant (Dorigo & Gambardella 1997b, p56). Secondly at every step each ant makes, thepheromones are adjusted according to the rule (Dorigo & Gambardella 1997b, p56).

τij ← (1− χ) · τij + χ∆τij (5)

Three possible values were trialled for ∆τij , the first based on Q-learning, the second was settingit to τ0, the initial pheromone value and the third setting it to 0 (Dorigo & Gambardella 1997b, p56).According to Dorigo and Gambardella (1997b), the best results came from ∆τij = τ0.MAX −MIN Ant System was proposed by Thomas Stutzle and Holger Hoos (2000) and

implements three new behaviours (Stutzle & Hoos 2000, p898). Firstly it has an offline updatesimilar to ACS where only the best ant may lay pheromones, although, unlike with ACS, this variesbetween the global best and round best ants from iteration to iteration (Stutzle & Hoos 2000, p898).

4

Page 5: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

The most obvious change is that there the pheromone values are restricted to the range τmin ≤τij ≤ τmax (Stutzle & Hoos 2000, p898) which helps to prevent stagnation potentially caused bythe previously mentioned behaviour (Dorigo & Stutzle 2004, p74). By setting minimum values nopotential solution can become impossible and no solution can become so strong as to stop any othersbeing chosen (Stutzle & Hoos 2000, p899). The upper bound is given by τmax = 1

ρC∗where C∗ is

the length of the optimal tour (Dorigo & Stutzle 2004, p75).The final behaviour is to set the initial pheromone value on each arc to τmax. This encour-

ages exploration early on in the algorithm since after n iterations the maximum ratio between thepheromones on any two arcs will be ρn (Stutzle & Hoos 2000, p900).

C Local Search

The basic implementation of Ant System and its derivatives allows for a local search to beimplemented easily. Once the ants have constructed their tours, these tours can be improved uponby a local search algorithm (Dorigo & Stutzle 2004, p92). The local search can be applied to alltours, or simply to the round best tour, the former producing theoretically better tours but beingsignificantly slower than the latter (Bentley 1992, p401).

Common local search methods include 2-opt, 3-opt and 2.5-opt. 2-opt works by removingtwo arcs, splitting the tour up into two sections. The tour is then reconnected in the alternativepermutation (Johnson & McGeoch 1997, p17), as can be seen in Figure 1. In essence, a 2-optsearch simply reverses part of the tour (Bentley 1992, p399).

Figure 1: An example of a 2-opt swap.

3-opt local search works in the same was as 2-opt, except rather than removing 2 arcs, 3 arcs areremoved, and there are 8 different ways of putting them back (Bentley 1992, p401), 7 which differfrom the original. 3-opt swaps include all the 2-opt swaps, as well as many more, however, loopingthrough three different splits means it has complexityO (n3) which is significantly worse than 2-optwhich has complexity O (n2) (Bentley 1992, p401).

2.5-opt is an expansion to 2-opt which provides many of the benefits of 3-opt but with consider-ably less additional complexity (Johnson & McGeoch 1997, p32). In addition to testing the standard2-opt swaps with the arcs AB and CD, 2.5-opt also tries moving the vertex B in between vertices Cand D (Johnson & McGeoch 1997, p32).

D Graph Drawing

Graph drawing relates to creating a visual representation of a graph. This has many potentialapplications, from the obvious being simply wanting to visually represent some data to more subtleapplications such as determining the best layout of components on a PCB such that the total size ofthe board and number of cross overs is reduced (Sim 1996, p1). In this project, the aim of the graphdrawing algorithm is to represent a connected graph with no loops or multiple edges clearly usingonly straight edges.

5

Page 6: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

In order to create a clear representation, there are various criteria which should be targeted,including even vertex distribution (Kamada & Kawai 1989, p8), maximizing angular resolution(Sim 1996, p2) and minimizing edge crossovers (Kamada & Kawai 1989, p8).

Force–directed graph algorithms generate representations of a graph by modelling each vertex asa charged particle which repels other vertices according to Coulomb’s law (Fruchterman & Reingold1991, p1130). Each arc is modelled as a spring which will apply a force, acting to return to its naturallength according to Hooke’s Law (Fruchterman & Reingold 1991, p1130). This is demonstrated inFigure 2a in which the red arrows represent the repulsion between two vertices and green arrowsrepresent the spring force.

The spring force acts to keep arcs of a similar length, this also helps keeps neighbouring verticesat a uniform distance. The repulsion between vertices helps to spread them out, which combinedwith the spring force results in an even distribution of vertices being preferred.

Angular resolution relates to the angles between two edges connected to a single vertex (Sim1996, p2). If this angle is too small, it will be very difficult to distinguish between the edges. Ascan be seen in Figure 2a, the repulsive force between the vertices, helps increase the size of anglesbetween vertices.

Regarding the number of edge crossovers, the algorithm will not actively avoid them, however,as can been seen in Figure 2b, crossed over arcs are longer than the alternative, which means thatthere will be more potential energy in the system, resulting in it being less stable.

Figure 2: A simple scenario which demonstrates properties of force–directed graph algorithms.

The problem with force–directed graph algorithms is, whilst the heuristic is good, the algorithmis very sensitive to local minima. The purpose of this research is to see if an ant colony algorithmcan be used in conjunction with the force–directed graph algorithms in order to create better results.

III SOLUTION

A Ant System and the basics

The first thing to be implemented was the graph class; this had the responsibility of storingthe pheromone scents and arc lengths as well as providing a basic interface to access them with.At its most basic, the Graph object was simply a list of vertices. A second class, the Vertex classwas 2 lists, the first being the distance (or cost) to everyone other vertex and the second being thepheromone scent on the arc to every other vertex. The graph class then implemented the followingbasic functions to query the graph data.

public void set_distance(int to, int fr, int distance);public int get_distance(int to, int fr);public void set_pheromones(int to, int fr, double pher);

6

Page 7: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

public void add_pheromones(int to, int fr, double pher);public double get_pheromones(int to, int fr);public void evaporate_pheromones(double factor);

Whilst the graph class provides all the information required by the algorithms on the travellingsalesman problems, it is sufficiently abstract that it could still be used for any graph, meaning thatit can be useful for a number of other problems. The graph class was then developed further withtwo more key functions. Since this project will be using TSPLIB which uses integer costs betweenvertices (Reinelt 1995, p6), the distances are stored as integers, the pheromones, however, are storedas double precision floating point decimals.

public int get_path_length(int[] path, bool circ = true);public string render(int[] path, bool phero = false);

The first of these functions takes an integer list of vertex ids as an argument and returns thelength of a path going through these vertices. The optional parameter states whether the path shouldbe a closed loop or not. The second function exists mainly for debugging and testing and rendersthe graph as an svg. The first argument takes a path to overlay on the graph and the second optionalargument specifies whether or not the pheromone levels should be displayed in the result.

TSPLIB is library containing a large number of sample scenarios for the travelling salesmanproblem, based on real–life scenarios. It also provides a specification for a file format in which TSPproblems can stored (Reinelt 1995, p1).

The next to be implemented was an interface to provide a way to implement all of the algorithmsin a single uniform way. It required start and stop functions to begin and end the algorithms, as wellas three functions relating to the setting of parameters. This method of sending a string parameterand a string value was implemented with the thought that a program could load any algorithm withunknown parameters and with these three functions could easily have a simple way to allow the enduser to adjust the various parameters. Sending parameters with strings was used because almostany form of data can be transferred as a string and converted to the desired datatype with relativeease. The algorithm is also passed a callback function which makes use of a function of Vala calleddelegates which allow you to treat functions as objects. In this case the Callback object is a functionwhich takes an integer array (the tour found) and an integer (the cost of the tour). This function iscalled when an improved tour is found, informing the main program of its progress.

delegate void Callback(int[] path, int cost);public interface AI.Solver : GLib.Object {

//public abstract Solver(Graph graph, Callback callback);public abstract void run();public abstract void stop();public abstract string[] list_parameters();public abstract string set_parameter(string parameter, str...public abstract string get_parameter(string parameter);

}

The “Ant System” and all future algorithms could then be written as an implementation of thisinterface. The algorithm also introduced a new Ant class which performed all of the agent actions.Each ant stored its current location as an integer and the current path it had taken so far as a listof integers as well as pointers to the parent “Solver” object and “Graph” object. In addition to thisthere were several methods defined.

public void reset(int start = 0);public int choose_arc();

7

Page 8: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

public void move_to(int vertex);public int length();public void lay_pheromones();

reset is called each iteration and empties the ants path history and puts it back to its startingposition. By default 0 but it is usually put on a random vertex to begin with.

choose arc looks at the graph and chooses the next vertex to visit.move to moves the ant on to another vertex.length returns the length of the path the ant has taken.lay pheromones lays pheromones on the path the ant has taken.With the Ant class containing most of the complicated stuff, the rest of the Ant System imple-

mentation was relatively simple. The actual code is slightly more complicated in order to allow foreasy extensibility for the other algorithms but the basic “Ant System” algorithm is implemented asshown below.

graph.evaporate_pheromones(DECAY);foreach(Ant ant in ants){

ant.reset();while(ant.path.length < graph.size){

ant.move_to(ant.choose_arc());}ant.lay_pheromones();best.is_lower(ant.path, ant.path_length);

}

best is an object which keeps track of the best tour so far. The is lower method checks to see ifthe tour given is better than the one it already has, if so it keeps that and runs the callback function.

B Derivative algorithms

There are two main derivatives to the Ant System algorithm which were looked at during thisproject; Ant Colony System and MAX −MIN Ant System. Initially ACS and MMAS ex-tended the basic AntSystem.Solver object, however, once local search had been implemented theywere modified to extend that instead.

ACS was the first to be implemented and features three significant changes (Dorigo & Gambardella1997b, p55). Firstly, in ACS only the best ant lays pheromones at the end of each iteration (Dorigo& Gambardella 1997b, p56). Since this is common with quite a few ant colony optimization algo-rithms (Stutzle & Hoos 2000, p898), this option was build into the basic AS class, so enabling it forACS was simply a matter of adding “only best lays = true;” to the constructor method.

Second, ACS implements a behaviour called exploitation which affected how ants chose the nextarc to visit (Dorigo & Gambardella 1997a, p3). Since this behaviour had already been experimentedwith, with the basic AS algorithm, the code was already in place but would only be run if theprobability of exploitation was greater than 0, hence by setting a value of q0 > 0 this would beenabled automatically.

Finally, ACS implements a local update rule; every time an ant moves to another arc, it layspheromones on the arc it has just crossed. In order to facilitate this, an empty function was imple-mented into AS, public virtual void step func(int node1, int node2){} which is called each timean ant moves from one vertex to another. To implement the local update rule could then be done bysimply overriding this method.

public override void step_func(int node1, int node2)graph.set_pheromones(node1, node2, (DECAY_ALPHA * graph.g...

8

Page 9: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

For MMAS, there were again a few changes needed. Firstly there was a slightly differentamount of pheromone deposited by the ants. Implementing this was a case over overriding the“calc pheromone strength” function. Like in ACS, only the best ant lays pheromones so the samechange was made in the constructor. Finally limits needed applying to minimum and maximumvalues allowed for pheromones. This required a few changes to the AntSystem.Solver and Graphclasses, but once again, the new code would only be run if values were set for τmin and τmax.

In addition to changes to the algorithms, these derivatives also took different parameters. Thiswas easily supported by simply chaining the relevant functions. For example, theMMAS class’get parameter function was written as such.

public new string get_parameter(string parameter){switch(parameter.down()){

case "tau min":return "%f".printf(TAU_MIN);

default:return (this as AntSystemLocal.Solver).get_parame...

}}

If you tried to set τmin then this function would deal with the request, otherwise it would simplypass it on to the parent class.

C Local Search

For implementing the local search, the basic Ant System algorithm description specified twoplaces where daemon actions should be placed in the algorithm. By default the demon actions didnothing, however, by simply using a different daemon function, local search could be implementedat these points. This was another case where Vala’s delegates came in useful as it provided an easyway to specify which daemon function should be used. The daemon delegate was a function whichtook an ant as an argument and did not return anything.

delegate void Daemon(AntSystem.Ant ant);

Each local search method was implemented as a separate function, and was created using nestedloops. Every permutation of arcs which could be removed was cycled through, and the best tourwhich could be reached via a k-opt swap was returned. A simplified pseudo code version is below.

public path k-opt_search(Ant ant){new_best = ant.path;foreach(int i,j in ant.path.length){

new_path = ant.path.reconnect(i, j);if(new_path.get_length() < new_best.get_length())

new_best = new_path;}return new_best;

}

The basic method regarding k-opt is to make a change and see if that improves the solution.However, with the symmetric TSP there is an easy way to optimize this search. For example, with2-opt, if we consider splitting the tour on the arcs AB and CD, we will reconstruct the tour withthe arcs AC and BD. So rather than generating the new tour and testing its lengths we can simplytest so see if arcs we are adding (AB + BD) are shorter than the arcs we are removing (AB + CD) .

9

Page 10: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

Implementing this almost doubled the speed of the algorithm from 11.9s for 2000 iterations to 6.6s.This shortcut is also applicable to 2.5-opt and 3-opt so was implemented into those functions too.

A slight adaptation to 2-opt was also implemented. Standard 2-opt works by searching theneighbourhood of 2-opt swaps and finding the best one. This means that once it has found a bettersolution it keeps searching from the initial tour. The adaptation testing is inspired by the hill–climbalgorithm in that, once a better tour is found, that new best tour is used as the basis going forward.In testing this local search is referred to as “2-opt climb”.

Two different implementations of 2.5-opt were implemented. Both performed the 2-opt swapinitialy, however, the first implementation performed the 2.5-opt swap separately, basing it upon theinitial tour, whereas the second performed the 2.5-opt swap on the already 2-opt swapped tour. Thelatter implementation is refereed to as “2.5-opt extend” in this report.

D Graph Drawing

As with the travelling salesman problem, implementing the graph drawing algorithms wasstarted off by creating a structure for the graph. This started out as a list of vertices and a 2Darray of ints storing the lengths of the arcs such that arcs[i,j] returned the length of the arc betweenvertices with ids i and j or -1 if no arc was present. In order to avoid having to search through thisarray to loop through the arcs, a list of Tuples was created where each Tuple represented an arc anda Tuple was a struct containing two integers.

The Vertex class then contained three main variables, x, v and a which represented the positionof the vertex, along with its velocity and acceleration. These variables were of type VectorF whichwas similar to the Tuple struct, but also contained several methods to simplify the maths involvedwith variables of this type such as vector.abs(); and vector1.plus(vector2);. Several other functionswere added to both these classes such as a static new graph from file method to create a graph froma text file and a render function which output the current solution in svg format.

Once this had been implemented the force–directed graph drawing algorithm was implemented.This basically ran in a loop and each iteration, looped through the vertices and calculated the forceon each of them. Initially the force between every pair of vertices was calculated as double force =KQQ / rr; where KQQ was a constant. This is based off Coulomb’s law which states the following(Young & Freedman 2008, p717).

F = kq1q2r2

(6)

Whilst it may be useful to have more significant vertices with higher chargers when workingwith larger graphs, in this implementation it was assumed that all vertices were of equal importanceand hence of equal charge so kq1q2 should be constant.

Secondly it then looped through every arc and calculated the force as double force = LAMBDA* extension / L; based on Hooke’s law (Young & Freedman 2008, p193).

F = kx =λx

L(7)

λ is the modulus of elasticity whilst k is the spring constant and x is the extension or the amount thespring is stretched by. The formula is most often given in its simpler form using k, however, λ isbeing used in this report since assuming a constant material, λ is independent of the natural lengthL whereas k = λ

L. The value of L for each arc is stored in the graph object as described above.

Although not implemented in this research, allowing for other natural lengths means that it is veryeasy to adapt the program to generate graphs where you want some arcs longer than others.

Once the forces have been calculated, the velocity and position after a short time ∆t are calcu-lated and the respective variables updated. The loop then moves onto the next iteration.

In order to implement the ant colony algorithm, antsystem.vala was copied from the travellingsalesman problem implementation and only minor changes had to be made for it to work with the

10

Page 11: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

graph drawing problem set up. The main change came with the Vertex object which now had tosupport pheromones. This is implemented as a 2D array of doubles which is individual to eachvertex and provides the pheromone scents for that vertex at every pixel. Whilst max x and max ydefine the maximum x and y coordinates, since x and y are doubles and the output is a scalablevector graphic, they do not define the resolution of the final result, purely the pheromone resolution.The solutions are stored as a Tuple array which contains the xy coordinates for each vertex.

When choosing which coordinates to place the vertex on, an equation similar to the Ant Systemone was used: pi,xy ∝ τi,xy · ηβi,xy where pi,xy is the probability that vertex i is positioned at coor-dinates x, y and τi,xy is the pheromone scent for vertex i at x, y. In this case the visibility ηi,xy wascalculated by considering the graph with just i vertices, with vertices 0 · · · (i − 1) in the positionsalready chosen and vertex i at position x, y.

The question at this point was which heuristic to use. Since the force–directed algorithms arebased on physical models, in order to have the force–directed local search work with the ant colonyalgorithm, it made sense to use the basic heuristic of mechanics, that is, systems are most stable intheir lowest energy state. As such the visibility was chosen to be ηi,xy = 1

Ei,xywhere Ei,xy is the

potential energy of vertex i at the position x, y.Another area to look at was the pheromone levels. With the travelling salesman problem, the

arcs are discrete such that i → j is nothing to do with the arc i → (j + 1). However, with graphdrawing, the position x, y is very similar to the position x, (y+ 1) so it makes sense that if there area lot of pheromones at the position x, y, then there should also be a bias to the surrounding pixels.In order to implement this, when pheromones are laid on x, y, the update is as follows.

public void add_pheromones(int i, int j, double amount){for(int dx = -r; dx < r; dx++){

for(int dy = -r; dy < r; dy++){int dist2 = ((dxˆ2 + dyˆ2 ) / (r/2)) + 1;pheromones[i+dx, j+dy] += amount / dist2;

}}

}

The pheromone scent grows weaker according to the inverse square law. The property r, whichshall be referred to as the pheromone radius, determines how much the pheromones spread.

The final adaptations aimed to reduce unnecessary degrees of freedom. Since ant colony algo-rithms aim to reinforce the best solution, ideally there would only be a small number of optimalsolutions. However, the graph problem has several degrees of freedom on every solution, meaningthat there are an infinite number of solutions. We can drastically reduce this by applying constraintsto the solution. The most obvious two degrees of freedom come from the fact that the optimal so-lution is translation invariant. That a translation of the entire graph by a fixed amount would resultin a equally viable solution, but every vertex would have a different position. In order to avoid this,we will fix one vertex to the origin of the image, which we will define as the centre.

A third degree of freedom comes from the fact that the solution is rotationally invariant. In orderto remove this degree of freedom, we consider polar coordinates and set θ = 0 for the second vertex.We could have set θ to any value, however, θ = 0 was chosen because when we convert back toCartesian coordinates x = r cos(θ) = r and y = r sin(θ) = 0. The final degree of freedom comesfrom symmetry and in order to remove that, we simply force x > 0 for the third vertex.

Once the ants had completed their solutions, the best solution was written to the Graph objectand the force–directed algorithm took it to the local minima. Once complete these results werepassed back to the ant so it could lay pheromones.

11

Page 12: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

E Languages and Formats

During this research, obtaining clear information regarding the progress of the algorithm as itruns is crucial. The primary method comes from the programs stdout which prints the time andresult every time an improved tour is found in csv format. By simply piping the program to a file, acsv file is created which can be opened in a spreadsheet program. Since the csv format is so simple,it is trivial to implement and to write scripts to grab specific information from it.

Secondly the algorithms can output visual information by rendering the current state of the graphas an svg image. For the TSP algorithms, the thickness of the lines show the pheromone strengthand a black line shows the best tour. For the graph drawing algorithms, lines indicating accelerationand velocity are added so show how the graph is reacting. The svg format was chosen as graphs areeasily represented as vectors and the xml based format is trivial to implement

For the ACO graph drawing algorithms, the pheromone levels for up to 3 points can be outputas a raster graphic in the ppm format. This format has been chosen as its extreme simplicity makesup for the poor file size. An image is simply a list or pixel values so no libraries are required.

The algorithms are programmed in the Vala programming language which is a compiled objectorientated language with a similar syntax to Java and C#. Since it is fully compiled (via c) it is fasterthan interpreted languages such as Python or byte–compiled languages such as Java.

IV RESULTS

A Ant System

With everything implemented the testing began in earnest. Initially testing took place on theTSPLIB problem att48 which looks at the shortest route visiting 48 US capitals. There are twoconstants which are used by every algorithm which were tested first, ρ ∈ [0, 1) and β ∈ R+.

In order to test ρ, the “Ant System” algorithm was run with values of 0.05, 0.075, 0.1, 0.125,0.15, 0.175, 0.2, 0.3 and 0.4. The mean of 12 runs was taken with colony sizes of both 5 and 60 antsand the results plotted in Figure 3.

Figure 3: A graph showing how the end solution varies with the parameter ρ.

For all tests, the final results are given as a value relative to the optimal solution. The errors arecalculated as the standard error given a poison distribution, which is the standard deviation dividedby the root of the population size. There was a lot of fluctuation, however, the best results appearedto come within the range 0.1 ≤ ρ ≤ 0.2 with the best results coming at 0.1 for 60 ants and 0.15 for5 ants.

In order to test the parameter β, as well as to try and round up this part of testing, the algorithmwas set to run with β values of 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 3.0, 4.0, 5.0 and 10.0; ρ

12

Page 13: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

values of 0.1, 0.15 and 0.2 and colony sizes of 2, 5, 10, 20, 40, 60 and 100 ants. For each of thesescenarios the average of 12 runs was taken. The tests were left to run overnight and took over 16hours to complete. Once completed, for each of the different colony sizes, graphs of β against themean final result were plotted. Each graph had three different series for the three different ρ valuesused, the best of which was used for the final graph which can been seen in Figure 4.

Figure 4: A graph showing how results vary with β.

As can be seen, the best results came from ρ = 0.15, β = 3.0 and 40 ants; it is also clear thatsetting β too low is drastically worse than setting it too high.

B Ant Colony System andMAX −MIN Ant System

ForMMAS we the pheromone level on each arc is restricted to the range τmin ≤ τij ≤ τmax.Tests were run over a range of values of τmin, and the mean of 12 results for each value was takenand plotted as a graph, as shown in Figure 5. As can be seen the optimum value of τmin wasdetermined to be 0.05.

Figure 5: A graph showing how results vary with τmin.

The Ant Colony System algorithm implements two further properties, q0 ∈ [0, 1] and χ ∈ [0, 1).Tests were run varying both these parameters and the average results for each value plotted ongraphs, as can be seen in Figure 6. The best results can be see with values q0 = 0.65 and χ = 0.11.

13

Page 14: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

Figure 6: A graph showing how results vary with q0 and χ.

C Local Search

A range of local search algorithms were tested, all of which were implemented as the elitistdaemon, except for 2-opt global which was implemented as the global daemon. The average of 12runs was taken and the results plotted in Figure 7. As can be seen, the best results came from the2.5-opt local search, with the extend variant performing marginally better.

Figure 7: A graph showing the effect of various local searches.

D Simulated Annealing and Genetic Algorithm

The final tests were to compare the ant colony algorithms with other established algorithms. Twoof the most well know, Simulated Annealing and a basic genetic algorithm were used. Using theparameters determined above, the algorithms were tested over a range of problems from TSPLIB.The problems used where burma14, att48, eil101 and pcb442. In addition to this a problem wascreated with 50 cities with randomly generated heuristic costs between vertices. The algorithmswere allowed to run for 1000 iterations or until a temperature of 10−6 was reached in the case ofSimulated Annealing. The end results relative to the optimal solution, or best known solution in thecase of rand50, have been plotted in Figure 8.

14

Page 15: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

Figure 8: A graph comparing all of the algorithms against each other.

Based purely on the end results, Simulated Annealing comes out on top with 2.5-optMMASoften coming a close second. On its own, however, this is a meaningless result. In addition to justlooking at which algorithms return the best solutions, the best results given time constraints willalso be taken into consideration. Based upon the same test runs, Figure 9 shows the best result after1 and 5 seconds. The full bars represent best result after 1 second of running times; the shadedpart of the bar represents the best result after 5 seconds. As can be seen from this, if a resultis needed quickly, the Ant Colony System algorithm with no local search yields the best results.This especially noticeable on larger graphs as after even 5 seconds on pcb442, the standard ACSalgorithm still has the best results.

Figure 9: A graph comparing all of the algorithms against each other with time constraints. The fullbar shows the best result after 1 second and the darker part of the bar shows the best result after 5seconds.

E Graph Drawing

The first thing to be looked at was the relative strengths of Hooke’s law and Coulomb’s law.This was defined by setting λ = 1.0 and defining an equilibrium extension such that keq1q2

r2= λxeq

L.

15

Page 16: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

A range of equilibrium positions were tested and the results plotted in Figure 10. As can be seenthere is not a huge amount of difference below 0.08, however, 0.05 does give the best results with areasonably low uncertainty.

Figure 10: A graph showing the final energy for various values of xeqL

After this, attention was focussed on the ant colony algorithm. Initial testing confirmed the theparameters determines for the TSP of β = 3.0 and ρ = 0.15 still gave the best results most of thetime. However, this still left the new parameter, the pheromone radius r, to be determined. This wastested with a square image size and the results plotted in Figure 11 with pheromone radius is givenrelative to the image width.

Figure 11: A graph showing the final energy for various values of the pheromone radius.

This then left the comparison of three algorithms. Each algorithm was run 5 times on problemswith 5, 16, 20 and 30 vertices and the results were plotted in Figure 12. As can be seen, with theexception of the very small 5 vertex graph, the ant colony algorithm with force–directed local searchreturns the best end results. The force–directed graph drawing algorithm comes in second, althoughby a greater margin as the graphs get larger. The basic ant colony algorithm with no local searchdoes relatively poorly.

16

Page 17: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

Figure 12: A graph showing the final energy for all three algorithm on graphs of varying size. Theant colony algorithm has been clipped in order to show the other two in more detail.

When time is considered the force–directed graph algorithm is considerable faster than the antcolony algorithms, reaching its final solution for the 20 vertex problem in an average of 0.77 secondscompared to an average of 160 seconds for the ant colony algorithm with local search, over 200times slower.

V EVALUATION

A Any Colony Algorithms

The first experiment concerned the Ant System algorithm which provides the basis for the restof the family. Initial two properties where tested, ρ and β. The initial test for the value of ρ wasjust a ball park search to get an idea of the neighbourhood. The best values were found in the range0.1 ≤ ρ ≤ 0.2. This was then taken forward to the first large scale test which tested various colonysizes, along with values of ρ and β. This test was run overnight and the results collated the followingmorning (Figure 4), giving the best result at ρ = 0.15, β = 3.0 and 40 ants. This differs slightlyfrom the expected result of ρ = 0.1, however, β was in the range 2.0 ≤ β ≤ 5.0 as expected. Whenlooking at a graph showing runs at β = 2.0 and β = 3.0. The runs at β = 2.0 find better solutionsinitially, but then flatten out after a very short period of time, whereas with β = 3.0, it is slightlyslower finding the best solutions, but it plateaus later and at a lower value. This makes sense whenwe consider what β is actually doing, a low value would result in a the pheromones being moreattractive, so more ants start following the trail sooner, resulting in the algorithm diverging soonerwith less exploration.

It is also likely the higher than expected value of ρ is a similar scenario. By evaporating thepheromones faster, they become less attractive and hence the algorithm diverges slower. OverallI would say that when working on smaller problems (up to 500 cities) on a relatively powerfulcomputer, the values found here make more more sense, however, if you were using a computerfrom the early nineties, as was the case in many of the papers, or you are trying to solve a muchlarger problem, then the slightly worse tours may be worth it for an algorithm around three times asfast.

ForMMAS the only extra property which needed determining was τmin. The upper bound isgiven by τmax = 1

ρL∗(Dorigo & Stutzle 2004, p75), however, the lower bound varies depending on

which source you read. The tests run in this research show that a low value of τmin is good, however,

17

Page 18: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

a non–zero value performs better than having no lower bound. This is in agreement with Stutzleand Hoos (2000, p902).

ACS brought with it two new parameters, q0 and χ. When testing q0 the best value came at0.65 which also appeared to be near the centre of the well. Overall though there was relatively littlevariation in the range 0.35 < q0 < 0.9 (Figure 6a). The results become poor very quickly aboveq0 = 0.9 which is surprising as Dorigo and Stutzle (2004, p96) suggest a value of q0 = 0.98 whichwould yield very poor results according to this graph.

χ was a bit less controversial with the minimum average value being found at 0.11 which agreesnicely with the value of 0.1 suggested by Dorigo and Stutzle (2004, p96).

Several local search methods were tested to see how they compared. The most common 2-optand 3-opt were implemented, along with two different implementations of 2.5-opt and a modifica-tion of 2-opt and set as the elitist daemon which runs only on the best ant. In addition to this, 2-optwas tested as the global daemon meaning it ran on the tours for every ant, not just the best ant.

Running the 2-opt daemon on every ant returned only minimal improvements on just running iton the best ant. When you consider that running it as a global daemon increases the running time bya factor of the colony size, the slight increase is very expensive. 3-opt was surprisingly poor, onlyslightly better than both the 2-opt despite being considerably more computationally expensive. Italso performed worse than 2.5-opt which was not expected. The best results came from the 2.5-optlocal search with the two implementations being very similar. In terms of speed, however, 2-optwas the best, providing the best results between 0.2 and 14 seconds or running time.

The final tests were comparing the algorithms with Simulated Annealing (SA) and a genetic al-gorithm. When looking at purely the end result, SA returned the best results on all of the problemsexcept the one generated with random costs. The genetic algorithm performed very poorly in com-parison with the ant colony algorithms and SA. Out of the ant colony algorithms, MMAS with2.5-opt local search usually gave the best results, the exceptions being the PCB routing problemwhichMMAS did very poorly on and the random data problem whereMMAS with 2-opt wasbest. There are two surprises in this data, the first being the poor performance ofMMAS on thePCB routing problem. To investigate further additional tests were run on att532 which gave similarresults, implying thatMMAS struggles with larger graph sizes.

The second surprise came from the random data. Whilst when compared with att48, the algo-rithms clearly struggle a bit more with randomly generated data, it appears that SA is effected evenworse and rand50 is the only instance where an ant colony algorithm beat SA on final result.

It is also important to note time constraints when dealing with meta-heuristics. In addition tothe final result, the best results after 1 and 5 seconds were recorded and plotted on another graph.In this case the general result was that the simpler AS algorithm gave the best results. If really fastresults are needed then Ant System with no local search initially has the best results. If there is a bitmore time or it is a simple problem then Ant System with the basic 2-opt local search gives the bestresults. As you allow more time,MMAS with 2.5-opt takes over and then with even longer timeconstraints SA becomes the best algorithm.

B Graph Drawing

In this research we set out to see if we could improve on the force–directed graph drawing al-gorithm by combining it with an ant colony algorithm. In the end the hybrid algorithm achievedresults on average 11% better than the force–directed graph drawing algorithm alone and signifi-cantly better than the ant colony algorithm alone. The end results of two runs can be seen in Figure13. The down side was the computation time, with the hybrid algorithm being 207.8 times slower.This is, however, to be expected since we are running the FDG algorithm on every iteration of theant colony algorithm.

18

Page 19: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

Figure 13: The end results of (a) the ant colony algorithm and (b) the force–directed graph drawingalgorithm.

Since this is possibly the first time that an ant colony algorithm has been used in graph drawingin this way, the algorithms are considerably less developed than they are for the travelling salesmanproblem so there is possibly a large amount of further potential in this area. One aspect which coulddo with being rethought is the way in which pheromones are stored. Ideally it would be possible todo so without having to have each pixel with its own pheromone level since having to loop througheach pixel results in the algorithm having a time complexity O (n2) with respect to the image width(assuming a constant aspect ratio). Otherwise, like the FDG algorithm, the ant colony algorithmis linear with respect to the number of iterations and O (|V |2 + |E|) with respect to the number ofvertices and arcs (edges) (Fruchterman & Reingold 1991, p1138).

VI CONCLUSIONS

In this research various properties of ant colony algorithms have been looked at. Three variationson the algorithm have been implemented, along with local search and the relevant parameters foreach of them have been confirmed.

The results obtained in this research generally agree with previous work. Slight differences canbe explained considering that the investigations here focused more on smaller graphs.

The main aim of this research was to better understand the ant colony algorithm and how it com-pares with other established algorithms and the basic conclusion which can be drawn is very well.Given a standard pc, it was able to provide very reasonable solutions to quite large problems of over100 cities in a very short amount of time. It completely outclassed the basic genetic algorithm andwas able to come very close to Simulated Annealing on final results; When strict time constraintswere applied it was often better.

An area which would be interesting to look into given more time is parallelisation. Since thereare a large number of ants running independently at once, as computers become more and moreparallel, ant colony optimization algorithms may be in the best position to make use of modernhardware such as multi-core processors and GPGPUs.

The graph drawing part of the research was a success. We have introduced a new techniquefor drawing graphs which often produces better results than the well known force–directed graphdrawing algorithm. Although significantly slower, it runs with the same time complexity so scalesin the same way to larger problems. Since the benefits increased with larger problem instances, thisalgorithm is potentially very useful for trying to render large graphs.

A potential area for development with the graph drawing algorithm is to look into redoing theway in which pheromones are stored. In addition to this, it could be worthwhile investigate whethera slightly less accurate, but faster local search algorithm, such as the grid variant force–directedgraph algorithm (Fruchterman & Reingold 1991, p1136) could produce better results by allowingfor more iterations or produce similar results in a significantly shorter time.

19

Page 20: A study of Ant Colony Algorithms and a potential ... · I INTRODUCTION A The Ant Colony Heuristics Ant Colony Optimization is a relatively recent meta heuristic, joining more established

References

Bentley, J. J. (1992), ‘Fast algorithms for geometric traveling salesman problems’, ORSA Journalon Computing 4, 387–411.

Dorigo, M., Birattari, M. & Stutzle, T. (2006), ‘Ant colony optimization’, IEEE ComputationalIntelligence Magazine 1, 28–39.

Dorigo, M. & Gambardella, L. M. (1997a), ‘Ant colonies for the traveling salesman problem’, BioSystems 43, 73–81.

Dorigo, M. & Gambardella, L. M. (1997b), ‘Ant colony system’, IEEE Transactions on Evolution-ary Computation 1, 53–66.

Dorigo, M., Maniezzo, V. & Colorni, A. (1996), ‘Ant system: Optimization by a colony of coop-erating agents’, IEEE Transactions on Systems, Man, and Cybernetics – Part B, Cybernetics26, 29–41.

Dorigo, M. & Socha, K. (2007), An introduction to ant colony optimization, in T. F. Gonzalez, ed.,‘Handbook of Approximation Algorithms and Metaheuristics’, CRC Press.URL: http://iridia.ulb.ac.be/IridiaTrSeries/IridiaTr2006-010r003.pdf

Dorigo, M. & Stutzle, T. (2004), Ant Colony Optimization, MIT Press.

Fruchterman, T. M. J. & Reingold, E. M. (1991), ‘Graph drawing by force–directed placement’,Software–Practice and Experience 21, 1129–1164.

Johnson, D. S. & McGeoch, L. A. (1997), The traveling salesman problem: A case study in localoptimization, in E. H. L. Aarts & J. K. Lenstra, eds, ‘Local Search in Combinatorial Optimiza-tion’, John Wiley and Sons, pp. 215–310.

Kamada, T. & Kawai, S. (1989), ‘An algorithm for drawing general undirected graphs’, InformationProcessing Letters 31, 7–15.

Pedemonte, M., Nesmachnow, S. & Cancela, H. (2011), ‘A survey on parallel ant colony optimiza-tion’, Applied Soft Computing 11, 5181–5197.

Reinelt, G. (1995), Tsplib 95.URL: http://comopt.ifi.uni-heidelberg.de/software/TSPLIB95/DOC.PS

Sim, S. (1996), Automatic graph drawing algorithms.URL: http://www.ics.uci.edu/ ses/papers/grafdraw.pdf

Stutzle, T. & Hoos, H. H. (2000), ‘MAX −MIN ant system’, Future Generation ComputerSystems 16, 889–914.

Young, H. D. & Freedman, R. A. (2008), University Physics with Modern Physics, Pearson Educa-tion.

20