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

Create a simple `SIIVector` structure #78

Open TorkelE opened 6 months ago

TorkelE commented 6 months ago

Would it be possible to have something like:

@parameters p1 p2 p3
ssi_vec = SSIVector([1.0, 2.0, 3.0], [p1, p2, p3])

and then have all of SII's functionality work on that?

There are a couple of cases where I have vectors and it would be nice to have a easy-to-use way of augmenting them with SII stuff without creating this thing myself for each case.

AayushSabharwal commented 6 months ago

Does ProblemState and SymbolCache combined solve your problem? I could make it so that ProblemCache can store an index provider, so you don't need to maintain both objects. Basically,

Current:

temp_sys = SymbolCache(nothing, [p1, p2, p3])
ssi_vec = ProblemCache(; p = [1.0, 2.0, 3.0])
getp(temp_sys, sym)(ssi_vec)

With the suggestion above:

ssi_vec = ProblemState(; p = [1.0, 2.0, 3.0], index_provider = SymbolCache(nothing, [p1, p2, p3]))
getp(ssi_vec, sym)(ssi_vec)

This will handle all SII functionality except observed (because SII only does that for Symbol/Expr, and doesn't have a hook for it)