Skip to content

Add new interface for symbolic indexing - #236

Merged
ChrisRackauckas merged 8 commits into
SciML:masterfrom
AayushSabharwal:symbolcache
Dec 12, 2022
Merged

ChrisRackauckas merged 8 commits into
SciML:masterfrom
AayushSabharwal:symbolcache

Conversation

@AayushSabharwal

@AayushSabharwal AayushSabharwal commented Dec 7, 2022 •

Copy link
Copy Markdown
Member
  • DiffEqArray now stores the new SymbolCache struct, which defines and implements its interface to query symbols
  • DiffEqArray supports symbolically indexing parameters, if provided

See SciML/ModelingToolkit.jl#1988

All tests pass as-is (except GPU, which I haven't been able to run locally), so this shouldn't be breaking. The constructors are modified to have the same interface but create the new structures

- DiffEqArray now stores the new `SymbolCache` struct, which defines and
  implements its interface to query symbols
- DiffEqArray supports symbolically indexing parameters, if provided
@AayushSabharwal

Copy link
Copy Markdown
Member Author

This gets a little annoying due to the compatibility with the old route:

DiffEqArray(u, t, sys, observed, p)

ends up constructing a SymbolCache(sys, observed, nothing) and puts p where observed should be.

- SymbolCache and interface functions added and exported
- `states`, `parameters` and `independent_variables` hoisted down from
  MTK
- DiffEqArray constructs SymbolCache taking into account if `indepsym` is
  `nothing`, a single symbol or an `AbstractArray` of symbols
- Test symbolic indexing functionality
- `symbolic_indexing_interface.jl` moved to its own package
- Update tests accordingly
@AayushSabharwal
AayushSabharwal marked this pull request as ready for review December 12, 2022 07:53
Comment thread test/symbolic_indexing_interface_test.jl
@AayushSabharwal

AayushSabharwal commented Dec 12, 2022 •

Copy link
Copy Markdown
Member Author

There is one major downside here: to avoid breaking changes, the constructors for DiffEqArray have been modified to work the same way they did before. However, this makes it so that trying to construct a DiffEqArray with a system requires specifying type parameters:

DiffEqArray(u, t, syms, indepsym, observed, p) # works as it did before
DiffEqArray(u, t, sys, observed, p) # interprets sys as syms, observed as indepsym and p and observed
DiffEqArray{..., typeof(sys), typeof(observed), typeof(p)}(u, t, sys, observed, p) # works

Also, to specify paramsyms (without a system)

sc = SymbolCache(syms, indepsym, paramsyms)
DiffEqArray{..., typeof(sc), typeof(observed), typeof(p)}(u, t, sc, observed, p)

@ChrisRackauckas

Copy link
Copy Markdown
Member

That's a fine wart for now. Open an issue to deprecate that in the next breaking update.

@ChrisRackauckas
ChrisRackauckas merged commit 7d5f1d5 into SciML:master Dec 12, 2022
@AayushSabharwal
AayushSabharwal deleted the symbolcache branch January 30, 2024 06:37
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.

2 participants