0

I'm developing a simple NetLogo disease model that has 4 compartments:

S - susceptible individuals E - Exposed individuals I - Infected individuals S - Recovered individuals that become susceptible again (i.e. there is no immunity).

My simulation starts off with 1 individual who is initially infected with the rest being susceptible.

This is the code I have so far:

turtles-own [
  disease?
  latent?
  susceptible? 
  latent-period-time
  infectious-period-time
]


to setup
  clear-all
  create-turtles num-agents [ setxy random-xcor random-ycor
    set shape "wolf"
    set size 2
    become-susceptible 
  ]
  
  ask n-of infected-agents turtles [become-infected] 
  reset-ticks
end

to go
move
spread
  tick 
end

to move
  ask turtles [ 
  right random 50
  left random 50
    fd 1 ] 
end

to spread
  ask turtles [
  ifelse disease? [] [
  if any? other turtles-here with [ disease? ]
  [ become-latent
    set latent-period-time 0 ]
  ]]

  ask turtles [
    if latent-period-time = latent-period ;latent-period is a slider variable set to 30 
    [
     become-infected
     set infectious-period-time 0] 
  ]
  
  ask turtles [ 
       if infectious-period-time = infectious-period ;infectious-period is a slider variable set to 100
    [ 
      become-susceptible] 
  ] 
  
  ask turtles [ 
    if latent?
        [ set latent-period-time latent-period-time + 1 ]
 if disease? 
      [set infectious-period-time infectious-period-time + 1]  ]
end 

to become-susceptible
  set disease? false
  set latent? false 
  set susceptible? true 
  set color orange 
end 

to become-latent
  set latent? true 
  set disease? false 
  set susceptible? false 
  set color gray
end 

to become-infected 
  set latent? false
  set disease? true
  set susceptible? false 
  set color blue
end

For some reason only the initial infected individual seems to go back to the susceptible pool, while any other newly infected individuals do not go back to the susceptible pool. The initially infected individual is also unable to get infected again after going back to the susceptible pool even though it encounters infected individuals.

I'm not sure how to fix this problem.

Thanks!

1 Answers1

0

Your problem is that you never reset the value of latent-period-time and infectious-period-time back to 0. There are two ways to fix this:

  1. Put the set to 0 into the same code that changes all the state flags and colours
  2. Scrap the tracking and incrementing entirely and use a variable that records when the turtle gets to the state - assume it's called 'state-start-time' then you would simply have set state-start-time ticks and then do a subtraction for your test of duration.
JenB
  • 17,620
  • 2
  • 17
  • 45
  • Thanks @JenB I was able to modify my spread procedure following your suggestions and now my model follows the SEIS disease dynamics! – Nikol Dimitrov Apr 28 '21 at 20:53