# Mixing set of continuous ODEs with probabilistic binary states

**URL:** <https://discourse.julialang.org/t/mixing-set-of-continuous-odes-with-probabilistic-binary-states/98209>\
**Category:** Modelling & Simulations\
**Tags:** question\
**Created:** [May 2, 2023, 4:04pm UTC](https://discourse.julialang.org/t/mixing-set-of-continuous-odes-with-probabilistic-binary-states/98209 "2023-05-02T16:04:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![p\_f](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@p\_f](https://discourse.julialang.org/u/p_f)\
**Post date:** [May 2, 2023, 4:04pm UTC](https://discourse.julialang.org/t/mixing-set-of-continuous-odes-with-probabilistic-binary-states/98209/1 "2023-05-02T16:04:34Z")

</div>

Say I have state vectors X1 and X2. X1 contains N1 continuous variables and X2 contains N2 binary (0 or 1) variables. X1 evolves in time according to function f1(X1,X2) and the binary variables in X2 have a probablity per unit time of switching states given by function f2(X1, X2, \dot{X1}).

I’m not sure what keywords I should be searching in the docs to work out if this is solvable using built-in DifferentialEquations.jl features? I’d like to take advantage of variable timestep stiff solvers given by DifferentialEquations.jl as the function f1 is quite costly, but I’m not sure if this setup is too non-trivial for the package, and I’ll just have to implement my own solver?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [May 2, 2023, 4:05pm UTC](https://discourse.julialang.org/t/mixing-set-of-continuous-odes-with-probabilistic-binary-states/98209/2 "2023-05-02T16:05:54Z")

</div>

The mixed jump process + ODE examples are demonstration of this kind of thing with Poisson jump processes instead of binary valued ones. See for example:

[https://docs.sciml.ai/JumpProcesses/stable/tutorials/discrete\_stochastic\_example/](https://docs.sciml.ai/JumpProcesses/stable/tutorials/discrete_stochastic_example/)

What you’d do is where your ODEs and then have callbacks (discrete or continuous) which define the jumping behavior on the discrete values. The growing cell example in the callback portion of the documentation might be helpful:

[https://docs.sciml.ai/DiffEqDocs/stable/features/callback\_functions/#Example-3:-Growing-Cell-Population](https://docs.sciml.ai/DiffEqDocs/stable/features/callback_functions/#Example-3:-Growing-Cell-Population)

---

<div class="post-metadata">

**Author:** ![p\_f](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@p\_f](https://discourse.julialang.org/u/p_f)\
**Post date:** [May 2, 2023, 4:12pm UTC](https://discourse.julialang.org/t/mixing-set-of-continuous-odes-with-probabilistic-binary-states/98209/3 "2023-05-02T16:12:31Z")

</div>

Many thanks! I’ll read through those pages and see how I get on, cheers!
