SystemDynamics + ABM

SystemDynamics + ABM preview image

1 collaborator

Default-person Michael Samuels (Author)

Tags

agent-based model 

Tagged by Michael Samuels over 11 years ago

multiscale model 

Tagged by Michael Samuels over 11 years ago

population dynamics 

Tagged by Michael Samuels over 11 years ago

system dynamics 

Tagged by Michael Samuels over 11 years ago

Part of project 'Sociotech'
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.3 • Viewed 1872 times • Downloaded 71 times • Run 0 times
Download the 'SystemDynamics + ABM' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This is a model of logistic growth using the System Dynamics Modeler.

HOW IT WORKS

Variables

  1. Birth Rate is chosen by modeler.
  2. Death Rate = 1 / Lifespan in Years. So if the Life Span is 10 years, the death rate is 0.1 with 1/Years as the units. This is a change from the original model as a build-up for converting the logistic from a population model into a form for studies of chaos.

At each step, the value of INFLOW is added to STOCK. The value of INFLOW is always the previous value of STOCK times a specified growth rate. The growth rate for an exponential model of population growth is the BirthRate. However, in a logistic model, the rate of change is reduced by (K - N)/K, where N is the population size and K is an upper limit - i.e., the carrying capacity. So the rate equation for logistic growth is rN(K-N/K). But r = b - d, so if we split up the rate in and rate out, we have bN(K-N/K) on the birth side and dN(K-N/K) on the death side (as the OUTFLOW for the system). We usually think of deaths in terms of life span of an individual, so the death rate, d, becomes 1/life-span.

HOW TO USE IT

Press the SETUP button, then press the GO button to run the model. The "Step 1 Year" button repeats the GO command 1000 times because "dt" in the System Dynamics model is set to 0.001. Note that the simulation length can be set by the user but increased during a model run if needed.

THINGS TO NOTICE

View the STOCK monitor to see the current value of STOCK.

View the plot to observe the growth of STOCK over time.

THINGS TO TRY

Use the System Dynamics Modeler to add an outflow.

Try different growth-rate values.

EXTENDING THE MODEL

Create a new stock that grows linearly. Try having the level of one stock influence the growth rate of the other. This would be a model useful for all sorts of problems, like infection rates on the INFLOW side and recovery rates on the OUTFLOW. Or diffusion of innovations (i.e., BASS Model of Diffusion).

NETLOGO FEATURES

This model uses the System Dynamics Modeler. Interesting to compare with the standard ABM model.

RELATED MODELS

System Dynamics -> Exponential Growth

HOW TO CITE

If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

COPYRIGHT AND LICENSE

Copyright 2005 Uri Wilensky.

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

Comments and Questions

Purpose of Model

This modifies the standard SD model for logistic growth using netlogo's SD editor so that it uses birth and death rates instead of birth rates and lifespans (just a minor change). Plus, it highlights the fact that the carrying capacity affects both input and output. In addition, some experiments were added to include ABM features with each "tick." The number of agents can become too big in a very short time, so the user is given the option of shutting this part off. The intent is to see how such a model would function - i.e., during each tick, the ABM part of the model can do some work, but the overall pattern is observed via system dynamics.

Posted over 11 years ago

Click to Run Model

;; LOGISTIC - Note that dt = 0.001 by default, but here it is initialized to 1 dt = 1 tick = 1 year.

;; system-dynamics-setup, system-dynamics-do-plot, and system-dynamics-go are automatically
;; generated by the System Dynamics Modeler.  The code can be viewed in the
;; Code Tab of the System Dynamics Modeler.

globals ;those not set in SD
[
   counter
   multiplier
   minmax
   pop-previous
   pop-change
   pop-plot
   old-pop
   upper-x
   upper-y
   predecessor
]

to setup
   ca
  
   system-dynamics-setup
   system-dynamics-do-plot
   set pop-change 0
   set pop-plot 0
   set old-pop init-pop
   set counter 0
   set multiplier 1
   set minmax 1.0E10  ;+/-9007199254740992 is range
   
   ;set graph display bounds assuming non-chaotic behavior   
   ifelse init-pop > carrying-capacity
   [ 
     set upper-y init-pop 
   ]
   [ 
     let uy list carrying-capacity (( birth-rate - death-rate ) * carrying-capacity )
     set upper-y max uy
   ]
   
   set upper-x Simlength
   
   set predecessor nobody
   
   print ( word "dt: " dt " Upper-x: " upper-x " Upper-y: " upper-y )
end 

to update-display1
  
  crt 1 [
    
    ;normalize to plot boundaries: min_range + (( current - min-data ) ( max-pxcor - min-pxcor)) / ( max-data - min-data)
    ;Max data range for x is length of simulation.  Max data range for y is carrying-capacity +- a buffer to show overshooet
    ;Max plot range for x is 1 less than max-pxcor to prevent last point from overshooting plot.  For y, 
   
    let x int ( ( ticks * ( max-pxcor - 1 ) ) / upper-x )
    let y int ( ( population * ( max-pycor - 1 ) ) / upper-y )

    set shape "circle"
    set size 1
    set color blue    
    set label ( precision pop-plot 0 ) 

    if pop-plot < 0 [ set color orange ]

    ;keep graphics on screen if chaotic behavior leads to wild fluctuations     
    if y < 0 [ set y 0 ] 
    if y > max-pycor - 1 [ set y max-pycor - 1 ]
    
    print ( word "         x: " x " y: " y " predecessor: " predecessor " at tick: " precision ticks 0 )
    setxy x y    
    if ticks >= 2.0 [ create-link-with predecessor ]
    set predecessor self

    
  ]
end 

to update-display2

  ;Depict individuals up to 100 tick units of time
    
  ifelse count turtles < 0 
  [ 
    crt 1 [
      let x ticks
      let y 2
      setxy x y
      set size 1
      set shape "circle"
      set color black
      ;set label count turtles
      print ( word "         population: " count turtles " births: " births " deaths: " deaths )
    ]
  ]
  [  
      ifelse births > 0
      [
        crt int births [
    
          let x random  ( max-pxcor - 1 )
          let y ( random  ( max-pycor - 11 ) ) + 10 
          setxy x y
    
          set size 1
          set shape "circle"
          print ( word "         turtle " who " born at x: " x " y: " y " at tick: " precision ticks 0 )
        ]
      ]
      [
        crt 1
        [
           let x ticks
           let y 4
           setxy x y
           set size 1
           set shape "circle"
           set color green
           ;set label precision births 1
        ]
      ]
    
      ifelse deaths > 0 
      [
        ask n-of int deaths turtles [
          print ( word "         turtle " who " died at at tick: " precision ticks 0 )
          die
        ]
      ]
      [
        crt 1
        [
          let x ticks
          let y 6
          set size 1
          set shape "circle"
          set color red
          ;set label precision deaths 1
        ]
      ]
  ]
end 

to update-plot
  
   set-current-plot "Population Size"
   system-dynamics-do-plot
   set-current-plot-pen "limit"
   plotxy ticks carrying-capacity
   
   set-current-plot "r"
   set-current-plot-pen "births"
   plotxy ticks births
   set-current-plot-pen "deaths"
   plotxy ticks deaths

   set-current-plot "dN"
   set-current-plot-pen "default"
   plotxy population pop-change
  
   set-current-plot "N2N1"
   set-current-plot-pen "default"
   plotxy pop-previous population 
end 

to go
  
  let mult multiplier / dt
  
  ;check status of simulation
  if ( ticks > SimLength ) [ stop ]
  if ( abs population >= minmax ) [ stop ]
 
  ;iterate 
  set counter counter + 1.0                ;number of iterations - i.e., "dt"
  set pop-previous population              ;record previous population in last dt
  system-dynamics-go                       ;one unit of dt
  set pop-change population - pop-previous ;change over 1 unit of dt
  
  if ( counter mod ( mult ) = 0 ) 
  [ 
    set multiplier multiplier + 1
    set pop-plot population - old-pop
    print ( word "Dt count: " counter " Tick count: " precision ticks 0 " Change per dt: " precision pop-change 3 " Change per tick: " precision pop-plot 3 " Population: " precision population 3 )
    
    ;combo box controls which way the main display is depicted - ON means population size over time with change as label.  OFF means individuals created and eliminated in a "network."
    if display-type = "display-population" [ update-display1 ]
    if display-type = "display-individuals" [ if ticks < max-pxcor - 1 [ update-display2 ]]
    
    set old-pop population

  ]
  
  update-plot
end 

There is only one version of this model, created over 11 years ago by Michael Samuels.

Attached files

File Type Description Last updated
SystemDynamics + ABM.png preview Preview for 'SystemDynamics + ABM' over 11 years ago, by Michael Samuels Download

This model does not have any ancestors.

This model does not have any descendants.