Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

structural_simplify broken for some underdetermined NonlinearSystems #2786

Open
AayushSabharwal opened this issue Jun 10, 2024 · 4 comments
Open
Assignees
Labels
bug Something isn't working linearization

Comments

@AayushSabharwal
Copy link
Member

Describe the bug 🐞

Some underdetermined nonlinear systems when simplified have a variable that only occurs on the RHS of observed equations, but is also not an unknown. Thus, it has no value assigned to it and errors.

Expected behavior

The variable should be on the LHS of an observed equation or be an unknown.

Minimal Reproducible Example 👇

Using the model in https://github.com/SciML/ModelingToolkit.jl/blob/master/test/downstream/inversemodel.jl,

@named model = InverseControlledTank()
get_sensitivity(model, :y)

Error & Stacktrace ⚠️

ERROR: UndefVarError: `filter₊x(t)[1]ˍtt` not defined
Stacktrace:
  [1] macro expansion
    @ ~/.julia/packages/SymbolicUtils/0opve/src/code.jl:375 [inlined]
  [2] macro expansion
    @ ~/.julia/packages/RuntimeGeneratedFunctions/M9ZX8/src/RuntimeGeneratedFunctions.jl:163 [inlined]
  [3] macro expansion
    @ ./none:0 [inlined]
  [4] generated_callfunc
    @ ./none:0 [inlined]
  [5] (::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{…})(::Vector{…}, ::Vector{…}, ::Vector{…})
    @ RuntimeGeneratedFunctions ~/.julia/packages/RuntimeGeneratedFunctions/M9ZX8/src/RuntimeGeneratedFunctions.jl:150
  [6] f
    @ ~/.julia/packages/ModelingToolkit/3Suzf/src/systems/nonlinear/nonlinearsystem.jl:292 [inlined]
  [7] NonlinearFunction
    @ ~/.julia/packages/SciMLBase/roUH9/src/scimlfunctions.jl:2297 [inlined]
  [8] evaluate_f(prob::NonlinearLeastSquaresProblem{…}, u::Vector{…})
    @ NonlinearSolve ~/.julia/packages/NonlinearSolve/m8oNC/src/internal/helpers.jl:7
  [9] __init(::NonlinearLeastSquaresProblem{…}, ::NonlinearSolve.GeneralizedFirstOrderAlgorithm{…}; stats::SciMLBase.NLStats, alias_u0::Bool, maxiters::Int64, abstol::Nothing, reltol::Nothing, maxtime::Nothing, termination_condition::Nothing, internalnorm::Function, linsolve_kwargs::@NamedTuple{}, kwargs::@Kwargs{})
    @ NonlinearSolve ~/.julia/packages/NonlinearSolve/m8oNC/src/core/generalized_first_order.jl:164
 [10] __init
    @ ~/.julia/packages/NonlinearSolve/m8oNC/src/core/generalized_first_order.jl:154 [inlined]
 [11] __solve(::NonlinearLeastSquaresProblem{…}, ::NonlinearSolve.GeneralizedFirstOrderAlgorithm{…}; stats::SciMLBase.NLStats, kwargs::@Kwargs{})
    @ NonlinearSolve ~/.julia/packages/NonlinearSolve/m8oNC/src/core/generic.jl:3
 [12] __solve
    @ ~/.julia/packages/NonlinearSolve/m8oNC/src/core/generic.jl:1 [inlined]

Environment (please complete the following information):

MTK downstream environment

@AayushSabharwal AayushSabharwal added the bug Something isn't working label Jun 10, 2024
@ChrisRackauckas
Copy link
Member

Test this on latest master with the new fixes.

@AayushSabharwal
Copy link
Member Author

Still broken

@ChrisRackauckas
Copy link
Member

@AayushSabharwal looks like this issue is back to you now, some issue with the p_getter. Then I think we should add it as a test.

@AayushSabharwal
Copy link
Member Author

The p_getter issue and another one are fixed in #2912 but the original issue here still exists with the same error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linearization
Projects
None yet
Development

No branches or pull requests

3 participants