# ModelingToolkit and State Variables with Optimization

**URL:** <https://discourse.julialang.org/t/modelingtoolkit-and-state-variables-with-optimization/84430>\
**Category:** Modelling & Simulations\
**Tags:** optimization, modelingtoolkit\
**Created:** [July 18, 2022, 10:26pm UTC](https://discourse.julialang.org/t/modelingtoolkit-and-state-variables-with-optimization/84430 "2022-07-18T22:26:28Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![mzhenirovskyy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzhenirovskyy/32/7549_2.png) [@mzhenirovskyy](https://discourse.julialang.org/u/mzhenirovskyy)\
**Post date:** [July 19, 2022, 4:20pm UTC](https://discourse.julialang.org/t/modelingtoolkit-and-state-variables-with-optimization/84430/6 "2022-07-19T16:20:18Z")

</div>

I see a similar issue here:

> [@Loss function with symbolic selection of variable parameters](https://discourse.julialang.org/t/loss-function-with-symbolic-selection-of-variable-parameters/64289):
>
> I’m trying to create a loss function with a reduced set of adjustable parameters. I’m using LabelledArrays to keep track of the parameters using symbolic names. What I’d like is to be able to say “hold this set of parameters fixed at the initial-guess values while solving the problem.” Looks like Zygote is having trouble with my implementation. I feel like there’s got be a better way, but I’m not sure what it would be. Maybe just using the original loss function & passing some constraints to …

@lamorton did you find the solution?

---

_[View the full topic](https://discourse.julialang.org/t/modelingtoolkit-and-state-variables-with-optimization/84430)._
