adolgert / CompetingClocks.jl

Simplest simulation to use non-Exponential transitions
MIT License
5 stars 0 forks source link

composition of hierarchical samplers #26

Closed slwu89 closed 7 months ago

slwu89 commented 12 months ago

Based on the compositional-hierarchical samplers in the book https://link.springer.com/book/10.1007/978-3-319-63113-4 we should be able to use undirected wiring diagrams to compose (i.e. black box combine) samplers for semi-Markov processes.

For the first proof of concept cases, we should consider models where observables and physical state are the same, and that they alone are sufficient to compute the hazards. That is, Markov processes. It's possible semi-Markov processes complicate things a bit, and multiple types of junction and port would be needed, but we can kick that can down the road.

slwu89 commented 12 months ago

The key thing here is we don't really need to know how probability in semi-Markov processes works categorically in order to be able to compose simulators (samplers) categorically, via operad algebras. This is the pragmatic approach taken in AlgebraicDynamics.jl. Although we do know how to talk about classic dynamical systems categorically, from the perspective of composition, we use UWDs to set up a vectorfield, and then pass it off to numerical solvers for computing trajectories. The composition is what's helpful for scientists and engineers dealing with complex systems.

Unorganized thoughts:

adolgert commented 9 months ago

Hi Sean! The book you referenced is the most up-to-date account of what samplers are efficient. Excellent book.

Samplers are composable, as you suggest. The rough rule is that direct samplers can contain direct samplers and first-to-fire samplers can contain any samplers. I just implemented a "multiple-direct" sampler to show how that works for direct methods, and there is already a MultiSampler that can contain other samplers. The main challenge with all of these is how to match a given transition (clock) with a particular sampler in the hierarchy. That isn't often discussed, I think, because it's usually done with ad-hoc code.

I suspect your goal isn't to compose samplers but to compose models, where each model has state and a sampler. We should make an example. The challenge will be merging the identifiers for clocks. If the space of clock ids is separate, they could merge directly. If not, you would want to embed them in a larger space. It's very much a math problem, and the code would follow.

slwu89 commented 9 months ago

Right, "sampler" is really language for "model" here. Basically I have been wanting to generalize the sort of compositional modeling via operad algebras as demonstrated in AlgebraicDynamics.jl to stochastic systems. It would basically follow the same undirected wiring diagram schema as in that package, but potentially we need to additionally allow for "read only" wires for non mass action terms.

Came down with a slight cold, once I recover, need to devote more brain clock cycles to this.