Swarm Intelligence

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

Swarm Intelligence

Eden Weizman 6/17/12

Assignment P2: Create an algorithm to calculate shortest path (see Traveling Salesmans Dilemma) following the methods used by ants.

Instructions for Use Upon first opening up the program, the ToolBox will open up and the user will be asked to input the Number of Ants, Pheromone Decay Rate, and the Ant Pheromone Decay Rate. All of these values can be changed while the simulation is running.

The Number of Ant is the amount of ants in the nest. The Pheromone Decay Rate is the percentage that the pheromone already laid on the ground will evaporate by each turn. The Ant Pheromone Decay Rate is the percentage the pheromone that each ant caries will be depleted by each turn. After these three initial values have been set, the space the ants will be moving around in and searching for food will pop up. This will initially be completely empty. The user must then click anywhere he wants in the space to place the nest, which will be indicated by a square with a black outline. The number of ants in each vertex will be displayed right above it.

After placing the nest, the toolbox will change to allow you to add vertices, food sources, and edges, remove edges, and change the size of food sources.

Vertices can be added by clicking when Add Vertex is selected. They are displayed as black hollow circles. Food Sources can be added by clicking when Add Food Source is selected, or by right clicking. They are displayed as red hollow circles. Edges can be added by clicking and dragging across two vertices while Add Edge is selected, or by clicking and dragging when shift is held down. One directional arrows can be added as well, by selecting that, or by holding alt as well as shift when clicking and dragging. Edges change color based on how much food pheromone they have. Warm colors like red, orange, and yellow signify more pheromone. Green is the middle. Blue signifies the least amount. Food Sources can change sizes when Change Food Source Size is selected, and by clicking food sources. Have fun experimenting! Algorithm Notes

In the beginning, I assumed that the same pheromone would be good enough to find the way to the food and back to the nest. However, after experimenting, the ants got caught in a loop around the food, and were unable to go back to the nest, thus making it difficult to see the shortest path. The ants needed to have some sort of goal, or else they would have a higher probability of going back the way they came, being attracted to their own pheromones. To solve this problem, I created two different types of pheromones; Normal and Food. They decay in the same way. However, an ant who has just come from the nest will only base his decisions on food pheromone and release normal pheromone, and an ant who has just found food will only base his decisions on normal pheromone and release food pheromone. Data I began with a very simple graph, with one obvious shorter path.

These were my defaults:

With this control setup, it took 4 rounds for the shortest path to become clear:

And about 70 to become entire stable, so that the left path was entirely blue consistently. Conclusions drawn in the first few trials can only so far be assumed to be applicable to this configuration. Trial 1 The number of ants was lowered to 10. In this case the shortest path was much less clear. It took at least 20 rounds for the path to become clear, and at least 1000 to stabilize, although it was still not as stable as the control.

The shortest path clearly the most used, but one path remains well used.

Conclusion: the more ants, the better. They will follow the percentages more, and there will be less randomness controlling the paths. Trial 2 Pheromone decay rate was raised to 0.1. Took 4 turns for the shortest path to become clear. Took 50 for the path to stabilize.

0.1 is superior to 0.01.

Trial 3 Pheromone decay rate was raised to 0.5 The shortest path did appear in 4 turns, but much less clearly than before. This is because there was less pheromone on the path traveled to get to the food source, and thus the ants were more likely to pick a path they had not traveled yet.

Took about 900 turns to stabilize, but not as stable as the control.

0.5 is too high to be an efficient pheromone level. Trial 4 Ant pheromone decay is raised to 0.1. Shortest path was clear after 4 turns. Shortest path was very stable after 4 turns. Trial 5 Ant pheromone decay is raised to 0.5. Shortest path was clear after 4 turns.

Shortest path was incredibly stable after 4 turns.

0.5 is superior to 0.1.

Trial 6

A was used with the control parameters, and run until stable. Then another, closer, food source was introduced. The ants took on average 7000 turns to fully adjust to the change in the graph.

Trial 7 Same as trial 6, but parameters were adjusted to those found to be optimal in the first few trials.

The ants adjusted much faster, taking only about 20 turns to all use the new food source.

Trial 8 Two food sources were introduced, one large and the other small, both the same distance from the nest. The ants took around 30 turns to only go to the large one.

After the ants became accustomed to the paths, the two food sources were switched. The one that had previously been small became large, and the one that had been large became small. The ants took about 700 turns to adjust to the change.

Trial 9 Control parameters were used. Ants were introduced to a food source with a short path and a long path leading to it. It took them about 20 turns to adjust.

The short path was removed, blocked by some obstacle. It took them 500 turns to fully adjust to the long path.

Trial 10 A more complicated graph is used, with the control parameters, except the number of ants is increased for the bigger graph size (valid from results of trial 1)

After 60 trials, the shortest path is not yet clear, though beginning to be.

After 1000 trials, the path is mostly stable, with most ants using the shortest path, but still use the other paths as well. Much less frequently, but still used.

Trial 11 The same complicated graph is used, with the parameters that were most successful in the first 5 trials.

After 60 trials, it was clear that many more ants were using the shortest path.

This was very successful. A much higher number of ants decided to take the shortest path. This was more successful than Trial 10. What held for a simpler graph held true for a more complex graph as well.

You might also like