Rejection-Based Simulation of Stochastic Spreading Processes
on Complex NetworksGerrit Großmann
Verena Wolf Saarland University
img © Michael Kreil
2
• Friendship networks • Online social networks • Telecommunication networks • Infrastructure networks • Biological and Ecological Networks • …
Networks are everywhere
Complex Networks
img © Michael Kreil
Motivation
3
• Infectious diseases • Computer viruses • Rumours/opinions/emotions • Blackouts • …
Understand spreading phenomena of
img © Michael Kreil
Spreading Process• Fixed graph topology • Continuous time dynamics • Nodes have local states • Nodes' states change randomly w.r.t. rules
4
Classical example: SIS model• 2 local states (infected, susceptible) • 2 rules (infection, recovery)
SIS Model
Infection (edge-based) Recovery (node-based)
5
• 2 local states (infected, susceptible) • 2 rules (infection, recovery)
(rate depends on neighborhood) (rate does not depend on neighborhood)
Rules:Rules:
1 3
SIS Naïve Simulation
�6
0.0
Rules:Rules:
1 3
SIS Naïve Simulation0.0123
�7
0.0
Rules:Rules:
1 3
SIS Naïve Simulation0.0123
1.2
�8
0.0
Rules:Rules:
1 3
SIS Naïve Simulation0.0123
0.0111.2
�9
0.0
Rules:Rules:
1 3
SIS Naïve Simulation0.0123
0.011
0.02110.1
1.2
�10
0.0
Rules:Rules:
1 3
SIS Naïve Simulation0.0123
0.011
0.02110.1
1.2
�11
0.0
Rules:
1 3
0.0123
0.011
0.02110.1
1.2
SIS Naïve Simulation
�12
0.0
0.0123
0.011
0.02110.1
1.2
0.0 0.011
SIS Naïve Simulation
�13
Rules:
1 3
0.0123
0.011
0.02110.1
1.2
0.0 0.011
SIS Naïve Simulation
�14
Iteration over all nodes is very slow.:(
Stochastic Simulation Approaches
• Standard Gillespie Algorithm
• Optimized Gillespie Algorithm
• Event-Based Rejection Simulation (Our Method)
15
Stochastic Simulation Approaches
• Standard Gillespie Algorithm
• Optimized Gillespie Algorithm
• Event-Based Rejection Simulation (Our Method)
16
Standard Gillespie
1 2
3 4
0
!17
Standard Gillespie
1 2
3 4
0
!18
Standard Gillespie
1 2
3 4
0
!19
2
4
2
4
Standard Gillespie2
4
2
4
2
0
2
2
1
2
1
0
1 2
3 4
0
!20
Standard Gillespie
1 2
3 4
0
!21
Standard Gillespie
1 2
3 4
0
!22
Iteration over all neighbours of the updated node is needed.
:(
Stochastic Simulation Approaches
• Standard Gillespie Algorithm
• Optimized Gillespie Algorithm
• Event-Based Rejection Simulation (Our Method)
23
Optimized Gillespie
1 2
3 4
0
!24[1] Cota & Ferreira: Optimized Gillespie algorithms for the simulation of Markovian epidemic processes on large and heterogeneous networks
What is the maximal rate at which an infected node attacks its neighbours?
(under all network configurations)
Optimized Gillespie
1 2
3 4
0What is the maximal rate at which an infected node attacks its neighbours?
(under all network configurations)
Maximal degree: 3
!25[1] Cota & Ferreira: Optimized Gillespie algorithms for the simulation of Markovian epidemic processes on large and heterogeneous networks
Optimized Gillespie
1 2
3 4
0
!26[1] Cota & Ferreira: Optimized Gillespie algorithms for the simulation of Markovian epidemic processes on large and heterogeneous networks
Optimized Gillespie
1 2
3 4
0
!27[1] Cota & Ferreira: Optimized Gillespie algorithms for the simulation of Markovian epidemic processes on large and heterogeneous networks
(upper bound)
Optimized Gillespie
1 2
3 4
0 43 2
!28
Actual (effective) rate:
Upper bound:
[1] Cota & Ferreira: Optimized Gillespie algorithms for the simulation of Markovian epidemic processes on large and heterogeneous networks
(upper bound)
Optimized Gillespie
Rejection step with probability:
!29
Actual (effective) rate:
Upper bound:
[1] Cota & Ferreira: Optimized Gillespie algorithms for the simulation of Markovian epidemic processes on large and heterogeneous networks
(upper bound)
1 2
3 4
0 43 2
Optimized Gillespie
Rejection step with probability:
!30
Rejection probability = Maximal rate - Effective rateMaximal rate
Actual (effective) rate:
Upper bound:
[1] Cota & Ferreira: Optimized Gillespie algorithms for the simulation of Markovian epidemic processes on large and heterogeneous networks
(upper bound)
1 2
3 4
0 43 2
Optimized Gillespie
Actual (effective) rate:
Upper bound:
Rejection step with probability:
Not necessary to update whole neighbourhood of node 4
Potentially large number of rejections
:):(
!31
Rejection probability = Maximal rate - Effective rateMaximal rate
[1] Cota & Ferreira: Optimized Gillespie algorithms for the simulation of Markovian epidemic processes on large and heterogeneous networks
1 2
3 4
0 43 2
!32
Rejection ProbabilitiesMaximal degree: 3Effective degree: 2
Degree: 2Susceptible neighbors: 1
Reject with probabilityReject with probabilityUpper bound
!33
Rejection ProbabilitiesMaximal degree: 3Effective degree: 2
Degree: 2Susceptible neighbors: 1
Reject with probabilityReject with probabilityUpper bound
Rejection step with probability:
!34
Rejection Probabilities
Degree: 2Susceptible neighbors: 1
Reject with probability
(high rejection probability when degree differences are large)
(high rejection probability for many infected nodes)
Maximal degree: 3Effective degree: 2
Reject with probability
Stochastic Simulation Approaches
• Standard Gillespie Algorithm
• Optimized Gillespie Algorithm
• Event-Based Rejection Simulation (Our Method)
35
Event-Driven SimulationIn each step
!36
1. Take first event from event queue.
2. Apply event to the network.
3. Generate new event(s).
Recovery of node 2
Infection from node 1 to 2
Event-Driven Simulation
!37
Infection from node 1 to 2
In each Step1. Take first event from event queue.
2. Check if event is applicable to network:
A. If Yes: apply event - Else: ignore
3. Generate new event(s).
Recovery of node 2
Event-Driven Simulation
!38
In each Step1. Take first event from event queue.
2. Check if event is applicable to network:
A. If Yes: apply event - Else: ignore
3. Generate new event(s) and check the events will be rejected
later.
A. If Yes: go back to 3B. Else: add events(s) to queue
Recovery of node 2
Infection from node 1 to 2
Event-Driven Simulation
!39
In each Step1. Take first event from event queue.
2. Check if event is applicable to network:
A. If Yes: apply event - Else: ignore
3. Generate new event(s) and check the events will be rejected
later.
A. If Yes: go back to 3 B. Else: add events(s) to queue
Late Reject
Early Reject
Algorithm Outline
!40
1 2
3 4
0
1. Generate a curing event for each infected node + annotate node with its curing time
2. Generate an infection attempt for each infected node
Initialization
Algorithm Outline1. Generate a curing event for each infected
node + annotate node with its curing time2. Generate an infection attempt for each
infected node
!41
Initialization
1. Take first event from queue2. If event is applicable:
1. Change node states acc. to event2. Generate two new events in case of infection
3. Else (Late Rejection):1. Generate new infection attempt
In each step1 2
3 4
0
Algorithm Outline
!42
1. Take first event from queue2. If event is applicable:
1. Change node states acc. to event2. Generate two new events in case of infection
3. Else (Late Rejection):1. Generate new infection attempt
1 2
3 4
0
1. Generate a curing event for each infected node + annotate node with its curing time
2. Generate an infection attempt for each infected node
Initialization
In each step
Early and Late Rejections
Generate infection
event
Event might be
successful
No
(Early Rejection)
Add toqueue
Yes
Early and Late Rejections
Generate infection
event
Event might be
successful
Event is applicable to graph
Applyevent
No
(Early Rejection)
Add toqueue No
(Late Rejection)
Yes Yes
Early and Late Rejections
Generate infection
event
Event might be
successful
Event is applicable to graph
Applyevent
No
(Early Rejection)
Add toqueue No
(Late Rejection)
Yes Yes
!Early Rejections are cheaper!
Sample Run
!46
(Initialization)
Sample Run
!47
(Initialization)
Sample Run
!48
(Initialization)
3 will still be infected
Sample Run
!49
(Initialization)
2nd event
Sample Run
!50
(Initialization)
Apply this event
Sample Run
!51
(Iteration)
Recovery of 4
Sample Run
!52
(Iteration)
Sample Run
!53
(Iteration)4 will already be
recovered already
Sample Run
!54
(Iteration)
Event not applicable (late rejection)
Sample Run
!55
(Iteration)
Generate new infection attempt
Sample Run
!56
(Iteration)
!57
Rejection Probabilities
Degree: 2Susceptible neighbors: 1
Reject with probability
(high rejection probability when degree differences are large)
(high rejection probability for many infected nodes)
Upper bound
Maximal degree: 3Effective degree: 2
Reject with probability
Rejection ProbabilitiesThe degree differences are large There are many infected nodes
!58
Event queue(Getting the next event is constant
regardless of degree)
Early Rejections(Infections towards infected neighbours
can be discarded early on)
Generalizations
• Possible for most epidemic models (but not for all)
• Easy for weighted networks
• Easy for temporal networks (for external process which alters network)
• Possible for non-Markovian dynamics (depends on formalism)
!59
Results (SIS)
!60
Results (SIR)
!61
Infected nodes become recovered before becoming susceptible again.
Results (SIR)
!62
Results (competing pathogens)
!63
Pathogen I and Pathogen II compete over susceptible nodes.
Results (competing pathogens)
!64
Conclusion• Not Iterating over a node’s neighbourhood
yields huge performance improvements • Event-based simulation reduces rejection
steps significantly • Exploit problem structure for early rejections • Event-based simulation is very flexible and
easy to adopt to different formalisms
Thank you
Rust Code: github.com/gerritgr/Rejection-Based-Epidemic-Simulation
Correctness (Sketch)• Same as for Optimized Gillespie
• Add shadow rule to system
• Interpret rejections not als rejections but as applications of the shadow rule
• Joint rate attributed to infection and shadow rule is always constant
!66