@@ -81,10 +81,10 @@ function DiffEqBase.solve(jump_prob::JumpProblem, alg::SimpleTauLeaping;
8181 interp = DiffEqBase. ConstantInterpolation (t, u))
8282end
8383
84- function compute_hor (nu )
85- hor = zeros (Int, size (nu, 2 ) )
86- for j in 1 : size (nu, 2 )
87- order = sum (abs (stoich) for stoich in nu[:, j] if stoich < 0 ; init= 0 )
84+ function compute_hor (reactant_stoch, numjumps )
85+ hor = zeros (Int, numjumps )
86+ for j in 1 : numjumps
87+ order = sum (stoch for (spec_idx, stoch) in reactant_stoch[j] ; init= 0 )
8888 if order > 3
8989 error (" Reaction $j has order $order , which is not supported (maximum order is 3)." )
9090 end
@@ -100,11 +100,11 @@ function compute_gi(u, nu, hor, i)
100100 if hor[j] == 1
101101 max_gi = max (max_gi, 1 )
102102 elseif hor[j] == 2 || hor[j] == 3
103- stoich = abs (nu[i, j])
104- if stoich >= 2
105- gi = 2 / stoich + 1 / (stoich - 1 )
103+ stoch = abs (nu[i, j])
104+ if stoch >= 2
105+ gi = 2 / stoch + 1 / (stoch - 1 )
106106 max_gi = max (max_gi, ceil (Int, gi))
107- elseif stoich == 1
107+ elseif stoch == 1
108108 max_gi = max (max_gi, hor[j])
109109 end
110110 end
@@ -168,14 +168,16 @@ function DiffEqBase.solve(jump_prob::JumpProblem, alg::SimpleAdaptiveTauLeaping;
168168 t_end = tspan[2 ]
169169 epsilon = alg. epsilon
170170
171- # Extract stoichiometry once from MassActionJump
171+ # Extract stochiometry once from MassActionJump
172172 nu = zeros (float (eltype (u0)), length (u0), numjumps)
173173 for j in 1 : numjumps
174- for (spec_idx, stoich ) in maj. net_stoch[j]
175- nu[spec_idx, j] = stoich
174+ for (spec_idx, stoch ) in maj. net_stoch[j]
175+ nu[spec_idx, j] = stoch
176176 end
177177 end
178- hor = compute_hor (nu)
178+ # Extract reactant stochiometry for hor
179+ reactant_stoch = maj. reactant_stoch
180+ hor = compute_hor (reactant_stoch, numjumps)
179181
180182 # Set up saveat_times
181183 saveat_times = nothing
@@ -202,8 +204,8 @@ function DiffEqBase.solve(jump_prob::JumpProblem, alg::SimpleAdaptiveTauLeaping;
202204 c (du, u_current, p, t_current, counts, nothing )
203205 else
204206 for j in 1 : numjumps
205- for (spec_idx, stoich ) in maj. net_stoch[j]
206- du[spec_idx] += stoich * counts[j]
207+ for (spec_idx, stoch ) in maj. net_stoch[j]
208+ du[spec_idx] += stoch * counts[j]
207209 end
208210 end
209211 end
0 commit comments