Ants Algorithm

Download Report

Transcript Ants Algorithm

Swarm Intelligence
Part 1
Ants Algorithm
‫‪BIONICS‬‬
‫•‬
‫•‬
‫طبيعت منبع الهام و الگو گرفتن برای بسياری از تحقيقات و‬
‫پيشرفت های علمی بوده است‬
‫به عنوان مثال‪:‬‬
‫– الگوريتم های ژنتيک ‪Genetic Algorithms‬‬
‫– شبکه های عصبی ‪Neural Networks‬‬
‫– سيستم های خودسازمان ده ‪Self-organizing Systems‬‬
‫•‬
‫•‬
‫گروهی از اين موارد بر اساس رفتار برخی از حشرات مثل‬
‫مورچه ها و زنبور عسل که رفتار اجتماعی دارند بوده است‬
‫در زمينه شبکه بر اين اساس الگوريتم های قدرتمندی برای‬
‫کاربردهايی مثل مسيريابی و توزيع بار طراحی شده اند‬
‫‪BIONICS: Application of biological‬‬
‫‪principles to the study and design of‬‬
‫‪engineering systems.‬‬
‫•‬
Swarm Intelligence
“any attempt to design algorithms or distributed problemsolving devices inspired by the collective behavior of social
insect colonies and other animal societies”
[Bonabeau, Dorigo, Theraulaz: Swarm Intelligence, p. 7]
‫مدل سازی و طراحی الگوريتم‬
‫مورچه ها ‪Ants‬‬
‫•‬
‫•‬
‫مورچه ها يکی از شگفت انگيزترين موجودات عالم هستند‪.‬‬
‫مورچه ها به صورت گروهی فعاليت های پيچيده ای را انجام می‬
‫دهند‪:‬‬
‫–‬
‫–‬
‫–‬
‫–‬
‫–‬
‫–‬
‫–‬
‫–‬
‫–‬
‫کشف و انتقال غذا در حجم کم يا زياد‬
‫ذخيره سازی غذا‬
‫النه سازی پيچيده‬
‫تميزکاری النه‬
‫محافظت از تخم ها‬
‫تشکيل پل برای عبور از آب‬
‫کشاورزی‬
‫گله داری‬
‫‪.........‬‬
‫ويژگی مشترک‬
‫•‬
‫•‬
‫•‬
‫تک تک مورچه ها حرکاتی ساده و بعضا بدون نظم خاص انجام‬
‫می دهند‬
‫اما در مجموع از برآيند حرکات آنها نظمی خاص وگاها بسيار‬
‫پيچيده پديد می آيد‪.‬‬
‫هيچ نوع هدايت و رهبری در اين امر دخالت ندارد‪.‬‬
‫‪Emergence‬‬
‫‪Unique global behavior arising from the interaction of many agents‬‬
‫رفتار کلی که از برآيند تعامل تعداد زيادی از عوامل جزء پديد می آيد‬
‫• ‪ Emergence‬وقتی اتفاق می افتد که تعدادی عوامل ساده مرتبط با هم به‬
‫گونه ای هماهنگ عمل می کنند که منجر به رفتار هوشمند پيچيده ای می شود‪.‬‬
‫• اين يک فرايند از پايين به باال است‪ Emergence :‬از متن جمعيت عوامل‬
‫شروع می شود و هيچگونه رهبری و مديريتی در آن صورت نمی گيرد‪.‬‬
‫‪Emergence‬‬
‫‪Unique global behavior arising from the interaction of many agents‬‬
‫رفتار کلی که از برآيند تعامل تعداد زيادی از عوامل جزء پديد می آيد‬
‫• ‪ Emergence‬در سيستم های متعددی اتفاق می افتد‪ :‬زندگی جمعی حيوانات‬
‫و خاصا بعضی از حشرات‪ ،‬مغز انسان‪ ،‬سيستم دفاعی بدن انسان‪،‬رفتارهای‬
‫اجتماعی انسان ها‪ ،‬سيتم شهرسازی و زندگی شهری انسان و‪.....‬‬
‫• در هر يک از اين سيستم ها عوامل موجود در يک سطح منجر به بروز رفتار‬
‫يا ويژگی در سطح باالتر می شوند‪.‬‬
‫‪"EMERGENCE The connected lives of ants, brains, cities, and software" by Steven Johnson‬‬
‫رفتار مورچه ها‬
‫• هر مورچه الگوريتم ساده ای را اجرا می کند‬
‫• الگوريتم بسيار پيچيده تری بر اثر مجموعه رفتارهای‬
‫مورچه ها اجرا می شود‬
‫‪Swarm Intelligence‬‬
‫• ‪ Swarm Intelligence‬يا هوش جمعی تعامل جزئی‬
‫تعداد زيادی عوامل ساده برای حصول يک هدف کلی است‬
‫• خصوصيات هوش جمعی عبارتند از‪:‬‬
‫– عوامل ساده اند‬
‫– عوامل به صورت غيرمستقيم با هم ارتباط برقرار می کنند‬
‫– رفتار کلی پيچيده از رفتارهای جزئی ساده عوامل حاصل می‬
‫شود‬
‫– اين رفتارها پايدارند‬
‫– تک تک عوامل در حصول نتيجه کلی بی تاثيرند‬
‫مثال‪ :‬تميزکاری النه مورچه ها‬
‫• مورچه ها آشغال ها ويا غذای پراکنده درسطح النه را جمع آوری و‬
‫در يک يا چند جا کپه می کنند‬
‫• اين کار به اين ترتيب عملی می شود‪:‬‬
‫–‬
‫–‬
‫–‬
‫–‬
‫–‬
‫–‬
‫هر مورچه شروع به گردش به صورت دلخواه و بی هدف در سطح النه‬
‫می کند‬
‫اگر مورچه به يک تکه آشغال برخورد کرد آن را بر می دارد‬
‫مورچه به گردش تصادفی خود ادامه می دهد‬
‫اگر مورچه به يک تکه آشغال ديگررسيد تکه قبلی را در کنار آن قرار می‬
‫دهد‬
‫و باز به گردش خود ادامه می دهد‬
‫بعد از مدتی مشاهده می شود که آشغال ها در گوشه کنار النه کپه شده اند‪.‬‬
Ant Colony Optimization
• Marco Dorigo is research
director of the IRIDIA lab at the
Université Libre de Bruxelles
• Inspired by the remarkable
ability of social insects to solve
problems, Dorigo and Stützle
introduce new technological
design principles for seeking
optimized solutions to
difficult real-world problems,
such as network routing and
task scheduling.
‫‪Ant Colony Optimization‬‬
‫• ‪ Ant Colony Optimization‬از قابليت‬
‫مورچه ها برای پيدا کردن مسيرهای کوتاه‬
‫يا کوتاه ترين مسيرها برای مسيريابی در‬
‫شبکه استفاده می کند‬
‫مورچه ها چگونه می توانند‬
‫کوتاه ترين مسير را پيدا کنند ؟‬
‫چگونه مورچه ها ارتباط برقرار می کنند‬
‫•‬
‫•‬
‫•‬
‫•‬
‫•‬
‫مورچه ها توانايی ديدن و شنيدن را ندارند و فقط از حس‬
‫بويايی استفاده می کنند‬
‫مورچه ها صدا نيز ندارند‬
‫به اين ترتيب مورچه ها نمی توانند با صدا و شنيدن با هم‬
‫ارتباط ايجاد کنند‬
‫ولی با استفاده از حس بويايی می توانند اطالعات را منتقل‬
‫کنند‬
‫اين نوع ارتباط را ”‪ “stigmergy‬می گويند‪:‬‬
‫–‬
‫–‬
‫–‬
‫–‬
‫مورچه ها از خود موادی را به جا می گذارند که بوی خاصی دارند‬
‫به اين مواد ‪ pheromone‬گفته می شود‬
‫مورچه ها ‪ pheromone‬به جا مانده از ساير مورچه ها را حس‬
‫می کنند‬
‫عالوه براين مورچه ها شدت بوی ‪ pheromone‬را نيز تشخيص‬
‫می دهند‬
The Shortest Path (1)
Nest
•
•
•
•
•
Food
Two ants start their random walk
They both eventually find the food
The one taking the shorter path finds the food first
Each ant leaves a trail of pheromones behind
Once taken the food the ants follow their pheromone trail
towards the nest
The Shortest Path (2)
Nest
Food
• The one taken the shorter path returns first and arrives
back to the nest first
The Shortest Path (3)
Nest
Food
• Now a third ants wants to search for food
• The ant realizes the trials left behind by its predecessors
• Most likely it follows one of the existing trials rather than
initiating a new trial
• Most likely it follows the trial with the higher density of
pheromones
The Shortest Path (4)
Nest
Food
• This results in even denser pheromone trial on the shorter
path
• In long term this results in most ants using the shortest
path
‫‪Simple Stochastic Algorithm‬‬
‫• وقتی يک مورچه شروع به حرکت می‬
‫کند‪:‬‬
‫– با احتمال کوچکی يک مسير جديد را شروع‬
‫می کند‪.‬‬
‫– با احتمال بيشتری يکی از مسيرهای موجود‬
‫دارای ‪ pheromone‬را انتخاب می کند‪.‬‬
‫– ولی در انتخاب مسيرهای موجود هر چه‬
‫شدت ‪ pheromone‬يک مسيربيشتر باشد‬
‫احتمال انتخاب آن نيز باالتر خواهد بود‪.‬‬
‫چرا مسيرهای تازه؟‬
‫• مورچه های قبلی الزاما کوتاه ترين‬
‫مسيررا انتخاب نکرده اند‬
‫• انتخاب مسيرهای جديد می تواند منجر به‬
‫يافتن مسيرهای کوتاه تر بشود‬
‫• در نهايت اين منتهی به يافتن کوتاه ترين‬
‫مسير می شود‬
‫تبخير و محو تدريجی ‪pheromone‬‬
‫• ‪ Pheromone‬به تدريج تبخير می شود‪.‬‬
‫• اين يکی از ضروريات پويا بودن الگوريتم است‪.‬‬
‫• انتقال از مسيرهای کوتاه به مسيرهای کوتاه تر بدون تبخير‬
‫‪ pheromone‬در مسيرهای قديمی امکان پذير نخواهد بود‪.‬‬
‫الگوريتم وفقی‬
‫• الگوريتم به صورت وفقی عمل می کند‪.‬‬
‫• علت اين امر احتمال شروع مسيرهای تازه و تبخير تدريجی در‬
‫مسيرهای قبلی است‪.‬‬
‫مقابله با خرابی و تغييرات مسير‬
‫•‬
‫•‬
‫•‬
‫الگوريتم به دليل رفتار پويا و وفقی می تواند در‬
‫صورت وقوع خرابی در مسير با يافتن مسير‬
‫جايگزين با آن مقابله کند‪.‬‬
‫همچنين اگر تغيير در مسير ايجاد شود الگوريتم‬
‫خود را با تغييرات هماهنگ می کند‪.‬‬
‫برای مثال اگر سنگی در مسير مورچه ها قرار‬
‫داده شود مورچه ها آن را دور زده و مسير کوتاه‬
‫جديدی را در کنار آن پيدا می کنند‪.‬‬
‫‪*Disclaimer: May not work with a cube of ice‬‬
‫اثر جانبی‬
‫• مورچه ها در بين غذاهای موجود در محيط اطراف النه‬
‫ابتدا نزديک ترين آنها را منتقل می کنند‪.‬‬
‫• اين يک اثر جانبی الگوريتم است‬
‫• اين پديده می تواند کاربردهای زيادی داشته باشد‬
StarLogo
•
•
•
•
•
http://education.mit.edu/starlogo/
StarLogo is a programmable
modeling environment for exploring
the behaviors of decentralized
systems, such as ant colonies.
In decentralized systems, orderly
patterns can arise without centralized
control.
Increasingly, researchers are
choosing decentralized models for
the organizations and technologies
that they construct in the world, and
for the theories that they construct
about the world.
StarLogo visualizes the behavior of
the decentralized system
StarLogo
•
•
•
•
•
•
•
•
StarLogo consists of graphic turtles and an environment
The behavior of the turtles can be programmed
All turtles run the same program in parallel
A turtle can represent almost any type of object: an ant in a colony, a car in a
traffic jam, an antibody in an immune system, a molecule in a gas
Also the effect of the environment on turtles can be programmed
You can write programs for thousands of "patches" that make up the turtles'
environment.
Turtles and patches can interact with one another
Turtles can be programmed to "sniff" around the environment, and change
their behaviors based on what they sense in the patches
Modeling the Ants Behavior
DEMO
Don’t go away
We will continue after the demo
Part 2
Ants in Networks
History
•ABC routing (Schoonderwoerd et al., 96)
•Regular and Uniform ant routing
(Subramanian et al., 97)
•Antnet (Dorigo et al., 98)
•Antnet++ (Dorigo et al., 02)
•Improved Antnet (Boyan et al., 02)
•Modified Antnet (Tekiner et al., 04)
•Antnet with evaporation (Tekiner et al., 04)
•Ants algorithm with QoS (Carrillo et al., 04)
What Are Ants
• Ants are emulated by mobile agents
• Mobile agents are carried by packets
• Especial packets can be used as mobile agents
(ants)
initialize_ant ()
while (current_state  target_state)
A = read_local_pheromone-table()
P = compute_transition_probabilities (A, M, problem_constraints)
next_state = apply_ant_decision_policy (P, problem_constraints)
move_to_next_state (next_state)
if (step-by-step_pheromone_update)
update_pheromone_table() // deposit pheromone on visited arc
update_ant_memory()
if (delayed_pheromone_update)
evaluate_solution()
update_pheromone_tables() // deposit pheromone on ALL visited arcs
die()
What About Pheromones?
• Pheromones pass the information about
the length of the path (time) to other ants
– The agents can pass the same information to
data packets at the nodes
• Ants decide based on the density of the
pheromones and some probability values
– The probability values can be calculated
based on the path information and listed in
routing tables in the nodes
AntNet
• First application of ants algorithm for routing in
(datagram) packet networks
• Ants are sent between source-destination pairs
to create a test and feedback signal system
• Ants discover and maintain routes
– Inter-node trip times are used to adjust next-hop
probabilities
• Packets are forwarded based on next-hop
probabilities
Routing Table
• Start with a static routing table for each node.
• Each routing table stores the probabilities of using the
next hops to reach all possible destinations
– Sum of probabilities at each row equals one
Ports (Neighboring Nodes)
Destinations
Port/ N1
dest
1
P11
N2
…
Nn
P12
…
P1n
2
P21
P22
…
P2n
3
P31
P32
…
P3n
Routing Table Updates
• To create a dynamic routing table, create
“ants” as agents that will go back and forth
to random destinations.
• These ants will then update the
probabilities in the routing table.
• Packets will be transferred to paths based
on the probabilities listed in the routing
table
The Agents
• Two types of agents (ants):
– Forward Ants (to collect information)
– Backward Ants (to update probability
table)
•
Out[ ]
Buffer
Port1
FIFO1
Schedule
r
FIFO2
Two types of queues:
– Low priority queue (data packets and
forward ants)
– High priority queue (backward ants)
Port2
FIFO1
Schedule
r
FIFO2
• Forward ants are routed at the same
priority as data packets
– Forward Ants experience the same
congestion and delay as data
• Backward ants are routed with higher
priority than other packets
Port N
FIFO1
FIFO2
Schedule
r
Forward Ants
• At regular intervals every node creates a forward ant to
randomly selected destinations.
– Destinations are selected to match current traffic patterns
– Forward ant uses probabilistic routing tables at every intermediate
node to choose output port from unvisited list of nodes.
• Elapsed time and node identifier is pushed to ant’s stack.
• If a cycle is detected , cycle is deleted from ant’s memory.
• When a forward ant reaches to its destination It
transforms itself to a backward ant
Backward Ants
• A backward ant visits the list of the nodes
in its stack in a reverse order,
• Updates corresponding entries in the
routing tables and array on its way back to
source by using its values stored on its
stack.
Example
Statistics
• Except for the routing table, each node also keeps a
table with records of the mean and variance of the trip
time to every destination
• At each node, backward ants update the trip time
statistics to the destination in addition to the next-hop
probability
N1
Stat1
N2
Stat2
…
…
Nn
Statn
Routing Table Updates
• Reinforcement Factor (Based on the trip time
and the statistics)
r = f (1 - Wbest/T) + g (mean,var)
0 < r < 1,
• Increase the probability of the channel that
backward ant comes from
P’ = P + r * (1 - P) = P * (1 – r) + r
• Decrease the probability of the other channels
P’ = P * (1 - r)
Data Packets
• Data packets are routed using the next-hop
probabilities
• The packets are distributed over the paths
proportional to their probabilities
• A probability threshold level can be used to
avoid selection of not-so-good paths
• Achieve some degree of load balancing over all
existing good paths
Performance
• AntNet reports better performance in
terms of:
–
–
–
–
Delay
Throughput
Robustness
Reaction to changes
• Traffic overhead is higher than OSPF
Variations
• Different varieties of the antnet routing
algorithm will be resulted depending on
the:
– Forward ant routing mechanism
– Routing table update mechanism
– Packet forwarding criterion
Router Architecture
Forward_ANT
Data Packet
Lookup and
forwarding
P\N
1
2
…
3
Backward_ANT
N1
P11
P21
…
P31
N2
P12
P22
…
P32
…
…
…
…
…
Updating
N3
P13
P23
…
P33
Out[ ]
Buffer
Port1
FIFO1
Schedule
r
FIFO2
Port2
FIFO1
Schedule
r
FIFO2
Port N
FIFO1
FIFO2
Schedule
r
Evaporation
• Link usage statistics are used to evaporate
the pheromone laid by the ants.
• It is the proportion of number of forward
ants destined to the node x over the total
ants received by the current node in the
given time window.
• By evaporating the links probabilities in a
predefined rate, average delay
experienced per packet is reduced
“Improved antnet routing algorithm with link probability evaporation”
F. Tekiner, F. Z. Gassemlooy, and S. Al-Khayatt
Congestion
•
•
•
•
Agents are delayed if congestion occurs
Has the same effect of a longer path
Pheromones evaporate more
Less pheromone if agent is delayed more
Quality of Service
• M-Class ants are used for M-class type of
services
• Probabilities in the routing table represent the
probability that packets can reach the required
level of QoS
• The probabilities are updated based on the
delay statistics per QoS class and the available
bandwidth
• Considering other QoS parameters, such as
availability etc., can be studied
“A Quality of Service Routing Scheme for Packet Switched Networks based on Ant Colony Behavior ”
Liliana Carrillo and J.L. Marzo
Security Issues
• Threats
– Untrustworthy hosts
• Forward data/ant packets to a wrong direction
• Delay data packets
• Generate bursts of ant packets
– Malicious Agents
• Carry false trip time information
• Attack Goals
– Increase the packet latency
• Mislead packets to a longer path
– Break down a critical node
• Mislead packets to a certain node to overload it
– Drop Data Packets
• Mislead packets to a malicious node
“Security Issues in Ant Routing”
Weilin Zhong
Conclusion
• Application of swarm intelligence in
network routing problems
• Inspired by the stigmergy model in ant
colonies
• Using mobile multi-agent systems
• A distributed adaptive routing algorithm
• Autonomous
THE END