Extending SIR epidemic model with a quarantined/immunised state

Thanks for getting back to me so quickly!

I have a ‘quarantined’ vertex property map that maintains who is quarantined and have set a vertex filter on the graph to filter out quarantined people. Quarantined people are not supposed to be able to infect others.

Here is a minimum working example where I quarantine all infected people from the graph but new people are infected in the next time step.

# SETUP
from graph_tool.generation import price_network
from graph_tool.dynamics import SIRSState
g = price_network(20)
model = SIRSState(g, r=0) # make sure there are no spontaneous infections
state = model.get_state()
# Keep track of who is quarantined
quarantined = g.new_vertex_property('bool', False)
# Filter out quarantined nodes from graph
g.set_vertex_filter(quarantined, inverted=True)

# TEST:
print("before quarantining:\n", state.a)
# Quarantine all infected individuals
quarantined.a = (state.a == 1)
# Run model one time step
model.iterate_sync()
# New nodes in the filtered graph are infected (with some probability):
print("filtered state after quarantining:\n", state.fa)

For completeness, here is the complete code of my extended model: https://gist.github.com/edwinlock/ccece9b82d13383ef50df8b6e5aedf60

Another question: I want to stop quarantined people from infecting others, but I do want them to recover with the same probability as non-quarantined people. In this case it makes sense to use an edge filter to remove all edges adjacent to a quarantined person
instead of filtering the person’s vertex itself, right?

Best,
Edwin

Thanks for getting back to me so quickly!

I have a ‘quarantined’ vertex property map that maintains who is quarantined and have set a vertex filter on the graph to filter out quarantined people. Quarantined people are not supposed to be able to infect others.

Here is a minimum working example where I quarantine all infected people from the graph but new people are infected in the next time step.

# SETUP
from graph_tool.generation import price_network
from graph_tool.dynamics import SIRSState
g = price_network(20)
model = SIRSState(g, r=0) # make sure there are no spontaneous infections
state = model.get_state()
# Keep track of who is quarantined
quarantined = g.new_vertex_property('bool', False)
# Filter out quarantined nodes from graph
g.set_vertex_filter(quarantined, inverted=True)

I imagined you were maybe doing it like this... Indeed, the SIRSState
keeps track of the original unfiltered graph.

What you need to do is to set the filter before you create the
SIRSState, and it should work as you are expecting.

Another question: I want to stop quarantined people from infecting others, but I do want them to recover with the same probability as non-quarantined people. In this case it makes sense to use an edge filter to remove all edges adjacent to a quarantined person
instead of filtering the person’s vertex itself, right?

Yes, this would be the correct approach. It would also be equivalent to
modifying the beta parameter as I described previously.

Best,
Tiago