Author – Ramachandra Kousik A.

S
Roll Number – MT2009002

ANT COLONY OPTIMIZATION – PROCEDURE AND NOTES
Theory -:
This algorithm is inspired by observation of real ants. Individually, each
ant is blind, frail and almost insignificant. Yet, by being able to cooperate with each other, the colony of ants demonstrates complex
behavior. One of these is the ability to find the closest route to a food
source or some other interesting landmark. This is done by laying down
special chemicals called "pheromones." As more ants use a particular
trail, the pheromone concentration on it increases, hence attracting
more ants. In our example, an artificial ant is placed randomly in each
city and, during each iteration, chooses the next city to go to. This
choice is governed by the following formula. (References cited at the
end of the document)
Each ant located at city i hops to a city j selected among the cities that
have not yet been visited according to the probability:

is the probability that ant k in city i will go to city j.

is the set of cities that have not yet been visited by ant k in

city i.

is the relative importance of the pheromone trail.

is the relative importance of the distance between cities.

short tours will result in higher levels of pheromone deposited on the edges.e. It is further possible to determine which of these has a larger weight by tweaking with the and parameters. Then each ant deposits pheromone on the complete tour by a quantity which is calculated from the following formula (Dorigo 1991): if . where it’s value can be set between 0 and 1.S Roll Number – MT2009002 Therefore the probability that a city is chosen is a function of how close the city is and how much pheromone already exists on that trail. where: • multiplies the pheromone concentration on the edge between cities i and j by p(RHO). Intuitively. as defined by which is the length of the tour created by this ant.Author – Ramachandra Kousik A. Once a tour has been completed (i. each city has been visited exactly once by the ant). The pheromone evaporates more rapidly for lower values. (Rho – Sort of an evaporation constant) • is the amount of pheromone an ant k deposits on an edge. pheromone evaporation the edges is calculated. .

as well as visually assess how far away the algorithm is from the optimal solution. Best Possible – 100. . About the Control Buttons -: Each button is self-explanatory. 1. The text information shows the following information: Example Epoch – 19.3. About the view -: Each view is divided into two horizontal sections. In most demonstrations of the TSP. Elapsed Time = 35(ms) Epoch represents the number of times the simulation has run through each cycle of the simulation. This allows an easy way to calculate the shortest path among the cities.S Roll Number – MT2009002 This file contains a summary of what you will find in each of the files that make up the AIDemo application. cities are placed at random. The Reset button resets the simulation while the Step button is used to step through the simulation. The bottom half shows a graph of the current solution charted against the best know solution. Best So Far is the shortest tour so far. The Start button is used to start the application and the Stop button is used to stop the simulation. Best So Far = 212. All the cities are distributed in a circular fashion.Author – Ramachandra Kousik A. 2. The top half shows a graphical view of the current performance of each algorithm.

Implementation Classes and Details – 1. . CSideBannerWnd is used to display the panel on the left-hand side of the window. CPerfTimer is used for timing. which was a major problem due to the fact that the screen is updated (repainted) several times each second.Author – Ramachandra Kousik A. 2. CAutoFont is a class used for font manipulation.S Roll Number – MT2009002 Best Possible represents the optimal solution to the current tour. configurations.vcproj This is the main project file for VC++ projects generated using an application wizard. The technique used here is to create an off-screen buffer to which the image is drawn. CMemDC is a class used for double buffering. 5. Elapsed Time is the time spent inside the algorithm. 3. It contains information about the version of Visual C++ that generated the file. The final image is then copied to the screen. This is a technique used in computer animation to avoid screen flicker. 4. and project features selected with the application wizard. and information about the platforms. CChart is a class used for charting. This excludes the time spent "drawing" the solution to the screen. AIDemo.

which is used as the application's icon.Author – Ramachandra Kousik A. This icon is included by the main resource file ButtonDemo. res\AIDemo.S Roll Number – MT2009002 AIDemo.h) and declares the CAIApplication application class. It includes other project specific headers (including Resource. and cursors that are stored in the ‘resource’ subdirectory. AIDemo. It includes the icons.cpp This is the main application source file that contains the application class CAIApplication. /////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// . AIDemo. res\AIDemo. bitmaps.rc2 This file contains resources that are not edited by Microsoft Visual C++.ico This is an icon file.h This is the main header file for the application.rc.rc This is a listing of all of the Microsoft Windows resources that the program uses.

This bitmap file is used to create tiled images for the toolbar. which is derived from CFrameWnd and controls all SDI frame features. 2. The initial toolbar and status bar are constructed in the CMainFrame class. AIDoc. MainFrm.h. res\Toolbar. AIView.cpp .S Roll Number – MT2009002 For the main frame window: The project includes a standard MFC interface. /////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// The application wizard creates one document type and one view: AIDoc. Edit these files to add special document data and to implement file saving and loading (via CAIDoc::Serialize). 3.h. Edit this toolbar bitmap using the resource editor.h. AIView.cpp .the view of the document These files contain CGAView class.rc to add toolbar buttons. and update the IDR_MAINFRAME TOOLBAR array in ButtonDemo.bmp 1. CGAView objects are used to view CAIDoc objects. .Author – Ramachandra Kousik A. MainFrm.cpp These files contain the frame class CMainFrame.the document These files contain CAIDoc class.

Applications of AI notes to define the convergence rules (The graph implementation has been inherited from here) . besides. This underlying assumption helps to find the gap between practical implementation of the code and the theoretical value. based on the work of Mat Buckland in his book "AI Techniques for Game Programming. Peter Kohout’s. (Notes about ACO are lone presented in this document but not GA for I have defined the state rules and circular transitions and graphics only for ACO but no concrete idea about the GA implementation. for the sake to not disturb the originality and to observe the differences between both the algorithms. EXTERNAL SOURCES AND REQUIRED MODIFICATIONS-: Ant Colony Optimization is not implemented directly. which could be further modified or generalized." (The design part of the implementation) and the implementation for ACO is clubbed with GA implementation that’s already existent. basing the works of partially M Jones in his book "AI Application Programming. Help has been taken from already existing source code for Genetic Algorithms. Also used.S Roll Number – MT2009002 REFERENCES.Author – Ramachandra Kousik A. I adopted already existent GA implementation style) The probabilistic formulation for the ACO algorithm is observed and read." The state rules defined for ACO here work under an assumption that the distance between any two adjacent cities is the same and are arranged in circular fashion.

And classes like CPerfTimer.S Roll Number – MT2009002 Other references include. FlickerFreeDrawing. Programming windows with MFC and Microsoft msdn. AutoFontHandling etc are taken from various online classes and are extended in this implementation .Author – Ramachandra Kousik A.