Tests of the duals: every kind of constraint, direct vs indirect, pinned algorithms

Abierto
#1,034 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@ocots ya está trabajando en esto.

Desde el 31/10/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

Follow-up of control-toolbox/CTFlows.jl#495 (the duals a flow can give) and companion of #1016 (doc examples of the sign convention).

Why

The ecosystem has one convention for the multipliers: ct-conventions SGN1–SGN6 (control-toolbox/ct-conventions#49). SGN6 is tested at the NLP level, in CTSolvers. Nothing yet checks it at the level of an optimal control solution, for every kind of constraint, and between the direct and the indirect method (SGN5). Only OptimalControl loads CTDirect and CTFlows together, so this test can only live here.

The idea is to pin the algorithms (solver, modeler, scheme, grid, options). With them pinned, we know what dual(sol, ocp, :label) should return. The tests then check that the duals are consistent across solvers, senses, ways of writing a constraint, and methods. A known gap is written as a @test_broken, so it stays visible and the test turns green when it is fixed.

What to test

For each kind of constraint, on a problem with a closed form:

Kind Example Notes
path, mixed x(t) + u(t) ≤ 0 (example 1 of #1016: dual = e^{t−1}) already sketched in #1016
state constraint of order 1, as a path constraint and as a state box x(t) ≥ 0.1, three arcs (control-toolbox/CTFlows.jl#440) same dual both ways (SGN5)
control box e.g. ẋ = u, −1 ≤ u ≤ 1, x(0) = 0, −x(1) → min: u = 1, p = 1, upper dual = 1 scale of the box duals: CTDirect#639
boundary, equality and inequality an active and an inactive inequality row sign of a one-sided row (SGN2)
variable box a free variable that hits a bound

Run every case along these axes:

  • sense: min J and max −J, which must give the same duals and costate (SGN1, SGN4);
  • writing: g ≤ 0 and −g ≥ 0 (SGN2), and path vs box for the same constraint (SGN5);
  • solver: Ipopt and MadNLP (and others when available), with the solver and its version in the name of the test, as SGN6 asks;
  • modeler: :adnlp and :exa (:exa gives no path or boundary dual yet);
  • method: a direct solve and the solution of Flow(ocp, law; constraint=:label, multiplier=μ), as far as CTFlows gives each kind (control-toolbox/CTFlows.jl#495).

Compare the sign exactly and the value up to the discretisation error, on pinned grids.

Known gaps, to be written as @test_broken

  • Box duals are not divided by the time step, and their sign is opposite to that of the path duals: control-toolbox/CTDirect.jl#639.
  • Path and boundary duals are missing with :exa.
  • A flow does not yet give boundary, box, or variable duals (control-toolbox/CTFlows.jl#495).

Open questions

  1. Where: the test suite of OptimalControl, the docs (#1016: each example is also a test), or both, with the docs kept to the readable cases?
  2. CI cost: MadNLP and :exa add time. Should the full matrix run behind a label?
  3. Tolerances: a fixed tolerance per pinned grid, or a check of the convergence order when the grid is refined?

Related: #1014 (the convention), #1015 (the page), #1016 (doc examples), control-toolbox/CTSolvers.jl#288, control-toolbox/CTDirect.jl#639, control-toolbox/CTFlows.jl#495.

🤖 Generated with Claude Code

Lenguaje dominante
Julia
Estrellas
135
Forks
11
Merge medio
7 h 51 min
PR fusionados (30 d)
22

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de control-toolbox/OptimalControl.jl

Todos los issues de control-toolbox/OptimalControl.jl

Issues similares

Más issues de Julia

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.