Skip to main content Accessibility help
×
Hostname: page-component-89b8bd64d-shngb Total loading time: 0 Render date: 2026-05-07T21:34:27.683Z Has data issue: false hasContentIssue false

Gillespie Algorithms for Stochastic Multiagent Dynamics in Populations and Networks

Published online by Cambridge University Press:  12 December 2022

Naoki Masuda
Affiliation:
State University of New York at Buffalo and Waseda University 
Christian L. Vestergaard
Affiliation:
Institut Pasteur, CNRS, Paris

Summary

Many multiagent dynamics can be modeled as a stochastic process in which the agents in the system change their state over time in interaction with each other. The Gillespie algorithms are popular algorithms that exactly simulate such stochastic multiagent dynamics when each state change is driven by a discrete event, the dynamics is defined in continuous time, and the stochastic law of event occurrence is governed by independent Poisson processes. The first main part of this volume provides a tutorial on the Gillespie algorithms focusing on simulation of social multiagent dynamics occurring in populations and networks. The authors clarify why one should use the continuous-time models and the Gillespie algorithms in many cases, instead of easier-to-understand discrete-time models. The remainder of the Element reviews recent extensions of the Gillespie algorithms aiming to add more reality to the model (i.e., non-Poissonian cases) or to speed up the simulations. This title is also available as open access on Cambridge Core.

Information

Figure 0

Figure 1 Rules of state changes in the SIR model. An infectious individual infects a susceptible neighbor at a rate β. Each infectious individual recovers at a rate μ.

Figure 1

Figure 2 Stochastic SIR process on a square-grid network with six nodes. (a) Status of the network at an arbitrary time t. (b) Status of the network after v4 has recovered. The values attached to the nodes indicate the rates of the events that the nodes may experience next.

Figure 2

Figure 3 A susceptible node and other nodes surrounding it. (a) A susceptible node vi surrounded by three infectious nodes. (b) A susceptible node vi surrounded by five nodes in different states.

Figure 3

Figure 4 Superposition of three Poisson processes. The event sequence in the bottom is the superposition of the three event sequences corresponding to each of the three edges connecting vi to its neighbors vj, vj′, and vj′′. The superposed event sequence generates an event whenever one of the three individual processes does. Note that edges (vi, vj), (vi, vj′), and (vi, vj′′) generally carry different numbers of events in a given time window despite the rate of the processes (i.e., the infection rate, β) being the same. This is due to the stochastic nature of Poisson processes.

Figure 4

Figure 5 Determination of the time to the next event in the SIR model using the Gillespie algorithms. (a) The current state of the system. The rate with which each node changes its state is shown next to the node. (b) The putative events generated by the Poisson process corresponding to each node, with the first event of each process shown in magenta. There is no event on the timeline of v6. This is because v6 is in the recovered state and no longer undergoes any state change; therefore the event rate of the Poisson process associated with v6 is equal to 0. The first reaction method generates a putative waiting time until the first event for each process and selects the smallest one. The direct method directly generates the waiting time until the first event in the superposed process (bottom of panel (b)).

Figure 5

Figure 6 Superposition of Poisson processes and how to determine which component Poisson processes contribute to an event in the superposed event sequence. We consider M=2 Poisson processes, one with rate λ1=2β and the other with λ2=β. The superposed Poisson process has rate λ1+λ2=3β. The next event in the superposed event sequence (shown in the dotted circle) belongs to process 1 with probability Π1=λ1/(λ1+λ2)=2/3 and process 2 with probability Π2=λ2/(λ1+λ2)=1/3.

Figure 6

Figure 7 Complete graph with N=7 nodes.

Figure 7

Figure 8 Linear search method for computing which Poisson process produces the next event for the entire population. We consider M=4 possible events, with respective rates λ1=0.5, λ2=2, λ3=1, and λ4=1.5. Suppose that we draw a uniform random variate ranging between 0 and ∑i=1Mλi=5 whose value is u=2.625. We first check whether u falls inside the first interval; in practice, we check if u≤λ1=0.5. Because this is not the case, we then check iteratively if it lies in each following interval. Because 2.5, we find that u falls in the third interval from the left (dotted arrow). The iteration over i as described in Step 2 in Box 3 thus stops in the third interval, and the method will select i=3.

Figure 8

Figure 9 Evolution of the number of infectious individuals NI over time of the SIR model in a well-mixed population simulated using (a) the rejection sampling method, (b) the first reaction method, and (c) the direct method. The population is composed of N=100 individuals. The infection rate is β=0.5. The recovery rate is μ=0.2. We carried out 1 000 simulations with each method. Each panel shows the number of infectious individuals over time. The overlapping thin red lines show the result for each of the 1 000 simulations. The thick black lines show the average over the 1 000 simulations. Note that a substantial portion of the simulations do not lead to any secondary infections; the red lines drop rapidly to zero, appearing as straight red lines at NI=0. Otherwise, NI increases first and then decays towards zero. The average behavior does not capture this bimodal nature of the stochastic dynamics.

Figure 9

Figure 10 Diagram of the state of each node undergoing the SIR dynamics. Out of the N=100 nodes, 40 nodes are susceptible and have three infectious neighbors (and other susceptible or recovered neighbors), 20 nodes are susceptible and have two infectious neighbors, 30 nodes are infectious, and 10 nodes are recovered.

Figure 10

Figure 11 Binary tree for drawing i from a discrete distribution {λ1,…,λM}. We assume M=8. (a) General case. (b) An example. The value in each nonleaf node of the tree is equal to the sum of its two child nodes’ values. There are log2M+1=4 hierarchical levels.

Figure 11

Figure 12 Indexed priority queue for storing putative reaction times in the next reaction method. (a) Example of an indexed priority queue. The indexed priority queue consists of a binary heap (top) and an index array (bottom). The binary heap contains tuples (i,tiput), where i is the reaction channel number and tiput the putative time when it would generate its next event. The nodes in the binary heap are ordered vertically by the value of tiput they store. The index array points to the node in the binary heap that corresponds to each reaction channel. (b) Configuration of the indexed priority queue after the value of t7put has been updated to 2.9 and the values stored in the nodes have been rearranged to satisfy the vertical ordering of the tiput values. All entries of the binary heap and the index array that the updating has affected are marked in red.

Figure 12

Figure 13 Bar graph for the composition and rejection algorithm. The height of each bar represents Πi. Like in Fig. 8, we assume N=4, Π1=0.1, Π2=0.4, Π3=0.2, and Π4=0.3. The two points uniformly randomly sampled from the dotted rectangle are shown by a circle and triangle.

Figure 13

Figure 14 Time courses of the fraction of the susceptible, infectious, and recovered nodes obtained from two runs of the SIR model. We set β=0.6 and μ=3. We used a regular random graph with N=1000 nodes and the nodes’ degree equal to five. In other words, each node has degree 5, and apart from that, we connect the nodes uniformly at random according to the configuration model (Fosdick et al., 2018). The network is the same for the two runs shown in (a) and (b). Each run started from the same initial condition in which a particular node was infectious and the other N−1 nodes were susceptible.

Figure 14

Figure 15 A metapopulation model network with N˜=6 patches and N=25 individuals. As in the previous similar figures, the blue, red, and brown circles represent susceptible, infectious, and recovered individuals, respectively.

Figure 15

Figure 16 Schematic of the voter model on a network.

Figure 16

Figure 17 Time courses of the fraction of the nodes with opinion A in the voter model in three different simulations. We use a regular random graph with nodes’ degree equal to five. We set (a) N=100 and (b) N=1000. We set βA→B=βB→A=1. Each run started from the initial condition in which half the nodes were in opinion A and the other half were in opinion B. The results for three runs are shown in different colors in each panel.

Figure 17

Figure 18 Rules of the stochastic Lotla–Volterra model with one prey species and one predator species.

Figure 18

Figure 19 Number of rabbits and foxes for two different runs of the stochastic Lotka–Volterra model in a well-mixed population. In both (a) and (b), we set α=30, β=0.1, μ=30, and there are initially Nrab=80 rabbits and Nfox=20 foxes.

Figure 19

Figure 20 Schematic of a “switching” temporal network with N=4 nodes. The network switches from one static graph to another at discrete points in time.

Figure 20

Figure 21 Survival probability of interevent times between face-to-face encounters. Solid black line: empirical data; dashed blue line: exponential distribution having the same mean as that of the empirical data. The empirical data come from the “Primary School” data set from the SocioPatterns project (Isella et al., 2011). Events are face-to-face proximity relationships between an individual and other individuals in the school. We show the survival probability, that is, Ψ(τ)=∫τ∞ψ(τ′)dτ′, instead of the distribution of interevent times, ψ(τ), because Ψ(τ) is more robust to noise in data. In other words, the vertical axis represents the fraction of the interevent times that are larger than the value specified on the horizontal axis. We selected the individual with the largest number of events and calculated all the interevent times for the selected individual. We omitted the largest interevent time, which is more than 10 times larger than the second largest one. The survival probability of the exponential distribution is given by Ψ(τ)=∫τ∞λe−λτ′dτ′=e−λτ.

Figure 21

Figure 22 Schematic definition of the different notions of times employed in this section and the relations between them.

Figure 22

Figure 23 Schematic showing a mixture of exponential distributions and the mechanism of the Laplace Gillespie algorithm. One draws λ1, λ2, and so forth from p(λ). The probability density function p(λ) is called the mixing weight distribution, representing how probable each value of λ is to be drawn. Once a λ value is drawn, one generates the time to the next time, τ, according to the exponential distribution λe−λτ. As a result, one mixes exponential distributions with mixing weights p(λ) to obtain the distribution of interevent times, ψ(τ). Although each component distribution is an exponential distribution, the mixture may yield a fat-tailed distribution.

Figure 23

Figure 24 Three power-law distributions: the distribution given by Eq. (5.26) with α=1 and κ=1, a Pareto distribution with α=1 and τ0=1, and a half-Cauchy distribution. Note that the three distributions follow the same asymptotic power law, ψ(τ)∝τ−2, as τ→∞.

Figure 24

Figure 25 Comparison between the non-Markovian Gillespie algorithm and the Laplace Gillespie algorithm. We use a power-law distribution of interevent times ψ(τ)=α/(1+τ)α+1 with α=1.5. (a) M=10. (b) M=100. For each algorithm, the survival function of the interevent time distribution is plotted for just one of the M processes and compared against the ground truth, that is, Ψ(τ)=1/(1+τ)α.

Save element to Kindle

To save this element to your Kindle, first ensure no-reply@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Gillespie Algorithms for Stochastic Multiagent Dynamics in Populations and Networks
Available formats
×

Save element to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Gillespie Algorithms for Stochastic Multiagent Dynamics in Populations and Networks
Available formats
×

Save element to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Gillespie Algorithms for Stochastic Multiagent Dynamics in Populations and Networks
Available formats
×