globals [clock totfood foodlast foodrate ifood ifoodlast ifoodrate radius xc yc] turtles-own [ age carrying-food? drop-size active? ] patches-own [ chemical food nest? nest-scent ] ;;;;;;;;;;;;;;;;;;;;;;;; ;;; Setup Procedures ;;; ;;;;;;;;;;;;;;;;;;;;;;;; to setup ;; (for this model to work with NetLogo's new plotting features, ;; __clear-all-and-reset-ticks should be replaced with clear-all at ;; the beginning of your setup procedure and reset-ticks at the end ;; of the procedure.) __clear-all-and-reset-ticks setup-turtles setup-patches set clock 0 set totfood 0 set foodlast 0 set foodrate 0 set ifood 0 set ifoodlast 0 set ifoodrate 0 set radius 0.7 ;set-plot-y-range 0 100 ;set-plot-x-range 0 100 ;set-plot-xlabel "violet-lifetime__red-productivity" ;type "|ver 6,vap,diff,delay,spin,spd-up,epi | " ;type evaporation-rate type "|, | " ;type diffusion-rate type "|, | " ;type delay type "|, | " ;type spin-rate type "|, | " ;type speed-up type "|, | " ;print epicycle ;print "|time,totfood,foodrate,ifood,ifoodrate,ave age,frac cycling,frac food of cycl, social efficacy| " ifelse not graphics? [ no-display stop] [display] do-plotting end to setup-turtles crt agents [ ; set size 2.0 setxy 0 0 rt random 360 set color sky set carrying-food? false set active? false set age 0 ] end to setup-patches ask patches [ set chemical 0 set food 0 setup-nest setup-food update-display ] end to setup-nest ;;Patch Procedure ;; set nest? variable to TRUE inside the nest set nest? ((distancexy 0 0) < 5) ;; spread a nest-scent over the whole screen -- stronger near the nest set nest-scent (200 - (distancexy 0 0)) end to setup-food ;;Patch Procedure set food 0 if ( distancexy 0 ( -0.7 * max-pxcor ) ) < 5 [ set food 3 ] end to update-display ;;Patch Procedure ;; give color to nest and food sources ifelse nest? [set pcolor sky] [ifelse food > 0 [set pcolor red ] [set pcolor scale-color green chemical 0.0 4 ] ] end ;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Runtime Procedures ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;; to go ;;Forever Button ask turtles [ go-turtles ] diffuse chemical (diffusion-rate / 100) move-source ask patches [ go-patches ] set clock (clock + 1) ifelse graphics? [display] [ no-display] do-plotting end to go-turtles ;;Turtle Procedure if (who < clock) [ if active? [set color 117 ; instead of violet 115 set age age + 0.1 ; if age > maxnum - 1.0 [setage maxnum] ] ifelse carrying-food? [set color pink return-to-nest] [if not active? [set color cyan] look-for-food] ] end to move-source let omega 0 let angle 0 ifelse ( clock < delay or spin-rate = 0 ) [ set xc 0.0 set yc -0.7 ] [ set omega spin-rate ; remove speadup option set angle ( clock - delay ) * omega / 10 set radius 0.7 * ( 1.0 - 0.3 * epicycle * sin 2 * angle ) set xc radius * sin angle set yc -1 * radius * cos angle ] end to go-patches ;;Patch Procedure set food 0 if (( distancexy (xc * max-pxcor) (yc * max-pxcor)) < 5) [ set food 2 ] set chemical chemical * (100 - evaporation-rate ) / 100 update-display end to return-to-nest ;;Turtle Procedure ifelse nest? ;; if ant is in the nest, it drops food and heads out again [ set carrying-food? false rt 180 fd 1 ] [ set chemical (chemical + drop-size) ;; drop some chemical, but the amount decreases each time set drop-size (drop-size - 1.5) if (drop-size < 1) [set drop-size 1] uphill-nest-scent ;; head toward the greatest value of nest-scent wiggle2 ;; which is toward the nest grid-step ] end to look-for-food ;;Turtle Procedure if (food > 0) [ set carrying-food? true ;; pick up food set totfood totfood + 1.0 if not active? [set ifood ifood + 1.0] set active? true set food (food - 1) ;; and reduce the food source set drop-size 60 rt 180 fd 1 stop ;; and turn around ] ; flatten-world ifelse (chemical > 2) [ fd 1 ] [ ifelse (chemical < 0.05) ;; go in the direction where the chemical smell is strongest [ set age 0 set active? false wiggle fd 1] [ uphill-chemical grid-step] ] end to uphill-chemical ;;Turtle Procedure let ahead 0 let scent-left 0 let scent-right 0 ; flatten-world ; rt random 40 - random 40 ;; sniff left and right, and go where the strongest smell is set ahead next-chemical rt 45 set scent-right next-chemical lt 90 set scent-left next-chemical rt 45 if ((scent-right > ahead) or (scent-left > ahead)) [ ifelse (scent-right > scent-left) [ rt 45 ] [ lt 45 ] ] end to-report next-chemical ;; reports what the strength of chemical right in front of the ant is report [chemical] of patch-at dx dy end ;;;;;;;;;;;;;;;;;;;;;;*************************;;;;;;;;;;;;;;;;;;;;;;;;; to uphill-nest-scent ;;Turtle Procedure let ahead 0 let scent-left 0 let scent-right 0 ; flatten-world ;; sniff left and right, and go where the strongest smell is set ahead next-nest-scent rt 45 set scent-right next-nest-scent lt 90 set scent-left next-nest-scent rt 45 if ((scent-right > ahead) or (scent-left > ahead)) [ ifelse (scent-right > scent-left) [ rt 45 ] [ lt 45 ] ] end to-report next-nest-scent ;; reports what the strength of nest-scent right in front of the ant is report [nest-scent] of patch-at dx dy end to grid-step ;;Turtle Procedure fd 1 setxy round xcor round ycor end to wiggle ;;Turtle Procedure rt random 10 - random 10 end to wiggle2 ;;Turtle Procedure rt random 5 - random 5 end to flatten-world ;;Turtle Procedure if( abs(xcor) > max-pxcor - 1) [ set heading towardsxy-nowrap 0 ycor ] if ( abs(ycor) > max-pycor - 1 ) [ set heading towardsxy-nowrap xcor 0 ] end to do-plotting let worker_count 0 let f1 0 let fse 0 set worker_count count turtles with [age > 0] if not plot? [ stop ] if (clock mod nplot) = 0 ; output only every nplot cycles [ set foodrate ( totfood - foodlast ) / nplot set ifoodrate ( ifood - ifoodlast ) / nplot ; type clock type "|, |" type totfood type "|, |" type foodrate ; type "|, |" type ifood type "|, |" type ifoodrate type "|, |" ; type 10.0 * (sum age) / count cycle type "|, |" set f1 worker_count / 100.0 set fse 1.0 - ( ifoodrate / (foodrate + 1) ) if foodrate = 0 [ set fse 0.0 ] if foodrate = ifood [ set fse 1.0 ] ; type f1 type "|, |" type fse type "|, |" print fse - f1 set-current-plot-pen "total" ; set-plot-pen-color black ; set in window plotxy clock totfood set-current-plot-pen "rate" ; set-plot-pen-color red ; set in window plotxy clock (foodrate) set-current-plot-pen "age" ; set-plot-pen-color violet if (worker_count > 0) [plotxy clock (sum [age] of (turtles with [age > 0]) / worker_count) ] set-current-plot-pen "collective" ; set-plot-pen-color green plotxy clock worker_count set foodlast totfood set ifoodlast ifood ] end ; *** NetLogo Model Copyright Notice *** ; ; This model was created as part of the project: CONNECTED MATHEMATICS: ; MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL ; MODELS (OBPML). The project gratefully acknowledges the support of the ; National Science Foundation (Applications of Advanced Technologies ; Program) -- grant numbers RED #9552950 and REC #9632612. ; ; Copyright 1998 by Uri Wilensky. All rights reserved. ; ; Permission to use, modify or redistribute this model is hereby granted, ; provided that both of the following requirements are followed: ; a) this copyright notice is included. ; b) this model will not be redistributed for profit without permission ; from Uri Wilensky. ; Contact Uri Wilensky for appropriate licenses for redistribution for ; profit. ; ; This model was converted to NetLogo as part of the project: ; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN ; CLASSROOMS. The project gratefully acknowledges the support of the ; National Science Foundation (REPP program) -- grant number REC #9814682. ; Converted from StarLogoT to NetLogo, 2001. Updated 2002. ; ; To refer to this model in academic publications, please use: ; Wilensky, U. (1998). NetLogo Ants model. ; http://ccl.northwestern.edu/netlogo/models/Ants. ; Center for Connected Learning and Computer-Based Modeling, ; Northwestern University, Evanston, IL. ; ; *** End of NetLogo Model Copyright Notice *** @#$#@#$#@ GRAPHICS-WINDOW 259 18 673 453 50 50 4.0 1 20 1 1 1 0 1 1 1 -50 50 -50 50 0 0 1 ticks 30.0 BUTTON 6 20 61 53 Setup setup NIL 1 T OBSERVER NIL NIL NIL NIL 1 SLIDER 4 128 183 161 diffusion-rate diffusion-rate 0.0 99.0 12 1.0 1 NIL HORIZONTAL SLIDER 4 169 183 202 evaporation-rate evaporation-rate 0.0 99.0 4 1.0 1 NIL HORIZONTAL BUTTON 68 20 123 53 Go go T 1 T OBSERVER NIL NIL NIL NIL 1 SWITCH 0 349 90 382 plot? plot? 0 1 -1000 SLIDER 4 87 183 120 agents agents 0 200 100 1 1 NIL HORIZONTAL PLOT 257 458 664 673 Self-organizing consumers Time Statistics 0.0 10.0 0.0 10.0 true true "" "" PENS "rate" 1.0 0 -2674135 true "" "" "age" 1.0 0 -8630108 true "" "" "collective" 1.0 0 -10899396 true "" "" "total" 1.0 0 -16777216 true "" "" SLIDER 4 294 176 327 epicycle epicycle 0 6 0 1 1 NIL HORIZONTAL SLIDER 4 258 176 291 delay delay 0 1000 132 1 1 NIL HORIZONTAL SLIDER 4 217 176 250 spin-rate spin-rate 0 75 2 1 1 NIL HORIZONTAL SLIDER 72 349 244 382 nplot nplot 1 50 4 1 1 NIL HORIZONTAL SWITCH 132 19 249 52 graphics? graphics? 0 1 -1000 MONITOR 39 618 134 663 worker count count turtles with [age > 0] 0 1 11 @#$#@#$#@ ��� Ant foraging with moving food source ver 1b - developed 2002 ��� This program was used to obtain the results in the following paper: N. Johnson, (2002). “The Development of Collective Structure and Its Response to Environmental Change.” Presented at the Self-Organisation & Evolution of Social Behaviour Workshop, Monte Verita, Switzerland, September, 2002. Los Alamos National Laboratory Report, LA-UR-02-3125. Available at: http://papers.ssrn.com/abstract=2232154 Norman L. Johnson http://CollectiveScience.com norman@santafe.edu ## ABSTRACT How do collective processes in decentralized, self-organizing systems respond to environmental change? What are the contrasting roles of collective structures and innovative components (variation, diversity, entropy), and how do these roles change with different rates of environmental change? To answer these questions, a simple self-organizing system is examined � a simulation of foraging for food by ants in the presence of environmental change. This model system has been argued to be similar in dynamics to decentralized components of many collective systems - ecologies, economies, knowledge systems, societies, political systems, etc. The simulations are first shown to illustrate a developmental view of evolving systems, captured by the developmental stages of Formative, Co-Operational and Condensed. The effects of different rates of environmental change are then presented. For small rates of change, the system productivity is largely unchanged. As the rate increases, innovative information becomes more important to sustaining the productivity. As the rate further increases, episodic failure is observed as stabilizing collective structures fail, and the system regresses to earlier developmental stages. The collective structures are shown to inhibit the performance of the system as a whole in rapidly changing environments. A quantitative measure is developed that captures the efficacy of the collective structure. A variation of the system with a mechanism for sustaining collective structures is found to be more sensitive to environmental change, duplicating the decline in productivity observed in aging systems. ��� The program is based on a modification of the standard ant foraging example (described below), distributed with NetLogo. ��� The following changes are made: - The finite food source is replaced with an infinite food source that can move in a circle or a complex elipse: * use "spin rate" to change the rate for spin * use "delay" to delay the time the spin starts * use "epicycle" to vary the distance from the nest while spinning - makes the foraging more challenging. - Plotting options for tracking the various "types" of workers. See paper for description. - Option to turn off graphing and plotting to speed up simulation. * use "nplot" to set the number of time steps between plotting See the paper to explore different self-organizing structures and their failures. ���Previous description for sample��� WHAT IS IT? In this project, a colony of ants forages for food. Each ant follows a set of simple rules, but the colony as a whole acts in a sophisticated way. When an ant finds a piece of food, it carries the food back to the nest, dropping a chemical as it moves. When other ants "sniff" the chemical, they follow the chemical toward the food. As more ants carry food to the nest, they reinforce the chemical trail. ## HOW TO USE IT Click the SETUP button to set up the ant nest (in violet, at center) and three piles of food. Click the GO button to start the simulation. The chemical is shown in a green-to-white gradient. The EVAPORATION-RATE slider controls the evaporation rate of the chemical. The DIFFUSION-RATE slider controls the diffusion rate of the chemical. There is an on-off PLOT? switch. Turning off the plotting lets the model run faster. ## THINGS TO NOTICE The ant colony generally exploits the food source in order, starting with the food closest to the nest, and finishing with the food most distant from the nest. It is more difficult for the ants to form a stable trail to the more distant food, since the chemical trail has more time to evaporate and diffuse before being reinforced. Once the colony finishes collecting the closest food, the chemical trail to that food naturally disappears, freeing up ants to help collect the other food sources. The more distant food sources require a larger "critical number" of ants to form a stable trail. The consumption of the food source is shown in a plot. In CYAN you see food1 which is on the right side of the screen. In BLUE you see food2 which is on the lower left of the screen. In MAGENTA you see food3 which is on the upper left of the screen. ## EXPLORATIONS Try different placements for the food sources. What happens if two food sources are equidistant from the nest? When that happens in the real world, ant colonies typically exploit one source then the other (not at the same time). In this project, the ants use a "trick" to find their way back to the nest: they follow the "nest scent." Real ants use a variety of different approaches to find their way back to the nest. Try to implement some alternative strategies. ## NETLOGO FEATURES In the UPHILL-CHEMICAL procedure, the ant "follows the gradient" of the chemical. That is, it "sniffs" in three directions, then turns in the direction where the chemical is strongest. You might want to try variants of the UPHILL-CHEMICAL procedure, changing the number and placement of "ant sniffs." RETURN-TO-NEST uses a similar gradient. ## CREDITS AND REFERENCES This model was developed at the MIT Media Lab. See Resnick, M. (1994) "Turtles, Termites and Traffic Jams: Explorations in Massively Parallel Microworlds." Cambridge, Ma: MIT Press. Adapted to StarLogoT, 1997, as part of the Connected Mathematics Project. Adapted to NetLogo, 2000, as part of the Participatory Simulations Project. To refer to this model in academic publications, please use: Wilensky, U. (1998). NetLogo Ants model. http://ccl.northwestern.edu/netlogo/models/Ants. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 ant true 0 Polygon -7500403 true true 136 61 129 46 144 30 119 45 124 60 114 82 97 37 132 10 93 36 111 84 127 105 172 105 189 84 208 35 171 11 202 35 204 37 186 82 177 60 180 44 159 32 170 44 165 60 Polygon -7500403 true true 150 95 135 103 139 117 125 149 137 180 135 196 150 204 166 195 161 180 174 150 158 116 164 102 Polygon -7500403 true true 149 186 128 197 114 232 134 270 149 282 166 270 185 232 171 195 149 186 Polygon -7500403 true true 225 66 230 107 159 122 161 127 234 111 236 106 Polygon -7500403 true true 78 58 99 116 139 123 137 128 95 119 Polygon -7500403 true true 48 103 90 147 129 147 130 151 86 151 Polygon -7500403 true true 65 224 92 171 134 160 135 164 95 175 Polygon -7500403 true true 235 222 210 170 163 162 161 166 208 174 Polygon -7500403 true true 249 107 211 147 168 147 168 150 213 150 link true 0 Line -7500403 true 150 0 150 300 link direction true 0 Line -7500403 true 150 150 30 225 Line -7500403 true 150 150 270 225 @#$#@#$#@ NetLogo 5.0.2 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ default 0.0 -0.2 0 1.0 0.0 0.0 1 1.0 0.0 0.2 0 1.0 0.0 link direction true 0 Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 210 180 @#$#@#$#@ 0 @#$#@#$#@