averbraeck / medlabs

Agent-Based Simulation for Disease Spread in Cities and Regions
BSD 3-Clause "New" or "Revised" License
3 stars 2 forks source link

Add more extensive offspring calculation #6

Closed averbraeck closed 1 month ago

averbraeck commented 3 months ago

To do data mining on the offspring, more details are needed. Therefore, another file is added that details the infections and non-infections per location per infectious person. The name of the file will be offspringLocation.csv. The following columns will be added to the file, every time when a person leaves a location:

One line will be added per infection, so it can be multiple lines per infectious person. In case no infection takes place in the location, one line is added to the file as well, without information on the infected person(s).

averbraeck commented 3 months ago

Calculating the time in location can be difficult -- the contact time is dependent on the entering time and leaving time of both the infectious person(s) and the exposed person(s), Every time someone enters a location, calculateTransmissionEnter is called that looks at possible infections since the latest enter/leave. When someone leaves, calculateTransmissionLeave is called that does the same. Inbetween can be very small intervals that have nothing to do with either the time of the infectious person in the location, nor with the time the exposed person was in the room, nor the time of the overlap. Therefore, it's best to not output any times.

averbraeck commented 1 month ago

Offspring calculations have been built into the Medlabs library. The structure of the classes DiseaseTransmission and DiseaseProgression have changed as a result. The DiseaseTransmission class uses a cache of infectious persons who entered a location, and calculates the number of infections that that person has caused while being in the location. When the infectious person leaves the location, the count is sent to the DiseaseMonitor.reportOffspring method, which fires an OFFSPRING_EVENT for the ResultWriter class (and possibly graphs) to record the offspring results in a file. To properly calculate offspring, also results with 0 infections at a location are transmitted.

averbraeck commented 1 month ago

The results have been tested with the SEIR demo model, and look consistent and complete.

There is one small issue in the SEIR demo model that clearly shows in the infections.csv file and offspringLocation.csv files: The incubation time when to move from the exposed stage to the infected stage is drawn from a distribution. At the same time, the viral load is determined based on a triangular distribution that is based on a number of days since infection, where the starting point of the distribution is not the same as the exposed -> infected transition. This means that persons who have the disease status exposed can infect others. This is not an error in the offspring/infection statistics, but an inconsistency in the implementation of the SEIR model.

averbraeck commented 1 month ago

The calculation of the offspring looks correct. A new version of the medlabs and heros model will be tagged.