@@ -88,7 +88,7 @@ js = convert(JumpSystem, rs)
88
88
@test all (map (i -> typeof (js. eqs[i]) <: DiffEqJump.ConstantRateJump , 15 : 18 ))
89
89
@test all (map (i -> typeof (js. eqs[i]) <: DiffEqJump.VariableRateJump , 19 : 20 ))
90
90
91
- pars = rand (length (k)); u0 = rand (1 : 100 ,4 ); time = rand ();
91
+ pars = rand (length (k)); u0 = rand (1 : 10 ,4 ); time = rand ();
92
92
jumps = Vector {Union{ConstantRateJump, MassActionJump, VariableRateJump}} (undef,length (js. eqs))
93
93
94
94
jumps[1 ] = MassActionJump (pars[1 ], Vector {Pair{Int,Int}} (), [1 => 1 ]);
@@ -117,23 +117,36 @@ jumps[20] = VariableRateJump((u,p,t) -> p[20]*t*u[1]*binomial(u[2],2)*u[3], inte
117
117
statetoid = Dict (convert (Variable,state) => i for (i,state) in enumerate (states (js)))
118
118
parammap = map ((x,y)-> Pair (x (),y),parameters (js),pars)
119
119
for i = 1 : 14
120
- maj = MT. assemble_maj (js, js. eqs[i], statetoid, ModelingToolkit. substituter (first .(parammap), last .(parammap)))
120
+ maj = MT. assemble_maj (js, js. eqs[i], statetoid, ModelingToolkit. substituter (first .(parammap), last .(parammap)), eltype (pars) )
121
121
@test abs (jumps[i]. scaled_rates - maj. scaled_rates) < 100 * eps ()
122
122
@test jumps[i]. reactant_stoch == maj. reactant_stoch
123
123
@test jumps[i]. net_stoch == maj. net_stoch
124
124
end
125
125
for i = 15 : 18
126
126
(i== 16 ) && continue
127
127
crj = MT. assemble_crj (js, js. eqs[i], statetoid)
128
- @test abs (crj. rate (u0,p,time) - jumps[i]. rate (u0,p,time)) < 100 * eps ( )
128
+ @test isapprox (crj. rate (u0,p,time), jumps[i]. rate (u0,p,time))
129
129
fake_integrator1 = (u= zeros (4 ),p= p,t= 0 ); fake_integrator2 = deepcopy (fake_integrator1);
130
130
crj. affect! (fake_integrator1); jumps[i]. affect! (fake_integrator2);
131
131
@test fake_integrator1 == fake_integrator2
132
132
end
133
133
for i = 19 : 20
134
134
crj = MT. assemble_vrj (js, js. eqs[i], statetoid)
135
- @test abs (crj. rate (u0,p,time) - jumps[i]. rate (u0,p,time)) < 100 * eps ( )
135
+ @test isapprox (crj. rate (u0,p,time), jumps[i]. rate (u0,p,time))
136
136
fake_integrator1 = (u= zeros (4 ),p= p,t= 0. ); fake_integrator2 = deepcopy (fake_integrator1);
137
137
crj. affect! (fake_integrator1); jumps[i]. affect! (fake_integrator2);
138
138
@test fake_integrator1 == fake_integrator2
139
139
end
140
+
141
+
142
+ # test for https://github.com/SciML/ModelingToolkit.jl/issues/436
143
+ @parameters t
144
+ @variables S I
145
+ rxs = [Reaction (1 ,[S],[I]), Reaction (1.1 ,[S],[I])]
146
+ rs = ReactionSystem (rxs, t, [S,I], [])
147
+ js = convert (JumpSystem, rs)
148
+ dprob = DiscreteProblem (js, [S => 1 , I => 1 ], (0.0 ,10.0 ))
149
+ jprob = JumpProblem (js, dprob, Direct ())
150
+ sol = solve (jprob, SSAStepper ())
151
+
152
+ nothing
0 commit comments