You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Julia Version 1.11.3
Commit d63adeda50 (2025-01-2119:42 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU:12×12th Gen Intel(R) Core(TM) i7-1265U
WORD_SIZE:64
LLVM: libLLVM-16.0.6 (ORCJIT, alderlake)
Threads:1 default, 0 interactive, 1 GC (on 12 virtual cores)
Environment:
JULIA_EDITOR = code
JULIA_NUM_THREADS =
Additional context
I suspect the changes in system initialization underlie this issue and it may be related to #3318 and #3346.
Using the defaults keyword to specify initial values fixes the issue:
This happens because the default of W is a Num. In hashconsing in isequal_with_metadata, when comparing the metadata of the W thus created and the W with the old default SU can't handle inspecting Nums because it doesn't know they're symbolic and can't unwrap them. So when isequal_with_metadata compares the old 0.5W_max default and new 0.5W_max default it doesn't dispatch to the specialized implementation and falls back to isequal, which of course says the two are equal.
So now the W always has a default of 0.5W_max in which the W_max has a default of 10. Now, when calling ODESystem it inspects the equations to find variables and parameters. Coincidentally, it looks at W first. MTK adds W to the list of unknowns, then inspects inside the default of W to find parameters used therein. Thus it finds the old W_max with a default of 10 and adds it to the list of parameters. When it re-discovers W_max in the equation, MTK ignores it. Then, when parsing defaults from variable metadata MTK looks at the W_max with a default of 10 instead of the one with a default of 2.
I can "fix" this by unwrapping in Symbolics.setdefaultval but this is essentially the same problem that plagues Symbolics CI currently - SU doesn't know Nums are symbolic and treats them like numbers. If SU has an unwrap equivalent it can make sure to unwrap wherever necessary to know it's operating on the right thing.
Describe the bug 🐞
When using parameters in the initial values of a model, all instances of the model keep the parameter values of the first instance.
Expected behavior
The parameter values should comply with those input by the user.
Minimal Reproducible Example 👇
Error & Stacktrace⚠️
Not applicable
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
Manifest
versioninfo()
Additional context
I suspect the changes in system initialization underlie this issue and it may be related to #3318 and #3346.
Using the
defaults
keyword to specify initial values fixes the issue:I'm not sure if I'm simply doing initialization incorrectly with the original MRE or if this is indeed unintended behavior?
The text was updated successfully, but these errors were encountered: