-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Broken amount of parameters: much more parameters in resulting ODEProblem than symbolic parameters in MTK system #3444
Comments
Well, here is a MRE as well: using ModelingToolkit
# @variables t # use unitless time
D = Differential(t)
@mtkmodel Roessler begin
@parameters begin
a = 0.2
b = 0.2
c = 5.7
end
@variables begin
x(t) = 1.0
y(t) = 0.0
z(t) = 0.0
nlt(t) # nonlinear term
end
@equations begin
D(x) ~ -y -z
D(y) ~ x + a*y
D(z) ~ b + nlt
nlt ~ z*(x - c)
end
end
@mtkbuild model = Roessler()
prob = ODEProblem(model)
prob.p.tunable
this is wrong, clearly only 3 parameters exist. is there a way to ensure that only the existing parameters go into the model? Especially when using |
Indeed, changing to: @mtkbuild model = Roessler() split = false
prob = ODEProblem(model)
prob.p
Where are these extra parameters coming from...? |
What happens here is that you also have the initial values for the unknowns of the model, which are also parameters. In previous versions of MTK they were not included. |
And with #3439 the will move to a separate section in the |
Oh thank god there is a coming fix for that, this is absolutely breaking for me, and may I say it does not make conceptual sense from a dynamical systems point of view to make default values or initial conditions extra parameters. |
also, my initial values are 3, not 4, which is another thing I would consider incorrect. |
I hope the MTK team will consider at least an option so that when |
Why would they not be parameters? If you consider the dynamical system in general, it can be parameterized by initial conditions and you can optimize those. In previous version if we were optimizing the initial conditions we would have passed the unkonwn to
I'm curious why is that needed? |
This statement does not make sense to me. How can the initial condition be a parameter of a dynamical system? Does the initial condition influence the form of the state space? Does it influence the nullclines shapes? Does it influence the speed of motion in the state space? Of course not. Does changing an initial condition change when bifurcations happen for example? of course not. The dynamical system is the whole of the state space. This is what it means to consider the dynamical system "in general". What I think you are calling a "dynamical system" is not the dynamical system in general, but rather a specific trajectory of a it evolved forwards in time and for a finite time window. In this scenario sure you can "optimize" the initial condition so that the trajectory does something else. If your time window is large enough, such an optimization only makes sense in a multistable dynamical system where different initial conditions may converge to different final states. But in a monostable system, what difference does the initial condition make? A parameter change on the other hand has huge impact in both monostable or multistable systems.
You are right, it is not needed, if I always and only access parameters by their symbolic reference. If however, for some reason research related or otherwise, I just want to obtain the whole parameter container and e.g., count how many parameters my system has, then you can imagine how confusing it is to have 80 instead of 25. Imagine writing a paper and needing to make a statement "there are 25 free parameters". You can't count the 25 by hand in a complex real-world system like mine. And as I said above, only for true state variables it makes sense to even consider their starting values. For non-state variables as the |
In any case, if we have contrasting views on what a "parameter" is, it doesn't make sense to argue about it. Everyone can use the definition that fits their needs. My point is: since there is an explicit |
The There is a new For |
I think that the main distinction here is initial value problem vs dynamical system. So when you have the dynamical system, as you said the initial conditions are less relevant, but when you solve an initial value problem, then the initial conditions become parameters. I think this is illustrated in how you go from a See also #3397 for more discussion on the topic 😅 |
That's the perfect way to put it I think. For a dynamical system the initial conditions are not parameters but for the IVP they are. I see people in #3397 having similar problems due to this missmatch. I think this is good evidence that some explicit API function that differentiates is useful. It is good to see that there will be a function So: is there, or will there ever be, a function that returns all parameters generated explicitly via
which is kinda nonsense. It would be better if it erroed with |
This viewpoint also generalizes nicely to a boundary-value problem, where it can make sense to refer to both |
Good point. Staying on the topic of the issue, the issue was closed but this was not answered:
|
And even further, the way the fitting of parameters is done is to treat the entire thing as a single vector that is then solved via a NonlinearLeastSquaresProblem. Formally, parameters are just initial conditions of state values where the derivative are zero. So a "parameter" is just But anyways, details aside:
|
Okay, but can someone please explain: what is the way to obtain all |
MTK has both IIRC this was introduced for parameter dependencies and caused some bugs for a while since it had to be replaced/propagated in a lot of places internally. |
Describe the bug 🐞
I just updated my MTK version and I find an incredible odd behavior. The number of parameters in the MTK model that generates the ODE Problem is much less than the parameters in the ODE Problem itself.
I have
All of my parameters are real numbers so by default they become "tunable", and I have:
This is much more than the actual parameters of my model. Indeed, If I check the symbolic parameters in the MTK System I get
25 parameters is the correct number.
Expected behavior
The number of parameters in the ODE problem should be the same.
There must have been a breaking change because before I updated I didn't have this problem.
Note that I recovered this problem because I build all my models with
split = false
, so that I do NOT create the specialized MTK container, ecll my parameters are real numbers. Even in that case I have the huge missmatch of 70+ parameters in the created ODEProblem even though my system only has 25.What was the change that caused this? Is there perhaps a new API way to obtain the "real" parameters of an ODEProb created from an ODESystem?
Minimal Reproducible Example 👇
If you really need a MRE for this, I'll try to make one from scratch. My codebase is now too complicated to modify it into a MRE. But I doubt a MRE is needed, this seems to be a deliberate change.
Environment (please complete the following information):
using Pkg; Pkg.status()
versioninfo()
1.10.8
The text was updated successfully, but these errors were encountered: