Skip to content

Substituting a constant = 1 seems to mutate variable type of certain types of parameters #3487

Closed
JuliaSymbolics/SymbolicUtils.jl
#734
@vyudu

Description

@vyudu

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

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions