-
-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ODEProblem doesn't accept symbolic maps for parameters #922
Comments
Before the fix, using # original dict
p = Dict{Symbol, Any}(
:a => 10.0,
:b => 28.0,
:c => 8/3,
)
# conversion into a named tuple
p = NamedTuple([pair for pair in p])
# solve
prob = ODEProblem(lorenz!,u0,tspan,p)
sol = solve(prob,Tsit5()) |
Yeah the NamedTuple is good. We just need to add a keyword argument to disable the interpretation as a function map, or only do so when a |
I ran into this after updating function lorenz!(du,u,p,t)
@unpack a, b, c = p
du[1] = a*(u[2]-u[1])
du[2] = u[1]*(b-u[3]) - u[2]
du[3] = u[1]*u[2] - c*u[3]
end
u0 = [1.0;0.0;0.0]
p = Dict{Symbol, Any}(
:a => 10.0,
:b => 28.0,
:c => 8/3,
)
tspan = (0.0,100.0)
f = ODEFunction(lorenz!)
prob = ODEProblem(f,u0,tspan,p)
#prob = ODEProblem(lorenz!, u0, tspan, p)
sol = solve(prob,Tsit5()) |
Related to this, I have a model where I adaptively turn parameters on and off when conditions are reached during solving. Because named tuples are immutable, this won't work with the named tuples approach. Also, simply using the order of parameters with p[i] can be frustrating if you're constantly changing the model/have many parameters to keep track of etc. |
@freddie090 you should use ComponentArrays |
There is now a keyword argument to disable or bypass the symbolic form. |
What is that keyword argument, and how/where should it be used? The current error message mentions |
That should be it,, can you share an MWE? |
Solving an ODEProblem with parameters provided in the form of a dictionary
Dict{Symbol, Any}
results in the following error message:ArgumentError: This problem does not support symbolic maps with 'remake', i.e. it does not have a symbolic origin. Please use 'remake' with the 'p' keyword argument as a vector of values, paying attention to parameter order.
Here's a simple example of what I'd like to do:
If I am not mistaken, the above code worked in an earlier DifferentialEquations.jl version. Is there a way to get it work again?
Thank you for your time and effort developing/improving this package!
The text was updated successfully, but these errors were encountered: