Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing Adaptive Rewiring (from Chapter 8: Dynamic and adaptive networks) #72

Open
uluturki opened this issue Nov 30, 2020 · 4 comments

Comments

@uluturki
Copy link

Hi,

I would like to simulate a 4 compartment model (SIR with an additional Quarantine compartment) with adaptive rewiring where susceptible nodes wire away from infected nodes with a rate. It seems that modifying the network during the simulation is not supported at the moment.

Based on my cursory reading, I can achieve this by modifying "Gillespie_simple_contagion", but I wanted to check if there is a recommended way to approach this issue. I do not mind writing a bit of code to achieve this.

Thanks!

@joelmiller
Copy link
Collaborator

You are correct that I don't have an option for adoptive rewiring.

This sounds like Gillespie_simple_contagion is the best option. Something like this might give some ideas: https://epidemicsonnetworks.readthedocs.io/en/latest/examples/SEIRT.html. In this example someone who is infected might be identified due to infection or because an infected partner is identified.

@uluturki
Copy link
Author

Thanks for the quick response, I do need the actual rewiring mechanism (i.e. modify the graph G as the simulation goes on) since that is an important part of the model I am trying to simulate.

Is there anything I should be wary of if I went into the Gillespie_simple_contagion function and modified the graph G whenever a node transitions to a certain compartment? I think removing all related pending events for that pair from the queue when breaking an edge, and initializing related events when adding an edge should be sufficient. A hacky solution will serve me fine at the moment since I only need a very simple rewiring mechanism.

I need quick results for this but I will be happy to discuss how to implement it more properly and contribute the implementation to the repo later if there is interest in including it.

@joelmiller
Copy link
Collaborator

Something like this is definitely doable.

you would need to spend a little bit of time thinking about the "listDict" class that it uses. Right now it keeps track of the possible events and their associated rate. So when an edge is broken or added you'll need to update those events.

A more hacky version would be to let it run for a little while and then pause and restructure the network and restart the calculations fresh. This wouldn't be very fast, but may be less likely to make mistakes in the coding (might also run into trouble because the rewiring wouldn't happen as fast as you want).

@joelmiller
Copy link
Collaborator

If you do get something working it would be nice if you can provide some code that is set up in a way where the user could specify their own rewiring rules and it could be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants