Skip to content

changed: algebraic variable at left limit for predicted outputs in MPC and MHE - #466

Merged
franckgaga merged 14 commits into
mainfrom
leftendpoint_outputs
Oct 13, 2026
Merged

franckgaga merged 14 commits into
mainfrom
leftendpoint_outputs

Conversation

@franckgaga

@franckgaga franckgaga commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

This get VERY confusing with zero order hold inputs, it's better to be as precise as possible in the notation, and to stick to this convention everywhere in the codebase:

Caution

The predicted output $\mathbf{\hat{y}}$, both for MPC and MHE, are computed from the $\mathbf{\hat{a}_0}$ vectors and the h! function, ALWAYS corresponding to the left limit of the sampling instants (with one single exception, see below).

Some details about this convention:

  • This convention is intuitive since it's the holding of the inputs for $T_s$ seconds that changes the predicted outputs.
  • This is the simplest convention for MPC, since it leads to exactly $H_p$ data points in $\mathbf{\hat{A}_0}$. The right limit convention leads to $H_p + 1$ samples as it requires one additional algebraic vector just after $k + H_p$.
  • The variables in $\mathbf{\bar{A}}$ are strictly reserved for the dynamic function fq!.
  • It does not mean that $\mathbf{\hat{a}_0}$ vectors are never used in the fq! function. A notorious exception is the MHE with p=1 : the last $\mathbf{\hat{a}_0}$ vector is used in the last trapezoid, for example.
  • The algebraic variable at the right limit of the sampling instants are denoted with $\mathbf{a^+}$. They are required for the TrapezoidalCollocation transcription, bundled in the $\mathbf{\bar{A}}$ vector.
  • The algebraic variable at the left limit of the sampling instants are denoted with $\mathbf{\hat{a}_0}$ (instead of $\mathbf{a^-}$) so it matches perfectly the notation of the states in $\mathbf{\hat{X}_0}$, since both are used to compute the predicted outputs.
  • The notation and the convention is introduced in the extended help of TrapezoidalCollocation and OrthogonalCollocation docstrings.
  • Strictly speaking, we should store the manipulated inputs and the measured disturbances at the left limit of the arrival time step, to rigorously estimate the arrival algebraic estimate $\mathbf{\hat{a}_0}(k - N_k + p)$ in the MHE. But it would lead to data windows with $N_k + 1$ data points for them. It would significantly complexify the MHE codebase, with no real gain. So we make an exception instead for the arrival algebraic vector estimate: we use the values at the right limit. This exception as no impact mathematically since $\mathbf{\hat{a}_0}(k - N_k + p)$ is only used to compute the predicted output at the arrival when direct=false (useless if direct=true). Only strictly proper plant models are supported in this package, thus the predicted output at the left limit and at the right limit are equals.

This get VERY confusing with ZOH, it's better to be as precise as possible in the notation, and to stick to a convention:
- The predicted output, both in MPC and MHE, are computed from the `â0` vectors and `h!` function, ALWAYS corresponding to the left limit of the sampling instants. This convention is intuitive since it's the holding of the inputs for `Ts` seconds that change the predicted outputs.
- The variables in `Ā` are strictly reserved for the dynamic function `fq!`.
- It does not mean that `â0` vectors are never used in the `fq!`. A notorious exception is the MHE with `p=1` : the last `â0` vector is used in the last trapezoid, for example.
@franckgaga franckgaga changed the title changed: algebraic variable at left limit for predicted outputs in MovingHorizonEstimator changed: algebraic variable at left limit for predicted outputs in MPC and MHE Oct 13, 2026
@codecov-commenter

codecov-commenter commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.21%. Comparing base (9cc2550) to head (92c286f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #466      +/-   ##
==========================================
+ Coverage   97.19%   97.21%   +0.02%     
==========================================
  Files          28       28              
  Lines        6879     6865      -14     
==========================================
- Hits         6686     6674      -12     
+ Misses        193      191       -2     
Flag Coverage Δ
unittests 97.21% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@franckgaga
franckgaga merged commit 79cd652 into main Oct 13, 2026
36 of 49 checks passed
@franckgaga
franckgaga deleted the leftendpoint_outputs branch October 13, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants