290 7 Simulating Biochemical Systems
The essence of the approach is to group together reactions with similar propensities
and select a group before selecting an individual reaction from within that group.
Each group has a lower-bound for the propensities of the reactions it contains. If
lwb(g) is the lower-bound propensity for group g, then a reaction with propensity
a
i
is placed in group g
n
, such that, lwb(g
n
)<= a
i
< lwb(g
n+1
). Successive pow-
ers of 2 times the minimum possible non-zero propensity value (a
min
) are used as
the boundary values for groups. The boundary values remain fixed for a particular
simulation run, but a reaction may move between groups as its propensity varies.
By grouping reactions in this way, much of the dependence of the algorithm on the
number of reactions, M, is removed, and hence a scaling independent of M becomes
possible. However, there are two assumptions required:
• The ratio of maximum to minimum probability for any two reactions must be
bounded.
• The average number of dependencies between reactions must remain fairly con-
stant and not grow in proportion to the total number of reactions.
Figure 7.9 shows an outline of the SSA-CR method.
7.3.1 Selection Procedure
The selection of the right group is based on the approach outlined in (7.2)forre-
action selection in Gillespie’s first reaction method. However, the implementation
illustrated in the findReaction method in Code 7.3 is a linear summation and
search, which is not particularly efficient—indeed, it is one of the elements that
contributes to the unoptimized first reaction method being O(M). An alternative,
which is applicable to both the first reaction method and the SSA-CR method, is to
store cumulative propensity values in a binary tree. In SSA-CR, the leaves corre-
spond to groups and store the sums of the reaction propensities within each group,
whereas in the first reaction method the leaves store the individual reaction propen-
sities. Each parent node stores the sum of the values in its two child nodes. As a
result, the root of the tree stores the sum of all group (and, therefore, all reaction)
propensities: a
0
. We can use the same style of tree implementation as that for the
indexed priority queue discussed in Sect. 7.2.2. An important difference is that the
propensity tree is not sorted; the leaves can be stored in group-number order, and
changes to propensities only result in node values changing rather than the tree
being reordered. Code 7.8 illustrates how the tree is constructed. For the sake of
simplicity, we assume that the number of groups, G, is a power of two, rounding
up and padding with empty groups at the upper end if necessary. The depth of the
tree is log
2
G, requiring 2
depth+1
− 1 nodes. The initial state of the tree is calcu-
lated by storing the group propensity values in the leaves, and then recursively sum-
ming the child values up to the root in the calculatePropensityChildren
method.
On each iteration of SSA-CR, the selection of the group using r
2
a
0
is performed
by working down from the root of the tree. If r
2
a
0
is less than the value in the left