globals [ ticks total-mortals max-mortals]
breeds [ mortals immortals ]
patches-own [ mortalPop immortalPop]
mortals-own [ deathRate birthRate diffusionRate ]
immortals-own [ diffusionRate ]
to setup
ca
set ticks 0
ask patches [set pcolor background-color]
set max-mortals init-mortals
create-custom-mortals init-mortals ;; create the mortals, then initialize their variables
[
set color blue
set diffusionRate mortals-diffusion
set deathRate mortals-death-rate
set birthRate mortals-birth-rate
setxy random-int-or-float screen-size-x random-int-or-float screen-size-y
]
create-custom-immortals init-immortals ;; create the immortals, then initialize their variables
[
set color red
set diffusionRate immortals-diffusion
setxy random-int-or-float screen-size-x random-int-or-float screen-size-y
]
do-plot
end
to go
ask patches [set mortalPop count mortals-here]
ask mortals [
moveMortal
reproduce
death
]
ask immortals [
moveImmortal
]
do-plot ;; plot populations
set ticks ticks + 1
set total-mortals count mortals
if total-mortals > max-mortals [set max-mortals total-mortals]
if total-mortals = 0 [ stop ]
if limit-mortals and (total-mortals > upper-threshold) [stop]
end
to moveMortal ;; turtle procedure
if random-int-or-float 100 < diffusionRate [
;; code for random movement
;; rt random 50 - random 50
;; code for gradient movement
set heading downhill mortalPop
fd 1
]
end
to moveImmortal ;; turtle procedure
if random-int-or-float 100 < diffusionRate [
;; code for random movement
;; rt random 50 - random 50
;; code for gradient movement
set heading downhill immortalPop
fd 1
]
end
to reproduce ;; mortals procedure
locals [births]
set births count immortals-here
if births > 0 [
if random-int-or-float 100 < birthRate [ ;; throw "dice" to see if you will reproduce
hatch births [ moveMortal ] ;; hatch an offspring and move it
]]
end
to death ;; turtle procedure
if random-int-or-float 100 < deathRate [ die ]
end
to do-plot
set-current-plot "populations"
set-current-plot-pen "mortals"
plot count mortals
set-current-plot-pen "immortals"
plot count immortals
end
; Altarum copyright notice
; Copyright Altarum Institute, 2003. All rights reserved.
; Converted from StarLogoT to NetLogo, 2000.
; 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 Altarum Institute.
; Contact Altarum Institute for appropriate licenses for redistribution for
; profit.
; To refer to this model in academic publications, please use:
; H.V.D. Parunak (2003). Discrete Life Model.
; http://www.altarum.net/~vparunak/models/DiscreteLife.nlogo .
; Altarum Institute, Ann Arbor, MI
; The author may be contacted at van.parunak@altarum.org
; Altarum copyright notice
@#$#@#$#@
GRAPHICS-WINDOW
486
10
820
365
40
40
4.0
1
10
1
1
1
CC-WINDOW
480
380
823
507
Command Center
SLIDER
9
87
172
120
init-mortals
init-mortals
0
250
250
1
1
NIL
SLIDER
8
130
180
163
mortals-diffusion
mortals-diffusion
0.0
100
25.0
1
1
NIL
SLIDER
8
172
182
205
mortals-death-rate
mortals-death-rate
0
100
11
1
1
NIL
SLIDER
204
88
358
121
init-immortals
init-immortals
0
250
50
1
1
NIL
SLIDER
8
213
190
246
mortals-birth-rate
mortals-birth-rate
0.0
100
85.0
1
1
NIL
BUTTON
11
16
80
49
setup
setup
NIL
1
T
OBSERVER
T
BUTTON
96
16
163
49
go
go
T
1
T
OBSERVER
T
PLOT
11
384
312
581
populations
time
pop.
0.0
100.0
0.0
100.0
true
true
PENS
"mortals" 1.0 0 -16776961 true
"immortals" 1.0 0 -65536 true
MONITOR
67
325
149
374
mortals
count mortals
3
1
MONITOR
160
325
242
374
immortals
count immortals
3
1
TEXTBOX
38
61
178
80
Mortals settings
TEXTBOX
230
62
343
80
Immortals settings
MONITOR
11
325
61
374
ticks
ticks
0
1
SLIDER
204
130
381
163
immortals-diffusion
immortals-diffusion
0
100
14
1
1
NIL
MONITOR
254
327
326
376
balance
mortals-birth-rate * init-immortals / (screen-size-x * screen-size-y) - mortals-death-rate
0
1
SLIDER
204
17
376
50
background-color
background-color
0
139
50
1
1
NIL
SLIDER
8
287
180
320
upper-threshold
upper-threshold
0
10000
1000
10
1
NIL
MONITOR
337
326
418
375
max-mortals
max-mortals
0
1
SWITCH
8
250
128
283
limit-mortals
limit-mortals
1
1
-1000
@#$#@#$#@
WHAT IS IT?
-----------
NetLogo encourages the development of entity-based or agent-based models. Many of the systems for which NetLogo models are popular have also been modeled with alternative methods, such as systems of differential equations. The differences between these broad classes of techniques are non-trivial and of great importance to practicing modelers (Parunak et al. 1998).
This model illustrates one such difference, identified by Shnerb et al. 2000. They present a simple scenario consisting of two interacting populations.
* Immortals are never born and never die. They move by diffusion (modeled in NetLogo by invoking DOWNHILL on their concentration) at a velocity specified by IMMORTALS-DIFFUSION.
* Mortals die, are born, and move. Their movement is by diffusion (driven by the concentration of other mortals). The probability that a mortal will die at a given time step is MORTALS-DEATH-RATE (expressed as 100 * the probability). Birth requires the presence of an immortal on the same patch. The probability that a mortal occupying a patch with an immortal will reproduce is given by MORTALS-BIRTH-RATE.
The differential equations capturing this behavior are quite simple. Their solution predicts that the long-term population of mortals will grow without limit if MORTALS-BIRTH-RATE * the density of the immortal population is greater than MORTALS-DEATH-RATE, and go to zero if the product is less than the death rate.
Shnerb et al. observe that this prediction is sometimes violated by an agent-based model of the same scenario. The reason is that the distribution of agents is not homogeneous. New mortals are not randomly distributed over the territory, but are born in the vicinity of their "father" immortals, and thus have a higher chance to encounter an immortal (namely, their father) than the mean field approximation would suggest. I built this model to see how robust this effect is and gain experience with its dynamics.
HOW TO USE IT
-------------
1. Adjust the slider parameters (see below), or use the default settings.
2. Press the SETUP button.
3. Press the GO button to begin the simulation.
4. View the POPULATIONS plot to watch the populations fluctuate over time
5. The BALANCE window shows the difference (BIRTH-RATE * IMMORTAL-DENSITY) - DEATH-RATE. The equation-based mean-field theory predicts that the population should grow if this is positive and go to zero if it is negative.
Parameters (all probabilities are expressed as whole-number percentages, and compared with random-int-or-float 100 to make decisions)
BACKGROUND-COLOR: Default is black, but on some screens, the blue turtles (mortals) may be hard to see, so you can use this slider to adjust the background.
INIT-MORTALS: The initial size of the population of mortals (default 250)
INIT-IMMORTALS: The (constant) size of the population of immortals (default 50)
MORTALS-DIFFUSION: The probability that a mortal will move a step on a given round (thus approximates velocity in patches-per-step) (default 25)
IMMORTALS-DIFFUSION: The probability that an immortal will move a step on a given round (thus approximates velocity in patches-per-step) (default 14)
MORTALS-DEATH-RATE: The probability that a mortal will die on a given step (default 15)
MORTALS-BIRTH-RATE: The probability that a mortal sharing a patch with an immortal will give birth on a given step (default 85)
UPPER-THRESHOLD: If the LIMIT-MORTALS switch is on, the model will stop when the mortal population reaches this level, making it easier to count runs at different population levels (see below).
THINGS TO NOTICE
----------------
The default settings give a balance of -14, predicting extinction, but in many runs the population of mortals explodes.
In other runs for the same balance, the population collapses. You may need to press SETUP several times before finding an initial distribution of agents that permits the explosion of mortals.
Explosion is not necessarily monotonic. The population of mortals can grow very large (10,000 or more, in which case the model slows down significantly!), and yet subsequently collapse.
THINGS TO TRY
-------------
Try adjusting the parameters under various settings. How sensitive is the stability of the model to the particular parameters?
You might count the proportion of setups that permit the population of mortals to grow to a certain threshold, as a function of the balance. What is the shape of this curve?
How does diffusion speed affect the likelihood of a boom in mortals?
EXTENDING THE MODEL
-------------------
What happens if we introduce a gestation period, by requiring a certain number of time steps to pass between a meeting between a mortal and an immortal, and the birth of the new mortal?
What if new mortals are not born in the vicinity of their parents, but rather are assigned to a random location in the terrain?
What happens if we make the immortals mortal?
NETLOGO FEATURES
----------------
Note the use of breeds to model two different kinds of "turtles": mortals and immortals.
DOWNHILL is a very easy way to model diffusion. (It would be nice to have a version of this primitive that makes the movement decision, not deterministically, but stochastically, selecting direction based on a roulette wheel whose segments are sized according to some function of the density to which DOWNHILL is responding.)
RELATED MODELS
---------------
This model was constructed by beginning with the Wolf-Sheep predation model in the NetLogo distribution (Wilensky 1998), and retains much of its structure for dealing with interacting populations. (The logic is, of course, quite different.)
CREDITS AND REFERENCES
----------------------
H. V. D. Parunak, R. Savit, and R. L. Riolo. Agent-Based Modeling vs. Equation-Based Modeling: A Case Study and Users' Guide. In Proceedings of Multi-agent systems and Agent-based Simulation (MABS'98), 10-25, Springer, 1998.
N. M. Shnerb, Y. Louzoun, E. Bettelheim, and S. Solomon. The importance of being discrete: Life always wins on the surface. Proc. Natl. Acad. Sci. USA, 97(19 (September 12)):10322-10324, 2000.
U. Wilensky. NetLogo Wolf Sheep Predation model. http://ccl.northwestern.edu/netlogo/models/WolfSheepPredation. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL, 1998.
To refer to this model in academic publications, please use:
H.V.D. Parunak. Discrete Life Model. http://ccl.northwestern.edu/netlogo/models/community/DiscreteLife . Altarum Institute, Ann Arbor, MI, 2003.
@#$#@#$#@
default
true
0
Polygon -7566196 true true 150 5 40 250 150 205 260 250
sheep-shape
false
15
Rectangle -1 true true 90 75 270 225
Circle -1 true true 15 75 150
Rectangle -16777216 true false 81 225 134 286
Rectangle -16777216 true false 180 225 238 285
Circle -16777216 true false 1 88 92
wolf-shape
false
0
Rectangle -7566196 true true 15 105 105 165
Rectangle -7566196 true true 45 90 105 105
Polygon -7566196 true true 60 90 83 44 104 90
Polygon -16777216 true false 67 90 82 59 97 89
Rectangle -1 true false 48 93 59 105
Rectangle -16777216 true false 51 96 55 101
Rectangle -16777216 true false 0 121 15 135
Rectangle -16777216 true false 15 136 60 151
Polygon -1 true false 15 136 23 149 31 136
Polygon -1 true false 30 151 37 136 43 151
Rectangle -7566196 true true 105 120 263 195
Rectangle -7566196 true true 108 195 259 201
Rectangle -7566196 true true 114 201 252 210
Rectangle -7566196 true true 120 210 243 214
Rectangle -7566196 true true 115 114 255 120
Rectangle -7566196 true true 128 108 248 114
Rectangle -7566196 true true 150 105 225 108
Rectangle -7566196 true true 132 214 155 270
Rectangle -7566196 true true 110 260 132 270
Rectangle -7566196 true true 210 214 232 270
Rectangle -7566196 true true 189 260 210 270
Line -7566196 true 263 127 281 155
Line -7566196 true 281 155 281 192
@#$#@#$#@
NetLogo 2.0.0
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@