# How to optimize multiple ODEs at once?

**URL:** <https://discourse.julialang.org/t/how-to-optimize-multiple-odes-at-once/98194>\
**Category:** Modelling & Simulations\
**Created:** [May 2, 2023, 12:59pm UTC](https://discourse.julialang.org/t/how-to-optimize-multiple-odes-at-once/98194 "2023-05-02T12:59:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [May 2, 2023, 12:59pm UTC](https://discourse.julialang.org/t/how-to-optimize-multiple-odes-at-once/98194/1 "2023-05-02T12:59:10Z")

</div>

Hello,  
I have a set of several ODEs to describe the interaction between six bacteria and six phages (one for bacterium). Collectively, I have 18 equations with 7 parameters.  
What is the approach to finding the values of the parameters that generate a “stable environment”? For instance, I can generate a stable environment with two bacteria and two phages, with cyclic but stable values:

 ![initialCondition](https://global.discourse-cdn.com/julialang/original/3X/1/4/1415d57f23d649e6f846ac17e102ad8871e11bf5.png)  
Finding the values that generate such a conditions for 18 ODEs is a bit cumbersome. Is there a procedure to follow? (I am a biologist, not a computer scientist or a mathematician…)  
Thank you.

---

<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, 3:43pm UTC](https://discourse.julialang.org/t/how-to-optimize-multiple-odes-at-once/98194/2 "2023-05-02T15:43:39Z")

</div>

Check out how to do parameter estimation for ordinary differential equations here:

[https://docs.sciml.ai/SciMLSensitivity/dev/tutorials/parameter\_estimation\_ode/](https://docs.sciml.ai/SciMLSensitivity/dev/tutorials/parameter_estimation_ode/)

What you need to do is then just change the loss function from a loss that calculates the cost of a data fit to a loss that measures how stable the solution is.

---

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [May 10, 2023, 8:39am UTC](https://discourse.julialang.org/t/how-to-optimize-multiple-odes-at-once/98194/3 "2023-05-10T08:39:05Z")

</div>

Thank you. I need to let this info sink…
