SciML / SymbolicIndexingInterface.jl

A general interface for symbolic indexing of SciML objects used in conjunction with Domain-Specific Languages
https://docs.sciml.ai/SymbolicIndexingInterface/stable/
MIT License
15 stars 8 forks source link

Make `indp` available for collecting `ArraySymbolic` #80

Closed hexaeder closed 5 months ago

hexaeder commented 5 months ago

Is your feature request related to a problem? Please describe.

I'd like to create vector indexes which are not fully determined on their own, more specifically I'd like MySymbolicIndex(:) to access all variables of a certain component. I register this as an ArraySymbolic which I cannot collect into a vector of ScalarSymbolic without knowledge from the index provider.

Describe the solution you’d like

Create a new abstraction to collect the array symbolic which defaults to simple collect but can be specified if necessary.

SII.collect_array_symbolic(indp, array_symbolic) = collect(array_symbolic)

So I could define

SII.collect_array_symbolic(indp::MyIndexProvider, as::MySymbolicIndex{Colon}) = ...

to expand in a more complex manner.

If you're open to the suggestion I could also prepare a PR.

AayushSabharwal commented 5 months ago

SII was refactored relatively recently to avoid having to collect array symbolics (since MTK doesn't want to do that either). If you implement variable_index(indp::MyIndexProvider, as::MyArraySymbolic) (and parameter_index, is_* etc..) it should just work.

hexaeder commented 5 months ago

Hm thats what I am doing right now. But I thought collecting at a higher level is nicer, because otherwise I need to collect both at is_variable and variable_index calls (or implement some lazy iterator thing). Also I need to recreate some of the dispatch machinery depending on whether I get scalars, arrays, tuples and so on which "just works" if I only need to implement the scalar version. But I'll do it on the package level then!