@@ -327,3 +327,33 @@ function make_sub!(eq,states_swaps)
327327 end
328328 return eq
329329end
330+
331+ # ## Converts a reaction system to ODE or SDE problems ###
332+
333+
334+ # ODEProblem from AbstractReactionNetwork
335+ function DiffEqBase. ODEProblem (rs:: ReactionSystem , u0:: Union{AbstractArray, Number} , tspan, p, args... ; kwargs... )
336+ u0 = typeof (u0) <: Array{<:Pair} ? u0 : Pair .(rs. states,u0)
337+ p = typeof (p) <: Array{<:Pair} ? p : Pair .(rs. ps,p)
338+ return ODEProblem (convert (ODESystem,rs),u0,tspan,p, args... ; kwargs... )
339+ end
340+
341+ # SDEProblem from AbstractReactionNetwork
342+ function DiffEqBase. SDEProblem (rs:: ReactionSystem , u0:: Union{AbstractArray, Number} , tspan, p, args... ; kwargs... )
343+ u0 = typeof (u0) <: Array{<:Pair} ? u0 : Pair .(rs. states,u0)
344+ p = typeof (p) <: Array{<:Pair} ? p : Pair .(rs. ps,p)
345+ p_matrix = zeros (length (rs. states), length (rs. eqs))
346+ return SDEProblem (convert (SDESystem,rs),u0,tspan,p,args... ; noise_rate_prototype= p_matrix,kwargs... )
347+ end
348+
349+ # DiscreteProblem from AbstractReactionNetwork
350+ function DiffEqBase. DiscreteProblem (rs:: ReactionSystem , u0:: Union{AbstractArray, Number} , tspan:: Tuple , p= nothing , args... ; kwargs... )
351+ u0 = typeof (u0) <: Array{<:Pair} ? u0 : Pair .(rs. states,u0)
352+ p = typeof (p) <: Array{<:Pair} ? p : Pair .(rs. ps,p)
353+ return DiscreteProblem (convert (JumpSystem,rs), u0,tspan,p, args... ; kwargs... )
354+ end
355+
356+ # JumpProblem from AbstractReactionNetwork
357+ function DiffEqJump. JumpProblem (rs:: ReactionSystem , prob, aggregator, args... ; kwargs... )
358+ return JumpProblem (convert (JumpSystem,rs), prob, aggregator, args... ; kwargs... )
359+ end
0 commit comments