_new per-capita model

No preview image

1 collaborator

Hobbes286x286 Rik Blok (Author)

Tags

agent-based model 

Tagged by Rik Blok over 11 years ago

output-wrap.nls 

Tagged by Rik Blok about 11 years ago

per-capita-tau-leaping.nls 

Tagged by Rik Blok about 11 years ago

random-walk.nls 

Tagged by Rik Blok about 11 years ago

sigfigs.nls 

Tagged by Rik Blok about 11 years ago

spatial 

Tagged by Rik Blok over 11 years ago

Model group UBC ISCI 422 | Visible to everyone | Changeable by the author
Model was written in NetLogo 5.0.4 • Viewed 566 times • Downloaded 53 times • Run 0 times
Download the '_new per-capita model' modelDownload this modelEmbed this model

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


Comments and Questions

Runtime error (correction)

This model is just a template and won't run as is. If you try to run it you should see a runtime error "FOREACH expected input to be a list but got the number 0 instead." It happens because no events have been added yet. To make a working model from this template add breeds, initial conditions, and events.

Posted over 11 years ago

Click to Run Model

;==================== begin _new per-capita model.nlogo ========================
; _new per-capita model - a template for writing agent-based simulations using
;   reactions and diffusion.  Agents interact via reactions that are
;   implemented via "per-capita-tau-leaping.nls" and move diffusively via
;   "random-walk.nls".
;
; By Rik Blok, 2013 
;
; This is free and unencumbered software released into the public domain.
;
; Anyone is free to copy, modify, publish, use, compile, sell, or
; distribute this software, either in source code form or as a compiled
; binary, for any purpose, commercial or non-commercial, and by any
; means.
;
; Revisions:
;
;   2013-10-08 - don't stop simulation if dt=0.  Instead do small random walk.
;   2013-08-02 - added event counts and error reporters
;   2013-07-01 - initial release by Rik Blok
;-------------------------------------------------------------------------------


__includes
[ "output-wrap.nls"            ; Same as output-print but wraps printed output.
  "per-capita-tau-leaping.nls" ; Approximate Gillespie's SSA.
  "random-walk.nls"            ; Random walk for individuals.
  "sigfigs.nls"                ; Like precision but specifies number of significant figures.
]


globals
[ ; Variable 'dt' not needed here if using System Dynamics Modeler.
  dt  ; Time step.  Automatically set in 'go' by 'per-capita-tau-leap'.
]

to startup
  setup  ; Might as well setup when model loaded.
end 

to setup
  clear-all
  reset-ticks
  output-wrap 27 ; Set output box to wrap at column 27.
  
  ; Create initial population here. For example...
  ; create-turtles 100
  ; [ setxy random-xcor random-ycor
  ; ]
  
  ; Place reactions here. For example, logistic N <--> 2 N could be implemented as...
  ; add-per-capita-event turtles                  ; N -> 2 N @ rate beta
  ;   task [ beta-birth-rate ] 
  ;   task [ hatch 1 ]
  ; add-per-capita-event turtles                  ; N + N -> N @ rate 1
  ;   task [ count other turtles-here ] 
  ;   task [ die ]
end 

to go
  if ticks = 0 ; If just starting, start timing.
  [ reset-timer 
  ]
  set dt per-capita-tau-leap inaccuracy dt
  ; If no events occurred, then dt=0.  
  ; Replace with small dt so a few turtles move to new patches.
  if dt = 0
  [ set dt inaccuracy * random-walk-time-patch diffusion-const
  ]
  random-walk turtles random-walk-jump-size diffusion-const dt
  tick-advance dt
end 

to-report diffusion-const
; Used by 'go' in call to 'diffuse-individual'.
  report 10 ^ log-diffusion
end 

to-report inaccuracy
; Complement of accuracy, depends on err-tolerance.
; Used by 'go' in call to 'per-capita-tau-leap'.
  report 10 ^ ( err-tolerance )
end 


;==================== end _new per-capita model.nlogo ==========================

There are 3 versions of this model.

Uploaded by When Description Download
Rik Blok about 11 years ago 2013-10-08 - don't stop simulation if dt=0. Instead do small random walk. Download this version
Rik Blok about 11 years ago 2013-08-02 - added event counts and error reporters Download this version
Rik Blok over 11 years ago Initial upload Download this version

Attached files

File Type Description Last updated
output-wrap.nls extension Same as output-print but wraps printed output. about 11 years ago, by Rik Blok Download
per-capita-tau-leaping.nls extension Approximate Gillespie's SSA. about 11 years ago, by Rik Blok Download
random-walk.nls extension Random walk for individuals. about 11 years ago, by Rik Blok Download
sigfigs.nls extension Like precision but specifies number of significant figures. about 11 years ago, by Rik Blok Download

This model does not have any ancestors.

This model does not have any descendants.