From algorithm 1 to algorithm 2 (SIR)

The first thing that comes to mind when algorithm 1 no longer suffices is the SIR approach. We look at the entire population and divide it into three compartments: who can be infected (S for susceptible), who are infected (I for infected) and who are resistant (R for resistant). To keep things simple for the time being, we start with a fixed number (N). The population does not increase or decrease during the time the model works. This means that we can assume that N = S + I + R . But the mutual relationships do change during that period. If we divide the time that the model works into periods, we can translate that assumption into:

N=S_t+I_t+R_t

so we can express S, I and R in percentages.

The SIR approach has a second assumption in the form of an associated transition model: S individuals can only change into I individuals and I individuals can only change into R individuals. We can try to capture the rate of the transitions from S_ {t} to I_ {t} in an infection rate per period, say \beta_ {t} and the rate of the transitions from I_ {t} to R_ {t} in a recovery rate per period, say \mu_ {t}.

We made algorithm 2 to get an impression of how this approach works out.