Hi Tiago,
Thanks again for your helpful reply. I have now changed my approach to
modifying the beta parameter instead, as you suggested in your previous reply.
However, I’m still running into unexpected behaviour.
I would expect that I can change the beta parameters after the model is
instantiated, to modify the progress of infection between iterations of the
model; at least that is what I thought the constant_beta flag is for. However,
it seems that the model ignores any changes that I make to the beta map after
instantiating. What am I doing or understanding wrong?
Here’s my minimum working example (adapted to the new approach), where I set
beta to 0 for all edges but new infections still happen.
# SETUP
from graph_tool.generation import price_network
from graph_tool.dynamics import SIRSState
g = price_network(20, directed=False)
# Initialise beta map with transmission probability 1 for all edges
beta_map = g.new_edge_property('float', 1)
model = SIRSState(g, beta=beta_map, r=0,
constant_beta=False) # ensure no spontaneous infections
state = model.get_state()
# TEST
print("before quarantining:\n", state.a)
# Set transmission probability to 0 for all edges
beta_map.a = 0
# Run model one time step
model.iterate_sync()
# New nodes in the filtered graph are infected
print("filtered state after quarantining:\n", state.a)
Essentially, I am looking for some way to isolate vertices and ensure they
cannot infect others.
On a related note, I am running into issues implementing the following
subroutine efficiently: for a list of vertices (as a numpy integer array),
determine the indices of all edges in the graph incident to at least one of the
vertices in the list. Here the index is w.r.t. edge property maps. Is there an
efficient way using a graph-tool function that I’m missing?
Many thanks for all your help.
Best,
Edwin
> On 10 Apr 2020, at 18:01, [email protected] wrote:
>
>
> Message: 1
> Date: Fri, 10 Apr 2020 12:04:34 +0200
> From: Tiago de Paula Peixoto <[email protected]>
> To: [email protected]
> Subject: Re: [graph-tool] Extending SIR epidemic model with a
> quarantined/immunised state
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="utf-8"
>
> Am 10.04.20 um 09:54 schrieb Edwin Lock:
>> 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
_______________________________________________
graph-tool mailing list
[email protected]
https://lists.skewed.de/mailman/listinfo/graph-tool