Skip to content

added: support box constraint in LinMPC and NonLinMPC#379

Open
franckgaga wants to merge 8 commits into
mainfrom
box_constraints
Open

added: support box constraint in LinMPC and NonLinMPC#379
franckgaga wants to merge 8 commits into
mainfrom
box_constraints

Conversation

@franckgaga

@franckgaga franckgaga commented Jun 18, 2026

Copy link
Copy Markdown
Member

Following discussion at #378, it is a good idea in terms of performances to treat constraints on the decision variable as box constraints, instead of linear inequality constraints, at least for NLP and interior point methods.

In this PR, these constraints:

  • limit on slack variable $\epsilon > 0$
  • limits on the input increments $\mathbf{\Delta u}$,
  • limits on the terminal state $\mathbf{\hat{x}}(k+H_p)$ for non-SingleShooting

are treated as box constraints. It applies to both LinMPC and NonLinMPC. Note that if there is a nonzero value in the associated softness parameters $\mathbf{c_{(\bullet)}}$ it is no longer a box constraint and the associated is treated as a linear inequality constraint, like before.

The default QP solver for LinMPC is OSQP.jl, and it does not support box constraint natively. It is still possible to define box constraints with the bridge mechanism of JuMP.jl. The new default optim argument for LinMPC is optim=JuMP.Model(OSQP.MathOptInterfaceOSQP.Optimizer, add_bridges=true). It should not affect the performances since JuMP will automatically convert them as linear equality constraints, as it was the case before this PR. It's possible that the performances with DAQP.jl will be improved however, since it supports box constraints natively.

Warning

Constructing LinMPC with optim=JuMP.Model(OSQP.MathOptInterfaceOSQP.Optimizer, add_bridges=false) will now throw an error. Please use add_bridges=true (it should not affect performances).

Let's see the benchmarks.

@codecov-commenter

codecov-commenter commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.60%. Comparing base (ed09542) to head (2f2cd11).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #379      +/-   ##
==========================================
+ Coverage   98.58%   98.60%   +0.01%     
==========================================
  Files          27       27              
  Lines        5512     5591      +79     
==========================================
+ Hits         5434     5513      +79     
  Misses         78       78              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants