ModelingToolkit and State Variables with Optimization

I see a similar issue here:

@lamorton did you find the solution?