NOTE!: this is a work in progress and the API is NOT stable
The purpose of PhySMC is to properly interface physics engines with probabilistic programming. Probabilistic programming, especially of the flavor found in Gen, composes stochastic computation with deterministic or pure functions (e.g., every time f is called with argument x you get the same result y). However, physics engines often rely on internal state (usually to cache computations), which can pose an issue for integrating them with Gen. For example, generating multiple traces using the same engine context (such as a particle filter) can lead to unintended side-effects when using Gen.update
.
PhySMC provides an interface where calls to physics engines and retrieval/manipulation of the state behave in a pure way.
The interface is defined in https://github.com/CNCLgithub/PhySMC/blob/master/src/PhySMC.jl
with the main function being step
"""
step(sim::PhySim, st::PhyState)::SimState
Performs a stateless evolution of the simulation state.
"""
function step(sim::PhySim, st::PhyState) end
where sim::PhySim is some simulation backend and st::PhyState is some state for that backend.
The default implementation of step
relies on two helper funtions that can be broadly useful in generative modeling:
sync!
forward_step
function step(sim::PhySim, st::PhyState)
sync!(sim, st)
new_st = forward_step(sim, st)
end
where these functions can be dispatched to particular simulator backends
"""
sync!(sim::PhySim, st::PhyState)::Nothing
Synchronizes the context within `sim` using `st`.
"""
function sync! end
"""
forward_step(sim::PhySim)::PhyState
Resolves physical interactions and obtains the next state representation.
"""
function forward_step end
- PhyBullet : Backend for the bullet physics engine (via pybullet)
- Taichi : Backend for taichi physics
Contributions are always welcome!
Documentation is a work in progress, please refer to docstrings in src/PhySMC.jl
in the meantime.