# Dynamic optimization over a step function in MTK and InfiniteOpt

**URL:** <https://discourse.julialang.org/t/dynamic-optimization-over-a-step-function-in-mtk-and-infiniteopt/135496>\
**Category:** Optimization (Mathematical)\
**Created:** [February 6, 2026, 9:11am UTC](https://discourse.julialang.org/t/dynamic-optimization-over-a-step-function-in-mtk-and-infiniteopt/135496 "2026-02-06T09:11:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [February 6, 2026, 9:11am UTC](https://discourse.julialang.org/t/dynamic-optimization-over-a-step-function-in-mtk-and-infiniteopt/135496/1 "2026-02-06T09:11:35Z")

</div>

After watching the inspiring [Optimal Control in Julia: SciML’s newest tooling | Rackauckas | Paris 2025](https://www.youtube.com/watch?v=B9ymnQOQY3s), I’d like to use the [dynamic optimization interface](https://docs.sciml.ai/ModelingToolkit/stable/tutorials/dynamic_optimization/). While InfiniteOpt is made to work with “infinite parameters”, can it also optimize the coefficients of a piecewise constant (step) function? With, or without the MTK interface?

I’ve been using Optimization.jl’s ipopt to optimize over data interpolations inside of MTK’s callable parameters, but A) the error messages have been painful, B) I am duplicating the input interface and C) it is very slow (as a single shooting method), as predicted by @baggepinnen.

This is basically [the problem I had nearly two years ago](https://discourse.julialang.org/t/sciml-optimizing-a-control-signal/117504) 😔

---

<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:** [February 6, 2026, 3:07pm UTC](https://discourse.julialang.org/t/dynamic-optimization-over-a-step-function-in-mtk-and-infiniteopt/135496/2 "2026-02-06T15:07:00Z")

</div>

> [@cstjean](#):
>
> can it also optimize the coefficients of a piecewise constant (step) function? With, or without the MTK interface?

Yeah set `tune_parameters = true` and if that’s a tunable parameter it should optimize the tunables simultaniously to the solve
