# ModelingToolkit parameter estimation tutorials, and some confusion

**URL:** <https://discourse.julialang.org/t/modelingtoolkit-parameter-estimation-tutorials-and-some-confusion/139765>\
**Category:** Modelling & Simulations\
**Tags:** optimization\
**Created:** [September 30, 2026, 8:33pm UTC](https://discourse.julialang.org/t/modelingtoolkit-parameter-estimation-tutorials-and-some-confusion/139765 "2026-09-30T20:33:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark.garnett](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mark.garnett](https://discourse.julialang.org/u/mark.garnett)\
**Post date:** [September 30, 2026, 8:33pm UTC](https://discourse.julialang.org/t/modelingtoolkit-parameter-estimation-tutorials-and-some-confusion/139765/1 "2026-09-30T20:33:01Z")

</div>

Hi all,

I am working to figure out how to do parameter fitting on a ModelingToolkit model, which yields an ODEProblem. I am not bringing neural nets or anything.

I am trying to figure which way to do it either following:

> **[Optimizing through an ODE solve and re-creating MTK Problems ·...](https://docs.sciml.ai/ModelingToolkit/stable/examples/remake/)**
>
> Documentation for ModelingToolkit.jl.

or [Parameter Estimation of Ordinary Differential Equations · SciMLSensitivity.jl](https://docs.sciml.ai/SciMLSensitivity/stable/tutorials/parameter_estimation_ode/)

The latter method seems nicer— but not sure if it is completely compatible with MTK.

On the examples themselves, I think something is not working right.

I notice that choosing a random guess for the initial value of the parameters for the optimizer, like in the ModelingToolkit example, doesn’t result in bringing the loss to 0, you have to make the guess closer.

In the SciMLSensitivity example, the fitted parameters just yield more or less constant solution to ODE, not matching the original parameters at all. This can be seen in the final plot itself in the example. Running it myself yields the same result. The crazy thing is that the initial guess u0 for optprob are exactly the parameters used to generate the data we are trying to fit!

```julia-auto
julia> optprob.u0
4-element Vector{Float64}:
 1.5
 1.0
 3.0
 1.0

```

So perhaps something broke along the way?

---

<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:** [October 2, 2026, 2:20am UTC](https://discourse.julialang.org/t/modelingtoolkit-parameter-estimation-tutorials-and-some-confusion/139765/2 "2026-10-02T02:20:24Z")

</div>

> [@mark.garnett](#):
>
> The latter method seems nicer— but not sure if it is completely compatible with MTK.

The latter is exactly the same? The MTK example just shows how to effectively use the parameters of an MTK model.

> [@mark.garnett](#):
>
> The crazy thing is that the initial guess u0 for optprob are exactly the parameters used to generate the data we are trying to fit!

The initial condition in the example is `rand(4)` ?

---

<div class="post-metadata">

**Author:** ![mark.garnett](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mark.garnett](https://discourse.julialang.org/u/mark.garnett)\
**Post date:** [October 2, 2026, 4:41am UTC](https://discourse.julialang.org/t/modelingtoolkit-parameter-estimation-tutorials-and-some-confusion/139765/3 "2026-10-02T04:41:39Z")

</div>

Thank you, I missed that the SciMLSensitivity example is optimizing the parameters to MAKE the ODE solution 1 for all variables, rather than fitting parameters to data. Derp.

The MTK example makes more sense after reading the FAQ sections on tunable parameters and using MTK with optimization
