Population Dynamics

Population Dynamics preview image

2 collaborators

Default-person Hossein Sabzian (Author)
Nima Shahriari (Team member)

Tags

population dynamics 

Tagged by Hossein Sabzian about 1 year ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.2.0 • Viewed 146 times • Downloaded 6 times • Run 0 times
Download the 'Population Dynamics' 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

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

patches-own [food]

turtles-own [
 gender ;;  male or female
 married?  ;; the maritial status of the agent
 spouse  ;; the spouse of the agent if it is married
 age ;; the age of agent with maximum of 100
 vehicle? ;; it is true if the agent has a wehicle and false if the agent has no vehicle
 parasite? ;; when the population exceeds the critical threshold, 0.1 of them get infected with parasite
 energy  ;; the energy of the agent
]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;setup block

to setup
  ca
  random-seed my-seed

  ask patches [
    set food random 10
    recolor-patch
  ]
  crt initial-pop [
    initial-properties
    setxy random-xcor random-ycor
  ]

  reset-ticks
end 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Go block

to go
  if not any? turtles [stop]
  if ticks = stop-time [stop]

ask turtles [
    update-age
    eat
  ]


ask turtles with [ age >= 18 and not married? ] [
    move
    evaluation-for-marriage ;; it assess the other agents on  when it can marry or not
  ]

ask turtles with [ married? ] [
    reproduction
  ]

death-by-energy-loss ;; death by loss of energy
unexpected-events  ;;  unexpcted events like car accidents, airplane crashes
unexpected-illness ;; unexpcted illnesses like cancers, HIV and parasite spreading



ask turtles with [parasite?] [set age age + random 4 ]


ask patches [ regrowth  recolor-patch ]



  tick
end 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; helper procedures
;;;;;;;;;;;;;;;;;;a patch-procedure

to recolor-patch
  set pcolor scale-color green food 10 0
end 
;;;;;;;;;;;;;;;;;; a turtle-procedure

to initial-properties
set size 2
set color magenta
set spouse nobody
set married? false
set age 0
set parasite? false
set energy 100
ifelse random-float 1.0 <= percentage-of-vehicle-owners [ set vehicle? true] [set vehicle? false]
ifelse random-float 1.0 <= 0.5 [set gender "male" set shape "person"] [ set gender "female" set shape "woman"]
end 
;;;;;;;;;;;;;;;;;; a turtles procedure

to update-age
  if ticks mod ticks-as-a-year = 0 [set age age + 1 ]
  if age >= 100 [ get-dead ]
end 

to get-dead
if spouse != nobody [ask spouse [ set spouse nobody set married? false ] ]
die
end 

;;;;;;;;;;;;;;;;;;a turtle procedure

to eat
  let target one-of patches with [food >= 1]
  set energy energy - energy-lost-for-finding-food
  if target != nobody [
    ask target [ set food food - 1 ]
    set energy energy + energy-gained-from-eating
  ]
end 
;;;;;;;;;;;;;;;;;;;;;;a turtle procedure

to move
  rt random-float 90
 lt random-float 90
  if not can-move? 1 [ rt 180]
  fd 0.75
  set energy energy - energy-lost-from-moving
end 
;;;;;;;;;;;;;;;;;;;;;; turtle procedure of marriage mechanisms

to evaluation-for-marriage
  let marriage-target one-of other turtles-here with [gender != [gender] of myself]  ;; target for marriage

  if  marriage-target != nobody and [age] of marriage-target >= 18 [

  let hypothesis? [married?] of marriage-target = true ;; a hypothesis that the target is married

    ifelse hypothesis? [ move ] [ marry marriage-target]

  ]
end 

to marry [person]
   set married? true set spouse person set-color
   ask person [set married? true set spouse myself set-color ]
end 

to set-color
  set color ifelse-value (gender = "male") [blue] [orange] ;; married man & woman
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;a turtle procedure

to reproduction
  if  gender = "female" and married? and age >= min-age-of-reproduction and age <= max-age-of-reproduction [
    if random-float 1.0 <= probability-of-childbearing [set energy energy - 20 hatch 1 [
    initial-properties

  ]  ]   ]
end 
;;;;;;;;;;;;;;;;;;;;;;;;;;; trurtle procedures for death by energy loss, unexpcted events and unexpected illness

to death-by-energy-loss
  ask turtles [ if energy <= 0 [ get-dead]  ]
end 

to unexpected-events
  ;; for car accident
  ask turtles [if age >= 18 and vehicle?
                      [ if possibility-of-vehicle-accident?
                                      [ ifelse high-speed-crash?  [ if random-float 1.0 <= 0.8 [get-dead]]   [if random-float 1.0 <= 0.1 [get-dead] ]  ] ] ]
end 

to unexpected-illness
  ;; for parasite spread
  if count turtles >= critical-threshold [ ask n-of (0.05 * count turtles) turtles [ set parasite? true] ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;; a trurtle procedure

to regrowth
  if random-float 1.0 <= probability-of-regrowth [ if food <= 1 [set food food + random 10] ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; reporters

to-report married-people
  report count turtles with [ married?]
end 

to-report single-people
  report count turtles with [not married?]
end 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; shocks

to shock-for-single-agents  ;; unmaried agents
  ask turtles with [ not married? ] [ move-to one-of patches]
end 

to shock-for-all-agents
  ask turtles  [ move-to one-of patches]
end 

;;;;;;;;;;; The voluem of food

to-report north-east
  report sum [food] of patches with [ pxcor > 0 and pycor > 0 ]
end 

to-report north-west
  report sum [food] of patches with [ pxcor < 0 and pycor > 0 ]
end 

to-report south-east
  report sum [food] of patches with [ pxcor > 0 and pycor < 0 ]
end 

to-report south-west
  report sum [food] of patches with [ pxcor < 0 and pycor < 0 ]
end 

There is only one version of this model, created about 1 year ago by Hossein Sabzian.

Attached files

File Type Description Last updated
Population Dynamics.png preview Preview for 'Population Dynamics' about 1 year ago, by Hossein Sabzian Download

This model does not have any ancestors.

This model does not have any descendants.