SciML / SciMLBase.jl

The Base interface of the SciML ecosystem
https://docs.sciml.ai/SciMLBase/stable
MIT License
118 stars 91 forks source link

Hybrid systems behavior #722

Open YingboMa opened 1 week ago

YingboMa commented 1 week ago
YingboMa commented 1 week ago

To index a clock time exactly, one can use sol(Clock(t, dt)[10], idxs=[x]).

ChrisRackauckas commented 1 week ago

sol[Hold(x)] should then match sol.t times?

Plot recipes should plot discrete as scatters plus dashed lines

YingboMa commented 1 week ago

Yes

AayushSabharwal commented 1 week ago

How do we handle sol[x, y] where x is discrete and y is continuous

saveat isa Real in solve(...,; saveat) can only be set such that for all discrete clock time step dt, isinteger(saveat/dt) or isinteger(dt/saveat)

When saveat is an AbstractVector when do we save the clocks? Only at coinciding times?

To index a clock time exactly, one can use sol(Clock(t, dt)[10], idxs=[x]).

Why not just sol[x, 10]? This syntax is unnecessarily verbose, and doesn't allow leveraging getu. Implementing the above syntax would also require pulling Clock down into SII/SciMLBase which is unnecessary.

sol[Hold(x)] should then match sol.t times?

Is there any standardization whether x will be a parameter or Hold(x)? Because this gives different semantics to sol[Hold(x)] and sol[x]. From SII's perspective, Hold(x) and x are identical (they have the same index) but one is indexed at the continuous timeseries, and the other in the discrete timeseries.

Also, since MTK doesn't support hybrid systems, does MTKParameters need to have a complicated discrete partition? It's only ever going to store the callback parameters. For these callback parameters, should they have the same semantics as discrete variables, or should they have an implicit hold?

While all of the proposed changes are possible, they're technically breaking for SII. This wouldn't be a problem if RAT didn't also have a release with the current implementation of discrete save, since it means that part of the API can't change or else old RAT with new SII will error.

YingboMa commented 1 week ago

Why not just sol[x, 10]? This syntax is unnecessarily verbose, and doesn't allow leveraging getu. Implementing the above syntax would also require pulling Clock down into SII/SciMLBase which is unnecessary.

Because sol(Clock(t, dt)[10], idxs=z) still works if z is a continuous variable.