# Tips on implementing a hybrid system

**URL:** <https://discourse.julialang.org/t/tips-on-implementing-a-hybrid-system/118649>\
**Category:** Modelling & Simulations\
**Created:** [August 26, 2024, 11:39pm UTC](https://discourse.julialang.org/t/tips-on-implementing-a-hybrid-system/118649 "2024-08-26T23:39:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdwfrost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdwfrost/32/2831_2.png) [@sdwfrost](https://discourse.julialang.org/u/sdwfrost)\
**Post date:** [August 26, 2024, 11:39pm UTC](https://discourse.julialang.org/t/tips-on-implementing-a-hybrid-system/118649/1 "2024-08-26T23:39:51Z")

</div>

I’d like to implement a hybrid model using the SciML ecosystem, that switches between a jump process (at ‘low’ population sizes) and an SDE. Individual examples of these models are [here](https://github.com/epirecipes/sir-julia/blob/master/markdown/sde_stochasticdiffeq/sde_stochasticdiffeq.md) and [here](https://github.com/epirecipes/sir-julia/blob/master/markdown/jump_process/jump_process.md). Any suggestions on best practices to switch between these two types of model as the integration progresses?

---

<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:** [August 27, 2024, 12:26am UTC](https://discourse.julialang.org/t/tips-on-implementing-a-hybrid-system/118649/2 "2024-08-27T00:26:45Z")

</div>

Not yet, but it is a big research project that @isaacsas and I are starting up so 🤷 I’m sure we’ll have more and better examples in the near future. My guess though is that the SDE likely isn’t a good idea and you might just want the ODE and the jump process since that would incorporate the noise when/where it matters, but that’s just a hunch. You can set it up with either.

---

<div class="post-metadata">

**Author:** ![sdwfrost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdwfrost/32/2831_2.png) [@sdwfrost](https://discourse.julialang.org/u/sdwfrost)\
**Post date:** [August 27, 2024, 2:10pm UTC](https://discourse.julialang.org/t/tips-on-implementing-a-hybrid-system/118649/3 "2024-08-27T14:10:42Z")

</div>

Thanks @ChrisRackauckas! Glad to hear you and @isaacsas are working on this. In the meantime, are there any existing examples to borrow from?

---

<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:** [August 27, 2024, 2:18pm UTC](https://discourse.julialang.org/t/tips-on-implementing-a-hybrid-system/118649/4 "2024-08-27T14:18:11Z")

</div>

Just the ones you linked.

---

<div class="post-metadata">

**Author:** ![isaacsas](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@isaacsas](https://discourse.julialang.org/u/isaacsas)\
**Post date:** [August 27, 2024, 2:26pm UTC](https://discourse.julialang.org/t/tips-on-implementing-a-hybrid-system/118649/5 "2024-08-27T14:26:01Z")

</div>

This is the one example someone put together using existing components:

> [@Improving the speed of large population simulations in DifferentialEquations.jl](https://discourse.julialang.org/t/improving-the-speed-of-large-population-simulations-in-differentialequations-jl/93109/9):
>
> Hi @ChrisRackauckas - thanks for your reply. I’m happy to explore this further, with the caveats that I haven’t had a chance to look through the paper in detail yet and lack formal mathematical training so this would probably require some patience on your part. Would you recommend setting up the game of life example as a toy model to get some intuition for how the approach works? Sorry can you just clarify what you mean by ‘… to specialize on’? Finally, here is an attempt i’ve made to swit…
