Ant-Based Stochastic Search-and-Reset Strategy
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
In this project a colony of artificial ants searches for a target at a set distance. Though each ant follows a set of simple rules, the colony as a whole acts in a sophisticated manner.
HOW IT WORKS
Every ant starts at the origin simultaneously and walks in a random manner (this is verified by the linear output produced on the average distance from origin squared by time graph). When an ant locates the target, it returns to the nest, marking it with a pheromone. When the reset time is reached, all ants return to the nest. If they detect the pheromone, they follow the trail of the original scout to the target. Otherwise, they continue to search randomly from the origin.
The experiment aims to find the optimal reset time to reduce the total search time by "parameter sweeping" the values with the help of the BehaviourSpace extension of Netlogo.
HOW TO USE IT
Click the SETUP button to set up the ant nest (in red, at the center) and target (in green, coordinates decided by the sliders FOOD-X-COORDINATE and FOOD-Y-COORDINATE). Click the GO button to start the simulation.
The EVAPORATION-RATE slider controls the evaporation rate of the path pheromone. The DIFFUSION-RATE slider controls the diffusion rate of the pheromone.
If you want to change the number of ants, move the POPULATION slider before pressing SETUP. To change the reset time, toggle the RESET-TIME slider. To change the location of the target with respect to the origin, change the FOOD-X-COORDINATE and FOOD-Y-COORDINATE sliders.
You can monitor the average distance moved by the ants using the average distance squared by time graph and the total number of ants searching on the graph below.
ACKNOWLEDGEMENTS
This model was built as an extension of the "ANTS" model from the Netlogo models library. The code was edited and written by Ayaan Dutt, with the help of Dr Sandeep Krishna from NCBS, Bangalore.
Comments and Questions
patches-own [ chemical ;; amount of chemical on this patch food ;; amount of food on this patch (0, 1, or 2) nest? ;; true on nest patches, false elsewhere nest-scent ;; number that is higher closer to the nest food-source-number ;; number (1, 2, or 3) to identify the food sources xc ;; unwrapped xcor yc ;; unwrapped ycor dist ;; turtle distance from origin ] globals [ total-time ;; total number of ticks since initiation nest-mark ;; marks the nest ] ;;;;;;;;;;;;;;;;;;;;;;;; ;;; Setup procedures ;;; ;;;;;;;;;;;;;;;;;;;;;;;; to setup clear-all set-default-shape turtles "bug" create-turtles population [ set size 1 ;; easier to see set color red ] ;; red = not carrying food setup-patches reset-ticks end to setup-patches ask patches [ setup-nest setup-food recolor-patch ] end to setup-nest ;; patch procedure ;; set nest? variable to true inside the nest, false elsewhere set nest? (distancexy 0 0) < 1 ;; spread a nest-scent over the whole world -- stronger near the nest ;set nest-scent 200 - distancexy 0 0 end to setup-food ;; patch procedure ;; setup food source one if (distancexy food-x-coordinate food-y-coordinate) < 1 [ set food-source-number 1 ] ;; setup food source two on the lower-left ;if (distancexy (-0.6 * max-pxcor) (-0.6 * max-pycor)) < 1 ;[ set food-source-number 2 ] ;; setup food source three on the upper-left ;if (distancexy (-0.8 * max-pxcor) (0.8 * max-pycor)) < 1 ;[ set food-source-number 3 ] ;; set "food" at sources to either 1 or 2, randomly if food-source-number > 0 [ set food 1 ] end to recolor-patch ;; patch procedure ;; give color to nest and food sources ifelse nest? [ set pcolor violet ] [ ifelse food > 0 [ if food-source-number = 1 [ set pcolor green ] if food-source-number = 2 [ set pcolor green + 3 ] if food-source-number = 3 [ set pcolor green - 3 ] ] ;; scale color to show chemical concentration [ set pcolor scale-color green chemical 0.1 5 ] ] end ;;;;;;;;;;;;;;;;;;;;; ;;; Go procedures ;;; ;;;;;;;;;;;;;;;;;;;;; to go ;; forever button ifelse ticks < reset-time ;; if time is less than reset time [ ask turtles [ if food > 0;; stop tracking ants that find food [ set nest-mark 1 ;; mark nest die ] wiggle fd 1]] ;; move [ ask turtles ;; time is more than reset time [ setxy 0 0 ;; send turtles back to origin if nest-mark > 0 ;; if nest is marked, stop tracking ants [ die ]] reset-ticks ] ;; reset ticks if count turtles = 0 [stop] ;; stop when all ants have found food set total-time total-time + 1 ;; time increment tick ;diffuse chemical (diffusion-rate / 100) ;ask patches ;[ set chemical chemical * (100 - evaporation-rate) / 100 ;; slowly evaporate chemical ; recolor-patch ] end to look-for-food ;; turtle procedure if food > 0 [set nest-mark 1 die ] ;[ set color orange + 1 ;; pick up food ; rt 180 ;; and turn around ; stop ] ;; go in the direction where the chemical smell is strongest ;if (chemical >= 0.05) and (chemical < 2) ;[ uphill-chemical ] end to return-to-nest ;; turtle procedure ;; drop food and head out again ; set color red ; rt 180 ] ;[ set chemical chemical + 60 ;; drop some chemical ; uphill-nest-scent ] ;; head toward the greatest value of nest-scent end ;; sniff left and right, and go where the strongest smell is to uphill-chemical ;; turtle procedure ;let scent-ahead chemical-scent-at-angle 0 ;let scent-right chemical-scent-at-angle 45 ;let scent-left chemical-scent-at-angle -45 ;if (scent-right > scent-ahead) or (scent-left > scent-ahead) ;[ ifelse scent-right > scent-left ; [ rt 45 ] ; [ lt 45 ] ] end ;; sniff left and right, and go where the strongest smell is to uphill-nest-scent ;; turtle procedure ;let scent-ahead nest-scent-at-angle 0 ;let scent-right nest-scent-at-angle 45 ;let scent-left nest-scent-at-angle -45 ;if (scent-right > scent-ahead) or (scent-left > scent-ahead) ;[ ifelse scent-right > scent-left ; [ rt 45 ] ; [ lt 45 ] ] end to wiggle ;; turtle procedure rt random-float 360 lt random-float 360 ifelse not can-move? 1 [ hide-turtle ] [ show-turtle ] set dist xcor * xcor + ycor * ycor end to-report nest-scent-at-angle [angle] ;let p patch-right-and-ahead angle 1 ;if p = nobody [ report 0 ] ;report [nest-scent] of p end to-report chemical-scent-at-angle [angle] ;let p patch-right-and-ahead angle 1 ;if p = nobody [ report 0 ] ;report [chemical] of p end to-report replace-all [target replacement str] ;; screeshot button setup let acc str while [position target acc != false] [ set acc (replace-item (position target acc) acc replacement) ] report acc end ; Copyright 1997 Uri Wilensky. ; See Info tab for full copyright and license.
There is only one version of this model, created over 3 years ago by Ayaan Dutt.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Ant-Based Stochastic Search-and-Reset Strategy.png | preview | Preview for 'Ant-Based Stochastic Search-and-Reset Strategy' | over 3 years ago, by Ayaan Dutt | Download |
This model does not have any ancestors.
This model does not have any descendants.