RP4 CVTD NetLogo Model – Pre-Release Beta 2.0

RP4 CVTD NetLogo Model – Pre-Release Beta 2.0 preview image

1 collaborator

Default-person Monish Ahluwalia (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.2.1 • Viewed 240 times • Downloaded 24 times • Run 0 times
Download the 'RP4 CVTD NetLogo Model – Pre-Release Beta 2.0' modelDownload this modelEmbed this model

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


Info tab cannot be displayed because of an encoding error

Comments and Questions

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

Click to Run Model

breed [dogs dog]
breed [dogs2 dog2]

turtles-own
[
  sick?
  immune?
  healthy?
  age
  infected-time
  coupled?
  coupled-time
  partner
]

globals
[
  number-infected
  number-healthy
  number-immune
  number-vulnerable
]

;; Designates the command for the setup button.

to setup
  clear-all
  setup-turtles
  reset-ticks
end 

;; Creates a number of turtles with random position. The designated number of infected turtles are instructed
;; to "get-sick". Also, it prevents the number of infected dogs from being larger than the total number of dogs
;; and the recovery time from being larger than the maximum dog age. Finally, there are two identical shapes for
;; the dogs. This is to help with the coupling code as explained later.

to setup-turtles
  create-turtles number-dogs
  [ setxy random-xcor random-ycor
    set size 1.5
    set color green
    set healthy? true
    set sick? false
    set immune? false
    set age 0 + random 5
    set coupled? false
    set coupled-time 0
    ifelse random 2 = 0
    [ set shape "dog"]
    [ set shape "dog 2"]
  ]
  if number-infected-dogs > number-dogs [set number-infected-dogs number-dogs]
  if recovery-time > maximum-dog-age [set recovery-time maximum-dog-age]
  ask n-of number-infected-dogs turtles
  [get-sick]
end 

;; Instructions of how a turtle gets sick. They turn red and stay sick for a certain amount of time defined by the recovery-time slider.

to get-sick
  set sick? true
  set healthy? false
  set immune? false
  set color red
  set infected-time 0
end 

;; Instructions of how a turtle gets better. They turn grey because they are now immune to the disease. There is also
;; a certain chance that the cancer will metastasize, resulting in death. This is defined as 5% from research.

to get-better
  set sick? false
  set immune? true
  set healthy? false
  set color grey
  ;if random-float 100 < 1 [die]
end 

;; What happens when the user presses the "go" button. It involves the turtles moving and getting older.
;; If a turtle is sick, every move it takes, that time is added to its infected-time
;; If that infected time is greater than the time for recovery (user-defined), then it undergoes get-better.
;; Global variables are also updated (counting for the monitors and graph).
;; To simplify the coding, dogs with the shape of "dog 2" are always the ones to initiate coupling.
;; If a turtle is not coupled, it will go down to different pathways, depending on if it is sick or not. If the
;; "dog 2" dog is sick, it will go down the "sick-couple" pathway, while healthy "dog 2"'s will go down the couple pathway.
;; If a turtle is coupled and has been for longer than the user defined couple-time, then it will uncouple.

to go
  ask turtles [
    if coupled? = false [move]
    if coupled? = true
    [ set coupled-time coupled-time + 0.1]
    if sick? = true
      [set infected-time infected-time + 0.1]
    if infected-time > recovery-time [get-better]
  if coupled? = false and (healthy? = true or immune? = true) and shape = "dog 2" and (coupling-frequency > random-float 10) [couple]
  if coupled? = false and sick? = true and shape = "dog 2" and (coupling-frequency > random-float 10) [sick-couple]
  if coupled-time > coupling-time and shape = "dog 2" [uncouple]
  get-older
  ]
  update-global-variables
  tick
end 

;; Moves randomly

to move
  rt random 100
  lt random 100
  fd 1
end 

;; A turtle gets older with every tick (defined as 0.1 years).
;; If it's age is greater than the user-defined max dog age, it dies :(.

to get-older
  set age age + 0.1
  if age > maximum-dog-age [die]
end 

;; Coupling code. All healthy "dog 2"'s will go through "couple" while all infected "dog 2"'s will go through "sick-couple".
;; Once down this path, the two turtles of different shapes next to eachother will be paired together and be surrounded by
;; a grey box. If dog 2 is healthy and its partner is sick, it's partner can infect it and vice versa.

to couple
  let potential-partner one-of (turtles-at -1 0) with [coupled? = false and shape = "dog"]
  if potential-partner != nobody
  [ set partner potential-partner
    set coupled? true
    ask partner [ set coupled? true]
    ask partner [ set partner myself]
    set pcolor grey - 3
    ask (patch-at -1 0) [set pcolor grey - 3]
    move-to patch-here
    ask partner [move-to patch-here]
    ask partner [infect]
    ]
end 

to sick-couple
  let potential-partner one-of (turtles-at -1 0) with [coupled? = false and shape = "dog"]
  if potential-partner != nobody
  [ set partner potential-partner
    set coupled? true
    ask partner [ set coupled? true]
    ask partner [ set partner myself]
    set pcolor grey - 3
    ask (patch-at -1 0) [set pcolor grey - 3]
    move-to patch-here
    ask partner [move-to patch-here]
    infect
    ]
end 

;; Uncoupling code. After a user-defined amount of time, a couple will break apart and will have an opportunity
;; to reproduce.

to uncouple
  set coupled? false
  set coupled-time 0
  set pcolor black
  ask (patch-at -1 0) [set pcolor black]
  if partner != nobody
  [ask partner [ set coupled-time 0]
  ask partner [ set partner nobody]
  ask partner [ set coupled? false]
  set partner nobody]
  make-babies
end 

;; Infection can only take place if the dogs are coupled and one of the dogs is infected.

to infect
  if coupled? = true and partner != nobody
  [ if transmission-rate-between-dogs > random-float 200 and immune? = false
    [ ask partner [ get-sick]]]
end 

;; Making babies can only take place if the dogs are coupled and the total number of dogs is less than
;; the carrying capacity. If one of the dogs is sick, then there is a chance that the offspring will be
;; infected. Since there are two shapes of dogs that can be created, there are two chances to reproduce.
;; This is why the chance is based off a random number from 0 to 400. The slider has a maximum of 200
;; and while this does not mean that every couple will have a child, it results in a similar result
;; as if a single dog could be produced based off a random number from 0 to 200. This also creates the
;; possibility that a single couple can produce two offspring.

to make-babies
  if random-float reproduction-rate > random 400 and count turtles < carrying-capacity
  [hatch-dogs 1
    rt random-float 360
    fd 1
    set age 0
    set immune? false
    set color green
    if sick? = true and transmission-rate-during-birth > random 200 [get-sick]
    ]
  if random-float reproduction-rate > random 400 and count turtles < carrying-capacity
  [hatch-dogs2 1
    rt random-float 360
    fd 1
    set age 0
    set immune? false
    set color green
    if sick? = true and transmission-rate-during-birth > random 200 [get-sick]
    ]
end 

;; Updating required for the graphs and monitors to keep up with the simulation.

to update-global-variables
  if count turtles > 0
  [ set number-infected (count turtles with [sick? = true])
      set number-healthy (count turtles - number-infected)
      set number-immune (count turtles with [immune? = true])
      set number-vulnerable (count turtles - (number-infected + number-immune))]
end 

There is only one version of this model, created over 9 years ago by Monish Ahluwalia.

Attached files

File Type Description Last updated
RP4 CVTD NetLogo Model – Pre-Release Beta 2.0.png preview Preview for 'RP4 CVTD NetLogo Model – Pre-Release Beta 2.0' over 9 years ago, by Monish Ahluwalia Download

This model does not have any ancestors.

This model does not have any descendants.