Skip to content

subset_tunables seems to modify the system in-place #3921

@SebastianM-C

Description

@SebastianM-C

Describe the bug 🐞

The original system appears modified after using subset_tunables. As I understand this operation should be out of place. The modification is that tunable_parameters returns the reduced set of parameters instead of the original one.

Expected behavior

The output of tunable_parameters should not change after using subset_tunables.

Minimal Reproducible Example 👇

using ModelingToolkit
using ModelingToolkit: D_nounits as D, t_nounits as t

@parameters α = 1.5 β = 1.0 γ = 3.0 δ = 1.0
@variables x(t) y(t)

eqs = [D(x) ~ α * x - β * x * y,
    D(y) ~ -γ * y + δ * x * y]

model = System(eqs, t, name=:sys)

sys = mtkcompile(model)

tunable_parameters(sys) # 8-element Vector{Any}

subset_tunables(sys, [α])

tunable_parameters(sys) # 5-element Vector{Any}

Error & Stacktrace ⚠️

the first call to tunable_parameters shows

8-element Vector{Any}:
 α
 β
 δ
 γ
 Initial(x(t))
 Initial(yˍt(t))
 Initial(xˍt(t))
 Initial(y(t))

the second

5-element Vector{Any}:
 α
 Initial(x(t))
 Initial(yˍt(t))
 Initial(xˍt(t))
 Initial(y(t))

Environment (please complete the following information):

  • Output of using Pkg; Pkg.status()
ModelingToolkit v10.22.0
  • Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
  • Output of versioninfo()

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    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