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 calculation of offspring per location per day #3

Closed averbraeck closed 6 months ago

averbraeck commented 6 months ago

Offspring is the number of susceptible persons typically infected by an infectious person.

averbraeck commented 6 months ago

Offspring is not so easy to calculate, since medlabs typically uses an (extension of an) SEIR model. This means that persons in the models are exposed at the time when we know who causes the exposed state, but when the infectious state is reached, that relation is gone. Therefore, the changeDiseasePhase method in an implementation of DiseaseProgression interface separates the exposed stage into a separate exposed method that identifies the infecting persons (or a list of possible infecting persons from which one has to be chosen) for an exposed person. The exposed method returns a boolean indicating whether the exposure will lead in the end to an infection. The registration of an infection is then allocated to the day when the transmission of the disease took place.

averbraeck commented 6 months ago

DiseaseProgression implements the exposed methods as follows:

    public abstract boolean expose(Person exposedPerson, DiseasePhase exposurePhase);

    public void expose(final Person exposedPerson, final DiseasePhase exposurePhase, 
        final Person infectiousPerson)
    {
        if (expose(exposedPerson, exposurePhase))
        {
            getModel().getDiseaseMonitor().reportInfection(exposedPerson, infectiousPerson);
        }
    }

    public void expose(final Person exposedPerson, final DiseasePhase exposurePhase, 
        final TIntList infectiousPersonList)
    {
        if (infectiousPersonList.size() == 1)
        {
            expose(exposedPerson, exposurePhase, this.model.getPersonMap()
                    .get(infectiousPersonList.get(0)));
        }
        else if (infectiousPersonList.size() > 1)
        {
            expose(exposedPerson, exposurePhase, this.model.getPersonMap()
                    .get(infectiousPersonList.get(this.model.getRandomStream()
                    .nextInt(0, infectiousPersonList.size() - 1))));
        }
        else
        {
            expose(exposedPerson, exposurePhase);
        }
    }
averbraeck commented 6 months ago

The following changes are made:

averbraeck commented 6 months ago

Changes has been tested, and seem to work as intended.