@@ -105,19 +105,37 @@ jprob = JumpProblem(prob,Direct(),jset, save_positions=(false,false))
105
105
m2 = getmean (jprob,Nsims)
106
106
107
107
# test JumpSystem solution agrees with direct version
108
- @test abs (m- m2) ./ m < .01
108
+ @test abs (m- m2)/ m < .01
109
109
110
110
111
111
# mass action jump tests for SIR model
112
112
maj1 = MassActionJump (2 * β/ 2 , [S => 1 , I => 1 ], [S => - 1 , I => 1 ])
113
113
maj2 = MassActionJump (γ, [I => 1 ], [I => - 1 , R => 1 ])
114
- js = JumpSystem ([maj1,maj2], t, [S,I,R], [β,γ])
114
+ js3 = JumpSystem ([maj1,maj2], t, [S,I,R], [β,γ])
115
115
statetoid = Dict (convert (Variable,state) => i for (i,state) in enumerate (states (js)))
116
116
ptoid = Dict (convert (Variable,par) => i for (i,par) in enumerate (parameters (js)))
117
- dprob = DiscreteProblem (js , u₀map, tspan, parammap)
118
- jprob = JumpProblem (js , dprob, Direct ())
117
+ dprob = DiscreteProblem (js3 , u₀map, tspan, parammap)
118
+ jprob = JumpProblem (js3 , dprob, Direct ())
119
119
m3 = getmean (jprob,Nsims)
120
- @test abs (m2 - m3) < .01
120
+ @test abs (m - m3)/ m < .01
121
121
122
- # mass action jump tests for other reaction types (zero order, second order, decay)
123
- # TODO
122
+ # mass action jump tests for other reaction types (zero order, decay)
123
+ maj1 = MassActionJump (2.0 , [0 => 1 ], [S => 1 ])
124
+ maj2 = MassActionJump (γ, [S => 1 ], [S => - 1 ])
125
+ js4 = JumpSystem ([maj1,maj2], t, [S], [β,γ])
126
+ statetoid = Dict (convert (Variable,state) => i for (i,state) in enumerate (states (js)))
127
+ ptoid = Dict (convert (Variable,par) => i for (i,par) in enumerate (parameters (js)))
128
+ dprob = DiscreteProblem (js4, [S => 999 ], (0 ,1000. ), [β => 100. ,γ => .01 ])
129
+ jprob = JumpProblem (js4, dprob, Direct ())
130
+ m4 = getmean (jprob,Nsims)
131
+ @test abs (m4 - 2.0 / .01 )* .01 / 2.0 < .01
132
+
133
+ # test second order rx runs
134
+ maj1 = MassActionJump (2.0 , [0 => 1 ], [S => 1 ])
135
+ maj2 = MassActionJump (γ, [S => 2 ], [S => - 1 ])
136
+ js4 = JumpSystem ([maj1,maj2], t, [S], [β,γ])
137
+ statetoid = Dict (convert (Variable,state) => i for (i,state) in enumerate (states (js)))
138
+ ptoid = Dict (convert (Variable,par) => i for (i,par) in enumerate (parameters (js)))
139
+ dprob = DiscreteProblem (js4, [S => 999 ], (0 ,1000. ), [β => 100. ,γ => .01 ])
140
+ jprob = JumpProblem (js4, dprob, Direct ())
141
+ sol = solve (jprob, SSAStepper ())
0 commit comments