Skip to content

📐 added: OrthogonalCollocation with gaussradau and gausslegendre schemes#322

Open
franckgaga wants to merge 43 commits intomainfrom
orthogonal_colloc
Open

📐 added: OrthogonalCollocation with gaussradau and gausslegendre schemes#322
franckgaga wants to merge 43 commits intomainfrom
orthogonal_colloc

Conversation

@franckgaga
Copy link
Member

@franckgaga franckgaga commented Mar 2, 2026

The transcription method is efficient for highly stiff nonlinear systems. The default gaussradau quadrature is slightly less accurate than gausslegendre, but its an L-stable method, while the latter being A-stable.

Some comments:

  1. I default to 3 collocations points per time step/interval/finite element (for a total of 4 points, if we include the point at $\tau=0$) . I found that it's a more common default (e.g. CasADi, do-mpc, Pyomo, Gekko, etc.) than 5 points (the default of SimpleColloc.jl).
  2. I tried to write a concise documentation for details on the collocation and continuity constraints. The various references on this subject tend to be VERY verbose, but somehow succeed to skip important information like the differentiation matrix construction and how to use it. The preview of the documentation is available here : OrthogonalCollocation, the associated con_nonlinprogeq! method and init_orthocolloc.
  3. The paper "Nonlinear modeling, estimation and predictive control in APMonitor" of Hedengren et al. (2014) mention that we should factor out the final time $\tau_{n_o}$ from the differentiation matrix, to improve the numerical robustness, but no other justifications. I don't see why at all, since the condition number of the differentiation matrix is quite low (around 50 in my test case), and the matrix is already constructed on the normalized times $\tau \in [0, 1]$. I did not do this in my implementation (similarly to SimpleColloc.jl), since it's simpler and I'm not convince that it's necessary.
  4. I only support zero order hold on the manipulated inputs for now. I will add the support of first-order hold in a following release.

Closes #238

`nc` was the number of collocation points. I renamed it to `np` since there is confusion with `mpc.con.nc`, the number of custom inequality constraints
The subscript p is already used for `Hp` i.e. "prediction".
A dispatch was not necessary for this.
It's not necessary to differentiate with a `k` vector that would include the operating point (there is never operating point in this vector). And it now follows the nomenclature of `OrthogonalCollocation`
The mutated argument is used to store the result of `model.f!` function, thus it is a derivative of the state. The distinction is more important for code readability of `CollocationMethods`.
@franckgaga franckgaga marked this pull request as draft March 2, 2026 21:27
@franckgaga franckgaga marked this pull request as ready for review March 3, 2026 00:32
@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 60.14760% with 108 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.54%. Comparing base (4ab5d3b) to head (7537b91).

Files with missing lines Patch % Lines
src/controller/transcription.jl 33.33% 106 Missing ⚠️
src/estimator/internal_model.jl 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #322      +/-   ##
==========================================
- Coverage   98.42%   96.54%   -1.88%     
==========================================
  Files          29       29              
  Lines        5397     5501     +104     
==========================================
- Hits         5312     5311       -1     
- Misses         85      190     +105     

☔ View full report in Codecov by Sentry.
📢 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
Copy link
Member Author

franckgaga commented Mar 3, 2026

Hello @baggepinnen, I still need to implement the tests, but do you have any comments on my points above and the documentation of the new OrthogonalCollocation. The preview of the documentation is available here : OrthogonalCollocation, the associated con_nonlinprogeq! method, and init_orthocolloc.

Thanks for your time!

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.

New transcription method based on orthogonal collocation

2 participants