-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
ChrisRackauckas
merged 29 commits into
SciML:master
from
AayushSabharwal:as/no-scalarize
Feb 22, 2024
Merged
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
298c29c
Array equations/variables support in `structural_simplify`
YingboMa 75d343f
Support array states in ODEProblem/ODEFunction
YingboMa ae6bd49
feat: scalarize equations in ODESystem, fix vars! and namespace_expr
AayushSabharwal 0287c1d
feat!: do not scalarize parameters, fix some tests
AayushSabharwal 36388d0
test: fix test file paths
AayushSabharwal f9f7ae1
refactor: support clock systems without index caches
AayushSabharwal 1591342
test: test callbacks without parameter splitting
AayushSabharwal f48d30d
refactor: format
AayushSabharwal 6abcc49
refactor: disable treating symbolic defaults as param dependencies
AayushSabharwal 9eb96a5
feat: add support for parameter dependencies
AayushSabharwal 55f2730
docs: update NEWS with parameter dependencies
AayushSabharwal c26d4d9
feat: un-scalarize inferred parameters, improve parameter initialization
AayushSabharwal 812e004
feat: flatten equations to avoid scalarizing array arguments
AayushSabharwal 059f6e8
fix formatting
ChrisRackauckas 55cd1d8
fix typo
ChrisRackauckas 0c26977
fix: fix `vars!`
AayushSabharwal 8d7c677
fix: refactor IndexCache for non-scalarized unknowns
AayushSabharwal 9e2c9bc
fix: do not call flatten_equations in JumpSystem
AayushSabharwal a6add74
fix: handle broadcasted equations and array variables in ODESystem co…
AayushSabharwal a41a64f
fix: use variable_index in calculate_massmatrix
AayushSabharwal c6c96dd
fix: do not scalarize in system constructors
AayushSabharwal d7265c1
test: fix mass matrix tests
AayushSabharwal 1275d6e
fixup! fix: fix `vars!`
AayushSabharwal 3e0aea0
fix: fix IndexCache to not put matrices as nonnumeric parameters
AayushSabharwal 1218152
feat: add copy method for MTKParameters
AayushSabharwal 9d5c211
Skip partial_state_selection test
YingboMa 7ce0f57
format
ChrisRackauckas 703da35
Update Project.toml
ChrisRackauckas 3ede8ff
Update Project.toml
ChrisRackauckas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -342,25 +342,28 @@ v == Set([D(y), u]) | |
function vars(exprs::Symbolic; op = Differential) | ||
istree(exprs) ? vars([exprs]; op = op) : Set([exprs]) | ||
end | ||
vars(exprs::Num; op = Differential) = vars(unwrap(exprs); op) | ||
vars(exprs::Symbolics.Arr; op = Differential) = vars(unwrap(exprs); op) | ||
vars(exprs; op = Differential) = foldl((x, y) -> vars!(x, y; op = op), exprs; init = Set()) | ||
vars(eq::Equation; op = Differential) = vars!(Set(), eq; op = op) | ||
function vars!(vars, eq::Equation; op = Differential) | ||
(vars!(vars, eq.lhs; op = op); vars!(vars, eq.rhs; op = op); vars) | ||
end | ||
function vars!(vars, O; op = Differential) | ||
if isvariable(O) | ||
if isvariable(O) && !(istree(O) && operation(O) === getindex) | ||
return push!(vars, O) | ||
end | ||
|
||
!istree(O) && return vars | ||
if operation(O) === (getindex) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we want |
||
arr = first(arguments(O)) | ||
return vars!(vars, arr) | ||
end | ||
|
||
operation(O) isa op && return push!(vars, O) | ||
|
||
if operation(O) === (getindex) && | ||
isvariable(first(arguments(O))) | ||
return push!(vars, O) | ||
end | ||
|
||
isvariable(operation(O)) && push!(vars, O) | ||
|
||
for arg in arguments(O) | ||
vars!(vars, arg; op = op) | ||
end | ||
|
@@ -807,7 +810,7 @@ end | |
function fast_substitute(eq::T, subs::Pair) where {T <: Eq} | ||
T(fast_substitute(eq.lhs, subs), fast_substitute(eq.rhs, subs)) | ||
end | ||
fast_substitute(eqs::AbstractArray{<:Eq}, subs) = fast_substitute.(eqs, (subs,)) | ||
fast_substitute(eqs::AbstractArray, subs) = fast_substitute.(eqs, (subs,)) | ||
fast_substitute(a, b) = substitute(a, b) | ||
function fast_substitute(expr, pair::Pair) | ||
a, b = pair | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.