Closed leeandrepc closed 3 weeks ago
This error seems to be coming from the replace!
call @AayushSabharwal
You can't use replace!
if the types of your parameters change. Here they could be Float64
or ForwardDiff.Dual
. replace!
being in-place won't work with this. replace
is what you want.
@leeandrepc is there a tutorial you got this from? It would be good to update the docs there.
Thanks for the response and guidance. I have been able to get the MWE to work, im assuming for now that my actual model will work too.
My main reference when trying to update the model and debug myself was: Optimizing through an ODE solve and re-creating MTK Problems Although it says on the page multiple times that replace! is for situations without type changes, it was never clear to me what situations would have changes in type fed to replace!, so I never made the connection that that was where my error stemmed from; and I see now on a third read that there is specifically an example that uses AutoFiniteDiff() rather than AutoForwardDiff() because of the type change. So it is probably a me problem.
Secondary references were the Defining OptimizationProblem, and OptimizationFunction pages when trying to debug.
I've been trying to update a model that used to work (I think pre-ModelingToolkit v9.xx.x) to the most recent version of ModelingToolkit v9.49.0. However, when I try to do the parameter optimization part of model it errors and I cannot figure out how to resolve it.
Minimal Reproducible Example 👇
At the Optimization.solve line, it will error out. I can use AutoFiniteDiff, and that will run and output the expected value for A. However the other suggested AD types in documentation will error with various different errors.
I can paste the whole error and stacktrace output if needed, however im running into character limit issues, so for now just have the truncated version here. Error & Stacktrace ⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()
Output of
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
Output of
versioninfo()