Skip to content

Commit eb329c2

Browse files
fix: fix creation of JumpProblems with no parameters
1 parent 9ed933a commit eb329c2

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/systems/jumps/jumpsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ end
508508
function JumpSysMajParamMapper(js::JumpSystem, p; jseqs = nothing, rateconsttype = Float64)
509509
eqs = (jseqs === nothing) ? equations(js) : jseqs
510510
paramexprs = [maj.scaled_rates for maj in eqs.x[1]]
511-
psyms = reduce(vcat, reorder_parameters(js, parameters(js)))
511+
psyms = reduce(vcat, reorder_parameters(js, parameters(js)); init = [])
512512
paramdict = Dict(value(k) => value(v) for (k, v) in zip(psyms, vcat(p...)))
513513
JumpSysMajParamMapper{typeof(paramexprs), typeof(psyms), rateconsttype}(paramexprs,
514514
psyms,

test/jumpsystem.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,32 @@ let
231231
jtoj = eqeq_dependencies(jdeps, vdeps).fadjlist
232232
@test jtoj == [[1, 2, 4], [1, 2, 4], [1, 2, 3, 4], [1, 2, 3, 4]]
233233
end
234+
235+
# Create JumpProblems for systems without parameters
236+
# Issue#2559
237+
@parameters k
238+
@variables X(t)
239+
rate = k
240+
affect = [X ~ X - 1]
241+
242+
crj = ConstantRateJump(1.0, [X ~ X - 1])
243+
js1 = complete(JumpSystem([crj], t, [X], [k]; name = :js1))
244+
js2 = complete(JumpSystem([crj], t, [X], []; name = :js2))
245+
246+
maj = MassActionJump(1.0, [X => 1], [X => -1])
247+
js3 = complete(JumpSystem([maj], t, [X], [k]; name = :js2))
248+
js4 = complete(JumpSystem([maj], t, [X], []; name = :js3))
249+
250+
u0 = [X => 10]
251+
tspan = (0.0, 1.0)
252+
ps = [k => 1.0]
253+
254+
dp1 = DiscreteProblem(js1, u0, tspan, ps)
255+
dp2 = DiscreteProblem(js2, u0, tspan)
256+
dp3 = DiscreteProblem(js3, u0, tspan, ps)
257+
dp4 = DiscreteProblem(js4, u0, tspan)
258+
259+
jp1 = JumpProblem(js1, dp1, Direct())
260+
jp2 = JumpProblem(js2, dp2, Direct())
261+
jp3 = JumpProblem(js3, dp3, Direct())
262+
jp4 = JumpProblem(js4, dp4, Direct())

0 commit comments

Comments
 (0)