GhettiG
GhettiG

Reputation: 91

NetLogo: dead agent = lost information?

i'm new to this site and to NetLogo. I'm trying to simulate pertussis epidemic in Italy and I want to know the age of the agent when he got sick.

The problem is that agents can die!! So I lose all the data related to dead agents!

Is there a way to retrieve the values of variables from dead turtles?

Thanks!

Upvotes: 2

Views: 431

Answers (2)

mattsap
mattsap

Reputation: 3806

If you want to store all the variables of dead turtles, I would create a new breed called corpse which has all the same variables as your other breed that's dying, and when your breed dies set its breed to corpse. ask turtles [set breed corpse]

This is an alternative to JenB's solution if you don't restrict your turtle commands by status already (e.g. ask turtles [something] compared to ask turtles with [status = "active"] [something])

Upvotes: 1

JenB
JenB

Reputation: 17678

Instead of asking them to actually die with the [die] command, just use a variable to say they are dead. You presumably have something that tracks their infection status (eg susceptible, infected, recovered), so you could add another state (susceptible, infected, recovered, dead). Then you can get information with commands like set VARNAME count turtles with [status = dead]

As per comments below, this may make your other code difficult if you need to exclude the dead turtles from interacting. So another option is to add other commands into the same are of code where to tell the turtle to die. Those other commands could be as simple as incrementing a counter, but could also add values to some list.

ask turtles
  [ if ... (whatever your test is to see if the turtle dies)
    [ set deathcounter deathcounter + 1
      die
    ]
  ]

Upvotes: 1

Related Questions