@@ -97,8 +97,10 @@ Generates a DiscreteProblem from an AbstractSystem
97
97
function DiffEqBase. DiscreteProblem (sys:: AbstractSystem , u0map, tspan:: Tuple ,
98
98
parammap= DiffEqBase. NullParameters (); kwargs... )
99
99
u0 = varmap_to_vars (u0map, states (sys))
100
- p = varmap_to_vars (parammap, parameters (sys))
101
- DiscreteProblem (u0, tspan, p; kwargs... )
100
+ p = varmap_to_vars (parammap, parameters (sys))
101
+ f = (du,u,p,t) -> du.= u # identity function to make syms works
102
+ df = DiscreteFunction (f, syms= Symbol .(states (sys)))
103
+ DiscreteProblem (df, u0, tspan, p; kwargs... )
102
104
end
103
105
104
106
"""
@@ -115,18 +117,12 @@ function DiffEqJump.JumpProblem(js::JumpSystem, prob, aggregator; kwargs...)
115
117
pvars = parameters (js)
116
118
statetoid = Dict (convert (Variable,state) => i for (i,state) in enumerate (states (js)))
117
119
parammap = map ((x,y)-> Pair (x (),y),pvars,prob. p)
120
+ eqs = equations (js)
121
+
122
+ foreach (j -> push! (majs, assemble_maj (js, j, statetoid, parammap)), eqs. x[1 ])
123
+ foreach (j -> push! (crjs, assemble_crj (js, j, statetoid)), eqs. x[2 ])
124
+ foreach (j -> push! (vrjs, assemble_vrj (js, j, statetoid)), eqs. x[3 ])
118
125
119
- for j in equations (js)
120
- if j isa ConstantRateJump
121
- push! (crjs, assemble_crj (js, j, statetoid))
122
- elseif j isa VariableRateJump
123
- push! (vrjs, assemble_vrj (js, j, statetoid))
124
- elseif j isa MassActionJump
125
- push! (majs, assemble_maj (js, j, statetoid, parammap))
126
- else
127
- error (" JumpSystems should only contain Constant, Variable or Mass Action Jumps." )
128
- end
129
- end
130
126
((prob isa DiscreteProblem) && ! isempty (vrjs)) && error (" Use continuous problems such as an ODEProblem or a SDEProblem with VariableRateJumps" )
131
127
jset = JumpSet (Tuple (vrjs), Tuple (crjs), nothing , isempty (majs) ? nothing : majs)
132
128
JumpProblem (prob, aggregator, jset)
0 commit comments