-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
Error with MTKParameters and Dual Numbers #2571
Comments
This is known and getting fixed. |
The commit (#e476efa9bf776593896a35d0bf26deeb8a58e68a) that completed this issue uses the internal function The MWE above, using
|
While waiting for the above PR, you can use |
I'll add a tutorial highlighting this particular workflow soon, and the |
Thank you, @AayushSabharwal. I am looking forward to the tutorial, since I was not yet able to implement a working cost function using The documentation of replace in |
The docs are available on master: https://docs.sciml.ai/ModelingToolkit/dev/examples/remake/
|
This looks great, the example seems really helpful and thorough. Thanks! |
Thanks again, @AayushSabharwal for the tutorial. One question that is not answered yet, is how to relate the positions in initial parameters estimates, currently
Note, how
In addition, I have a proposal for a similar example, where only a subset of the tunable parameters is optimized. |
That's a pretty cool trick, thanks for sharing! Note that If you have another example, please feel free to open a PR adding it to the docs. Since your proposed example relates to this new one, I recommend adding it in the same file under a distinct header. |
I should also point out that
is incorrect. Not all parameters in values, repack, alias = SciMLStructures.canonicalize(Tunable(), parameter_values(prob_ind))
values .= eachindex(values)
repack(values) The parameter object will be modified in-place if |
The PR it out for more than a week now with only a discouraging comment by Chris. |
Discouraging? It already got fixed and already got a tutorial? https://docs.sciml.ai/ModelingToolkit/stable/examples/remake/ Could you please be more specific on what you're looking for beyond that? |
Thanks for checking back. An efficient and differentiable updating of only a small subset of parameters is important to me, and I hoped that the new MTK9 infrastructure would aim at supporting this. |
I think I was just sending a message to Aayush 😅 |
It seems that the new MTKParameters system does not work with Dual Numbers from things like Automatic Differentiation. Trying to follow the advice given in the FAQ for using ModelingToolkit with Optimization/AutomaticDifferentiation results in something akin to
MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{OptimizationForwardDiffExt.var"#37#55"{…}, Float64}, Float64, 4})
The other methods in the FAQ (i.e
setter!
and usingSciMLStructures
) results in the same issue. As far as I can tell, it seems that passing a Dual Number intoMTKParameters
causes the problem.The text was updated successfully, but these errors were encountered: