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

Understand what happens with filtering of edges in epidemic simulator #151

Open dburov190 opened 4 years ago

dburov190 commented 4 years ago

In epidemic simulator's run method here: https://github.com/dburov190/risk-networks/blob/ecaf3369ef7e45b6d51a8a73330cde52808d0aa5/epiforecast/epidemic_simulator.py#L142-L166

it seems a bit inconsistent that there's some sort of filtering done for the edges that are then passed to contact simulator, but not for the edges that are added/removed from the contact network. Seems weird

glwagner commented 4 years ago

If I recall correctly, previously the method discharge_and_admit_patients managed the contact network. The logic was that the action of "discharging" and "admitting" a patient was itself the rewriting of the contact network. It was therefore necessary to recompute the edges_to_add and edges_to_remove for the purposes of the ContactSimulator.

(Using that abstraction it would have still been possible to output contacts_to_add and contacts_to_remove to be used by contact_simulator. However this was not done, perhaps for the sake of the simplicity of the HealthService.)

As it reads now, it should be possible to omit recomputing edges_to_add and edges_to_remove, since it basically reproduces what's done, for example, here:

https://github.com/dburov190/risk-networks/blob/ecaf3369ef7e45b6d51a8a73330cde52808d0aa5/epiforecast/health_service.py#L173-L175

I think contacts_to_add and contacts_to_remove can be passed instead to contact_simulator. It looks like contact_simulator will accept edges or lists, and that redundant entries are ok:

https://github.com/dburov190/risk-networks/blob/ecaf3369ef7e45b6d51a8a73330cde52808d0aa5/epiforecast/contact_simulator.py#L192-L197

It doesn't look to me like the code is currently inconsistent. However, it is unnecessary to recompute edges_to_remove when it is identical to contacts_to_remove. This can be checked by comparing edges_to_remove to contacts_to_remove (but note that one is a list and one is a set).

As an aside, it may make sense to change the name of discharge_and_admit_patients, since this method does not discharge or admit patients by modifying the contact network.