AlgebraicJulia / AlgebraicDynamics.jl

Building dynamical systems compositionally
https://algebraicjulia.github.io/AlgebraicDynamics.jl/
MIT License
65 stars 13 forks source link

Passing batch of initial states / batch of inputs. #88

Open rejuvyesh opened 2 years ago

rejuvyesh commented 2 years ago

The underlying OrdinaryDiffEq.jl package supports solving from a batch of initial conditions. It's very likely I am misunderstanding something but in principle it should be possible to support the same even here. Would love to know if there is a particular reason that the dynamics and readout functions have their type signatures restricted to AbstractVector.

slibkind commented 2 years ago

One of the reasons that dynamics and readout have their type signatures restricted is that in order to compute the composite dynamics (e.g. the dynamics of two machines wired together), we have to assume the form of the input. However, it seems possible to change the induced_dynamics and induced_readout methods to support other types of input. Do you have an example of the kind of thing you're interested in?

rejuvyesh commented 2 years ago

Simplest example would be modifying the Cyber-Physical example as: https://gist.github.com/rejuvyesh/537924449c334656ac367b0cdc02e660. Essentially I have tried modifying the functions L, C, D that correspond to their respective boxes to support a batch dimension.

slibkind commented 2 years ago

Neat! Thanks for sharing. PR #89 adds the functionality for evaluating the dynamics of a system with batch initial conditions and inputs, although so far only for systems composed using directed wiring diagrams (which is the case in the Cyber-Physical example). Here is an example in the test file.