Skip to content

Documentation: sign conventions (min/max, p⁰, constraints, duals) and how they appear in a solution #1015

Open

Description

@ocots

Summary

Add a page to the documentation that explains the sign conventions of the ecosystem and how they show up in a solution, once they are settled in the discussion #1014. This issue is the place for that page; it should not be written before the choices are made.

Related: #968 (documentation items waiting on other packages), control-toolbox/CTDirect.jl#639, control-toolbox/CTFlows.jl#472.

What the page should explain

  • min vs max: the value of p⁰, the Hamiltonian (with and without constraints), and whether p and the duals change sign when min J becomes max −J.
  • Inequality constraints: g ≥ 0 or c ≤ 0, the sign of the multiplier on each side, two-sided constraints, equalities.
  • What dual(sol, ocp, :label) returns for each kind of constraint (path, box, boundary, variable box): sign, scaling (continuous-time density or raw NLP value), and its meaning at the first and last nodes.
  • The same constraint solved directly (solve) and by an indirect method (Flow(ocp, law; constraint=:label, multiplier=μ)): how to read the duals on both sides, and the dictionary between μ and dual.
  • Transversality and boundary constraints: the sign of β and of the dual of a boundary constraint.
  • Which of these do not depend on the NLP solver (Ipopt, MadNLP).

Elements already available

Depends on

Activity

  1. ocots commented on Oct 23, 2026

    @ocots
    MemberAuthor

    Update (2026-10-23): the convention is proposed, and what this page should say

    The convention proposed in #1014 and control-toolbox/CTSolvers.jl#288 gives this page its content, once it is chosen. The page is written for the user of OptimalControl, with no mention of the solvers (the solver side is documented in CTSolvers, the pseudo-Hamiltonian side in CTFlows).

    It should state that:

    • the duals of the inequality constraints are positive, whatever the constraint and the sense of the criterion; each active side has its own nonnegative multiplier (μ ≥ 0 for c ≥ l, for c ≤ u, and for the bounds of the variables), and g ≥ 0 and -g ≤ 0, being the same constraint, have the same dual;
    • an equality constraint keeps its sign: no positivity condition, and c = 0 and -c = 0 differ by a sign, since an equality has no preferred side;
    • min f and max -f are the same problem and have the same duals and the same adjoint p: the adjoint does not change sign when min f is written max -f;
    • how to read dual(sol, ocp, :label) for a constraint, a box, a boundary condition, and for the solution of a direct solve and of an indirect one (Flow(ocp, law; constraint=:label, multiplier=μ)), where the dual is the μ given to the flow and is 0 off the boundary arc.

    The pieces already available are listed above (probes of 2026-10-21 and 2026-10-23, the derivation in control-toolbox/CTDirect.jl#639). The page depends on the decision in #1014 and on the implementation in control-toolbox/CTSolvers.jl#288, and on the alignment of CTDirect for a maximisation (its duals and costate currently flip with the sense).

  2. ocots commented on Oct 23, 2026

    @ocots
    MemberAuthor

    The examples for this page, and the tests that should come with them, are listed in #1016. Implementation: control-toolbox/CTSolvers.jl#289 (direct solvers), control-toolbox/CTFlows.jl#494 (flows), control-toolbox/CTModels.jl#483.

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

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions