I have a general question about using ModelingToolkit when solving a
I noticed when building an
OptimizationSystem you can bound your variables. Modeling Optimization Problems · ModelingToolkit.jl
I was wondering if you could do the same when solving a
NonlinearSystem. Does anyone know? I tried replicating the syntax shown in the link above in my NL system but it did not appear to work.
My motivation stems from the thought that placing bounds may be useful because my model will fail if certain variables dip below known physical bounds (e.g. temperature cannot be less than zero).
I think this is possible, but not via the
bounds syntax. You can replace
x <= 0 with
max(x,0) ~ 0. However, this is now highly non-linear and difficult to solve. Can you not just use an
Sorry I missed that thread that was previously discussed.
max method doesn’t sound worthwhile as you pointed out. However, converting the system to an
OptimizationSystem sounds reasonable. I believe the equations
eqs in the
NonlinearSystem would simply become the constraints
cons in the optimization sys, and the objective function would be left blank, if possible, right? If not, how would you suggest writing the obj func in order to trick the solver to not try to minimize the obj func, and simply solve the system of equations at hand.