added: pretty-print optimization problem dimensions for MPC and MHE#378
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #378 +/- ##
=======================================
Coverage 98.57% 98.58%
=======================================
Files 27 27
Lines 5479 5512 +33
=======================================
+ Hits 5401 5434 +33
Misses 78 78 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Out of curiosity, do you have any comments on these choices currently in the package :
I have a hunch that treating the box constraints (lower and upper limits on a decision variable) as box constraint instead of linear equality constraints (e.g. the slack variable |
|
It's @cvanaret presentation at JuMP-dev 2026 that made me think about this. What's your take on this @cvanaret ? Right now I do not use any box constraints to define my NLP. They are all defined as linear inequality constraints (with identity A matrix, if it's really a box constraint) since it was easier for me. Knowing that cvanaret/Uno#474 allows efficient |
|
Absolutely. Since the immense majority of solvers handle bound constraints separately, you should define your model accordingly. For some methods (like active-set/SQP methods), I don't think this will make a big difference because they handle linear constraints and bound constraints pretty much the same way. In interior-point methods though, bound constraints are handled directly while general inequality constraints get attached slack variables => the problem becomes larger (still sparse, but pointlessly larger). Should your problem be fully bound constrained (no general constraints), it can be solved with very efficient (projection) methods. You might not want to unleash the more complex (and probably slower) active-set or interior-point methods there. Under the solver's hood, the bound constraints most likely do not appear in the computation of constraint violation or in the merit function, aren't relaxed, etc. Uno in particular doesn't have (yet) a special treatment for linear constraints and has no presolver, so you should declare the bound constraints as such.
The update of the model is efficient, but Uno doesn't allow proper reoptimization yet 😅 Note that it also allows an efficient update of the bound constraints without model recreation. |
|
Alright, many thanks for the detailed answer. I will open a PR that treats box constraints as box constraints and see if it make a difference! |
|
Cool, I look forward to seeing the results. Ultimately they will be the decider. |
Print optimization problem dimensions
Printing a
LinMPC,NonLinMPCorMovingHorizonEstimatorobject will now shows the dimensions of the optimization problem that is, the number of decision variables and constraints. Below is a preview of what is printed for the 3 types. The new information is in theoptimizationsection at the end. I also moved the slack variable dimension in this section.LinMPCobjectNonLinMPCobjectMovingHorizonEstimatorobject:Why?
It is more explicit and transparent for the user like this. Especially knowing that the classification can look surprising at first. For example :
NonLinModel(because the stochastic model of the unmeasured disturbances is linear)MovingHorzionEstimatorwill always create linear inequality constraints even if the plant model is aNonLinModel(because the arrival state estimate is always a decision variable)Some of these choices may change in the future. For example, I have a feeling that treating the slack variable$\varepsilon$ as a box constraint would help the MHE for the NLP case (this case is finicky right now).