tapios / risk-networks

Code for risk networks: a blend of compartmental models, graphs, data assimilation and semi-supervised learning
Other
2 stars 2 forks source link

Removes multithreaded loop over contacts in contact simulation #97

Closed glwagner closed 4 years ago

glwagner commented 4 years ago

Reproducibility is more complicated with multithreaded simulations. While set_num_threads(1) worked on my laptop (as discussed in #90), it did not work on @lubo93's.

This PR removes multithreading from the contact simulation. On my laptop, this resolves #90 without requiring set_num_threads(1).

Performance is unchanged on my laptop even for large problems with 300,000 nodes and 3,000,000 contacts. The multithreading therefore does not appear to be helpful anyways.

For reference, this is what running simple_epidemic.py on a large network looks like

(risknet) ~/Projects/risk-networks/examples$ python3 simple_epidemic.py 

                               *** Day: 0.125

[ Patient manifest ]          Admitted: 
                            Discharged: 
                               Current: 

[ Status report ]          Susceptible: 284172
                               Exposed: 815
                              Infected: 14450
                          Hospitalized: 20
                             Resistant: 539
                              Deceased: 4
             Current possible contacts: 2999900
               Current active contacts: 6199

[ Wall times ]    Hosp. administration: 0.0151 s,
                    Contact simulation: 15.3120 s,
                    Kinetic simulation: 43.2738 s

                               *** Day: 0.250

[ Patient manifest ]          Admitted: 80640, 47825, 132465, 124354, 13572, 86217, 276696, 233060, 75182, 209195, 138990, 55911, 279802, 153095, 218622, 290115, 128662, 29448, 149009, 52506
                            Discharged: 
                               Current: 80640, 124354, 290115, 13572, 233060, 55911, 153095, 86217, 29448, 209195, 52506, 75182, 138990, 47825, 132465, 149009, 128662, 276696, 279802, 218622

[ Status report ]          Susceptible: 283072
                               Exposed: 1855
                              Infected: 13914
                          Hospitalized: 37
                             Resistant: 1108
                              Deceased: 14
             Current possible contacts: 2999684
               Current active contacts: 13084

[ Wall times ]    Hosp. administration: 0.0149 s,
                    Contact simulation: 16.4692 s,
                    Kinetic simulation: 43.1717 s

Resolves #90

lubo93 commented 4 years ago

Thanks, this also solves #90 .