Anda di halaman 1dari 8

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.

Author Ramachandra Kousik A.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. It is
further possible to determine which of these has a larger weight by
tweaking with the and parameters. Once a tour has been
completed (i.e. each city has been visited exactly once by the ant),
pheromone evaporation the edges is calculated. Then each ant deposits
pheromone on the complete tour by a quantity which is calculated
from the following formula (Dorigo 1991):

if

, where:

multiplies the pheromone concentration on the edge


between cities i and j by p(RHO), where its value can be set
between 0 and 1. 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, as defined by which is the length of the tour created by
this ant. Intuitively, short tours will result in higher levels of
pheromone deposited on the edges.

Author Ramachandra Kousik A.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.
About the view -:
Each view is divided into two horizontal sections.
1. The top half shows a graphical view of the current performance of
each algorithm.
2. The bottom half shows a graph of the current solution charted
against the best know solution. In most demonstrations of the
TSP, cities are placed at random. All the cities are distributed in a
circular fashion. This allows an easy way to calculate the shortest
path among the cities, as well as visually assess how far away the
algorithm is from the optimal solution.
About the Control Buttons -:
Each button is self-explanatory. The Start button is used to start the
application and the Stop button is used to stop the simulation. The
Reset button resets the simulation while the Step button is used to step
through the simulation. The text information shows the following
information:
Example Epoch 19, Best So Far = 212.3, Best Possible 100, Elapsed Time =
35(ms)
Epoch represents the number of times the simulation has run through
each cycle of the simulation.
Best So Far is the shortest tour so far.

Author Ramachandra Kousik A.S


Roll Number MT2009002

Best Possible represents the optimal solution to the current tour.


Elapsed Time is the time spent inside the algorithm. This excludes the
time spent "drawing" the solution to the screen.
Implementation Classes and Details
1.

CMemDC is a class used for double buffering. This is a technique


used in computer animation to avoid screen flicker, which was a
major problem due to the fact that the screen is updated
(repainted) several times each second. The technique used here is
to create an off-screen buffer to which the image is drawn. The
final image is then copied to the screen.

2.

CAutoFont is a class used for font manipulation.

3.

CChart is a class used for charting.

4.

CPerfTimer is used for timing.

5.

CSideBannerWnd is used to display the panel on the left-hand side


of the window.

AIDemo.vcproj
This is the main project file for VC++ projects generated using an
application wizard.
It contains information about the version of Visual C++ that
generated the file, and information about the platforms, configurations,
and project features selected with the application wizard.

Author Ramachandra Kousik A.S


Roll Number MT2009002

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

Author Ramachandra Kousik A.S


Roll Number MT2009002

For the main frame window:


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

Author Ramachandra Kousik A.S


Roll Number MT2009002

REFERENCES, EXTERNAL SOURCES AND REQUIRED


MODIFICATIONS-:
Ant Colony Optimization is not implemented directly. Help has been
taken from already existing source code for Genetic Algorithms, based
on the work of Mat Buckland in his book "AI Techniques for Game
Programming." (The design part of the implementation) and the
implementation for ACO is clubbed with GA implementation thats
already existent, for the sake to not disturb the originality and to
observe the differences between both the algorithms. (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, besides, I adopted already
existent GA implementation style)
The probabilistic formulation for the ACO algorithm is observed and
read, basing the works of partially M Jones in his book "AI Application
Programming."
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. This underlying assumption helps to find
the gap between practical implementation of the code and the
theoretical value, which could be further modified or generalized.
Also used, Peter Kohouts, Applications of AI notes to define the
convergence rules (The graph implementation has been inherited from
here)

Author Ramachandra Kousik A.S


Roll Number MT2009002

Other references include,


Programming windows with MFC and Microsoft msdn.
And classes like CPerfTimer, FlickerFreeDrawing, AutoFontHandling etc
are taken from various online classes and are extended in this
implementation

Anda mungkin juga menyukai