Convenient parameter change for remake ODEProblem made with ODESystem

I’m creating an ODESystem using ModelingToolkit.jl and was wondering if for EnsembleProblems there is an easier way to specify the parameters in remake.

Example, from the documentation of ModelingToolkit:

using ModelingToolkit
using DifferentialEquations

@variables t x(t) RHS(t)
@parameters τ 
D = Differential(t)

@named fol_separate = ODESystem([ RHS  ~ (1 - x)/τ,
                                  D(x) ~ RHS ])

tspan = (0.0, 10.0)
u0 = [x => 0.0]
p = [τ => 3.0]

prob = ODEProblem(structural_simplify(fol_separate), u0, tspan, p)

τs  = range(0.1,10,length = 10)

For an EnsembleProblem I create a function to modify the problem with remake

function prob_func(prob,i,repeat)
   remake(prob, p = [τs[i]])
end

And then specify and solve the EnsembleProblem

ens_prob = EnsembleProblem(prob, prob_func = prob_func)
sim = solve(ens_prob, Tsit5(), EnsembleThreads(), trajectories = size(τs)[1])

This is fine for smaller problems, but for systems with more parameters I first have to check the order with parameters(fol_separate) and then manually type it out in the correct order in prob_func. This is rather cumbersome and prone to errors for systems with more parameters.
Is there some more convenient method to assign the changed parameters for remake?
E.g. something like remake(prob, p = [τ => 0.1]); which I know doesn’t work because p can’t be a vector{Pair}.

Summarizing:
I’m looking for a way to remake an ODEProblem created with an ODESystem where in remake I can specify which parameter to change, instead of typing out the p = [...] array

https://mtk.sciml.ai/dev/basics/FAQ/#Transforming-value-maps-to-arrays

1 Like

That clears that up, thanks.