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

feat!: do not scalarize parameters, fix some tests #2469

Merged
merged 29 commits into from
Feb 22, 2024

Conversation

AayushSabharwal
Copy link
Member

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Add any other context about the problem here.

@AayushSabharwal AayushSabharwal marked this pull request as ready for review February 15, 2024 18:16
@AayushSabharwal AayushSabharwal force-pushed the as/no-scalarize branch 2 times, most recently from 1b028d5 to c076e60 Compare February 18, 2024 15:01
@ChrisRackauckas
Copy link
Member

format

@AayushSabharwal
Copy link
Member Author

JuliaFormatter is getting updated a lot recently

@AayushSabharwal
Copy link
Member Author

I have the same version of JuliaFormatter as CI, but locally it doesn't complain and here it does?

@AayushSabharwal AayushSabharwal force-pushed the as/no-scalarize branch 2 times, most recently from 220d6c3 to decfb51 Compare February 19, 2024 12:41
@assert all(control -> any(isequal.(control, ps)), controls) "All controls must also be parameters."

deqs = reduce(vcat, scalarize(deqs); init = Equation[])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should never scalarize during construction for MTKv9. We should just follow what I did in #2472

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If one wants a scalarized system for simulation, then one needs to call structural_simplify.

!istree(O) && return vars
if operation(O) === (getindex)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want structural_simplify to work correctly, we have to differentiate x and x[1] alone. https://github.com/SciML/ModelingToolkit.jl/pull/2472/files#diff-47c27891e951c8cd946b850dc2df31082624afdf57446c21cb6992f5f4b74aa2R351-R369 has the correct implementation

@AayushSabharwal
Copy link
Member Author

All tests pass locally 🎉 v9 is good to go (after JuliaSymbolics/Symbolics.jl#1057 is fixed)

@@ -232,7 +232,7 @@ end

function collect_defaults!(defs, vars)
for v in vars
(haskey(defs, v) || !hasdefault(v)) && continue
(haskey(defs, v) || !hasdefault(unwrap(v))) && continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should v ever be wrapped? It will be a pretty hard to catch bug.

@YingboMa
Copy link
Member

We should bound Symbolics to be at least v5.20.0

Project.toml Outdated Show resolved Hide resolved
@ChrisRackauckas ChrisRackauckas merged commit eaecbe3 into SciML:master Feb 22, 2024
13 of 24 checks passed
@AayushSabharwal AayushSabharwal deleted the as/no-scalarize branch February 22, 2024 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants