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
I'm really not sure what's going on here, but the variable type of Initial(p) seems to be silently changed to variable instead of parameter when substituting h = 1. This doesn't happen when any number other than 1 is substituted, or for normal parameters.
@constants h =1@variables x
eq = x ~ h *Initial(x)
dvs =Set(); ps =Set()
ModelingToolkit.collect_vars!(dvs, ps, eq, nothing; op = Initial) # dvs = Set(x), ps = Set(Initial(x))empty!(dvs); empty!(ps)
eq = Symbolics.substitute(eq, h =>1) # eq = x ~ Initial(x)
ModelingToolkit.collect_vars!(dvs, ps, eq, nothing; op = Initial) # dvs = Set(x, Initial(x)), ps = Set()
ModelingToolkit.isparameter(eq.rhs) # false
on 9.65.0
The text was updated successfully, but these errors were encountered:
This isn't hashconsing, it's a bug in substitute. When substituting h => 1, it ends up in a state where
expr = h *Initial(x)
op =*
args = [1, Initial(x)] # values after substitution into `expr`
It then calls maketerm(typeof(expr), op, args, metadata(expr)). The problem is that this turns 1 * Initial(x) into Initial(x), then sets the metadata of the result to metadata(expr), which erases the parameter metadata from Initial(x).
I'm really not sure what's going on here, but the variable type of
Initial(p)
seems to be silently changed to variable instead of parameter when substituting h = 1. This doesn't happen when any number other than 1 is substituted, or for normal parameters.on 9.65.0
The text was updated successfully, but these errors were encountered: