@@ -8,23 +8,7 @@ function regular_rate(out, u, p, t)
88 out[2 ] = 0.01 u[2 ]
99end
1010
11- function regular_c (dc, u, p, t, mark)
12- dc[1 , 1 ] = - 1
13- dc[2 , 1 ] = 1
14- dc[2 , 2 ] = - 1
15- dc[3 , 2 ] = 1
16- end
17-
18- dc = zeros (3 , 2 )
19-
20- rj = RegularJump (regular_rate, regular_c, dc; constant_c = true )
21- jumps = JumpSet (rj)
22-
23- prob = DiscreteProblem ([999.0 , 1.0 , 0.0 ], (0.0 , 250.0 ))
24- jump_prob = JumpProblem (prob, PureLeaping (), rj; rng)
25- sol = solve (jump_prob, SimpleTauLeaping (); dt = 1.0 )
26-
27- const _dc = zeros (3 , 2 )
11+ const dc = zeros (3 , 2 )
2812dc[1 , 1 ] = - 1
2913dc[2 , 1 ] = 1
3014dc[2 , 2 ] = - 1
@@ -46,7 +30,7 @@ sol = solve(jump_prob, SimpleTauLeaping(); dt = 1.0)
4630 u0 = [10 , 5 , 0 ]
4731 tspan = (0.0 , 10.0 )
4832 p = [0.1 , 0.2 ]
49- prob = DiscreteProblem (u0, p, tspan )
33+ prob = DiscreteProblem (u0, tspan, p )
5034
5135 # Create MassActionJump
5236 reactant_stoich = [[1 => 1 ], [1 => 2 ]]
@@ -86,22 +70,24 @@ sol = solve(jump_prob, SimpleTauLeaping(); dt = 1.0)
8670 out[1 ] = p[1 ] * u[1 ]
8771 end
8872
89- function rj_c (dc, u, p, t, mark)
90- dc[1 , 1 ] = - 1
91- dc[3 , 1 ] = 1
73+ rj_dc = zeros (3 , 1 )
74+ rj_dc[1 , 1 ] = - 1
75+ rj_dc[3 , 1 ] = 1
76+
77+ function rj_c (du, u, p, t, counts, mark)
78+ mul! (du, rj_dc, counts)
9279 end
9380
94- rj_dc = zeros (3 , 1 )
95- regj = RegularJump (rj_rate, rj_c, rj_dc; constant_c = true )
81+ regj = RegularJump (rj_rate, rj_c, 1 )
9682
9783 jp_pure_regj = JumpProblem (prob, PureLeaping (), JumpSet (regj))
9884 @test jp_pure_regj. aggregator isa PureLeaping
9985 @test jp_pure_regj. discrete_jump_aggregation === nothing
10086 @test jp_pure_regj. regular_jump != = nothing
10187
10288 # Test mixed jump types
103- mixed_jumps = JumpSet (; massaction_jumps = maj, constant_jumps = crj,
104- variable_jumps = vrj, regular_jumps = regj)
89+ mixed_jumps = JumpSet (; massaction_jumps = maj, constant_jumps = ( crj,) ,
90+ variable_jumps = ( vrj,) , regular_jumps = regj)
10591 jp_pure_mixed = JumpProblem (prob, PureLeaping (), mixed_jumps)
10692 @test jp_pure_mixed. aggregator isa PureLeaping
10793 @test jp_pure_mixed. discrete_jump_aggregation === nothing
@@ -119,8 +105,8 @@ sol = solve(jump_prob, SimpleTauLeaping(); dt = 1.0)
119105 hopping_constants = hopping_consts)
120106
121107 # Test MassActionJump with parameter mapping
122- param_mapper = MassActionJumpParamMapper ([1 , 2 ])
123- maj_params = MassActionJump (reactant_stoich, net_stoich, param_mapper)
108+ maj_params = MassActionJump (reactant_stoich, net_stoich; param_idxs = [1 , 2 ])
124109 jp_params = JumpProblem (prob, PureLeaping (), JumpSet (maj_params))
125- @test jp_params. massaction_jump. scaled_rates == p
110+ scaled_rates = [p[1 ], p[2 ]/ 2 ]
111+ @test jp_params. massaction_jump. scaled_rates == scaled_rates
126112end
0 commit comments