Juliacon 2024

SymbolicIndexingInterface.jl: Symbolic Indexing for Everyone
07-10, 11:00–11:30 (Europe/Amsterdam), Else (1.3)

What's the point of a DSL for modeling if the solution can't be accessed using the model's variables? No one remembers what sol[1] is.
SymbolicIndexingInterface.jl is a new package in the SciML ecosystem. It defines an interface to allow symbolically defined systems and their solutions to be efficiently indexed using symbolic variables. Any DSL implementing the common interface will automatically support symbolically indexing the relevant data structures.


DSLs such as ModelingToolkit allow creating models using symbolic variables and writing the relevant equations similar to how they're written mathematically. SymbolicIndexingInterface was created to allow accessing the values of these symbolic variables without having to dig through internals of the relevant libraries. The intent of sol[x] is much more obvious than sol[1]. Not to mention, the order of variables is not guaranteed and may be changed by the modeling library.

Most notably, SymbolicIndexingInterface is designed to be independent of the modeling DSL and symbolic framework, providing access to powerful indexing capabilities if a data structure implements its interface. Any type implementing the interface can be queried for the values of it's symbolic variables. Multiple variables can be queried at once using (arbitrarily nested) tuples and arrays, and the result is type-inferred if the queried collection of variables is completely concretely typed. SymbolicIndexingInterface can create functions that cache the metadata needed to access a particular symbolic quantity, allowing for efficient queries/updates to the same quantity repeatedly.