Converting a math problem to discrete event modeling

I am trying to implement the SIR epidemic model . Basically, the way I understand the model is that at each time step, it tells us how many nodes are infected and how many nodes are restored. Now I'm trying to convert this to discrete event modeling and am confused at some point.

The model is usually solved using the Euler method. Now, when I convert it to discrete event modeling, I do something like this (numbers are used for clarity):

Initialize 100 members
At every time step t,
  //Determine how many get infected
  for i = 1 to 100
     let i pass a message to its neighbors
     When the neighbor receives the message from an infected member, it generates a random number and if it is less than beta*(infected/total), where beta is the infection rate, then the member gets infected
     Update the count for infected, recovered, susceptible

  //Determine how many are recovered
  for i = 1 to 100
      Generate a random number from a uniform distribution and check if it is less than gamma*infected. If it is, then this member is recovered.
      Update the count for infected, recovered, susceptible

I was interested to know if this approach is correct. Any suggestions?

+3
3

, , , , - . , ( , , , ) - ( , " " " - ).

, ( SIR): , "", , , → , .. , , , , , ; , → , , !

:

-- nummsgs, number of "messages" received this time step
-- compartment (susceptible, infected or recovered)

. :

for each individual:
    if individual.compartment != infected:
        continue
    for each neighbor of the individual:
        neighbor.nummsgs += 1
    if (random number says so):
        individual.compartment = recovered

for each individual:
    if individual.compartment != susceptible:
        continue
    maybe (depending on random number & nummsgs):
        individual.compartment = infected

for each individual:
    individual.nummsgs = 0

, -, ( , ).

+4

, , , .

1) - , beta*(infected/total) beta.

2) , gamma*infected , gamma*infected - ​​ gamma.

, - , . , .

+2

-, , . , , " " , . , node "" .

-, . , node ? node node blob? .

In fact, I see no reason to use messages here. The probability of infection for each node is just a function of the number of infected neighbors - why not use this? Depending on your goals, it would be better to replace probabilities with mathematical expectations.

Finally, the problem is closely related to the famous “game of life”. Take a look at the various implementations.

+2
source

Source: https://habr.com/ru/post/1734642/


All Articles