You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Give the path and boundary duals to build_solution by label (CTModels 0.21.1) #672
CTModels 0.21.1 is released (it contains control-toolbox/CTModels.jl#507, #509 and #510): set the compat lower bound CTModels = "0.21.1". The current call keeps working meanwhile (deprecated, with a warning).
Problem
build_solution receives the path and boundary duals by position (path_constraints_dual=, boundary_constraints_dual=, in src/DOCP_data.jl). CTModels 0.21.1 deprecates this input (Base.depwarn), to be removed at the next breaking release: the duals are given by label, build_solution(...; duals=Dict(label => value)), and CTModels places them (CTModels.Models.constraint_rows(model, label) gives the layout). A label that is not given is unknown: dual(sol, ocp, :label) throws a PreconditionError; it is never read as 0.
With :exa, CTDirect currently passes zeros for the path and boundary duals (# +++ not yet implemented for exa), so dual(sol, ocp, :c) silently returns 0.
What to do
ADNLP: the NLP rows follow the stacked layout of path_constraints_nl(ocp) / boundary_constraints_nl(ocp), so the multipliers are split by label with constraint_rows: Dict(label => mult[:, rows]) for each path label (after the division by the time step), Dict(label => mult[rows]) for each boundary label (a number for a one-row label).
changed the title [-]Give the path and boundary duals to build_solution by label (CTModels 0.22)[/-][+]Give the path and boundary duals to build_solution by label (CTModels 0.21.1)[/+]on Nov 3, 2026
Scope for the next release: a first step, without waiting for CTParser#414
With the compat bump of #677 (CTModels 0.21.1), every solve prints the deprecation warning of path_constraints_dual / boundary_constraints_dual (49 times in the test suite, once per solve). A user of OptimalControl sees it on every solve, for an internal call between two packages of the organization. So this issue is split in two:
Step 1, now (for a quick release):
ADNLP: the path and boundary multipliers are given by label, duals=Dict(label => value), split with CTModels.Models.constraint_rows(ocp, label) (after the division by the time step for the path rows; a number for a one-row boundary label). dual(sol, ocp, :label) must be unchanged.
Tests: no deprecation warning (ADNLP and :exa); dual unchanged with ADNLP for every path and boundary label; dual throws with :exa for a path and a boundary label, and its message carries the note.
In CTModels 0.21.1 the plots read the duals only through has_dual / dual, never as a 0:
src/PlotCase/rows.jl: a path constraint is always a row, with row.dual = has_dual(sol, model, label); a box is a row only when its dual is known; boundary and variable-box labels are not plotted.
src/PlotCase/build.jl: the dual samples are read only when a drawn path row has a known dual. A path row whose dual is unknown gets the constraint on the left, and on the right either nothing (no dual column at all when no row has a known dual) or an empty panel annotated dual not known (when another row, e.g. a box, has one).
This case is tested in CTModels (test/suite/plotting/test_plot_rows.jl, the dual not known annotation).
So an :exa solution plots its path constraints, without their duals, and the box duals as before. Worth adding to the tests of step 1: plotting an :exa solution with a path constraint and the :dual group does not throw.
Activity
[-]Give the path and boundary duals to build_solution by label (CTModels 0.22)[/-][+]Give the path and boundary duals to build_solution by label (CTModels 0.21.1)[/+]ocots commentedon Nov 13, 2026
Scope for the next release: a first step, without waiting for CTParser#414
With the compat bump of #677 (CTModels 0.21.1), every solve prints the deprecation warning of
path_constraints_dual/boundary_constraints_dual(49 times in the test suite, once per solve). A user of OptimalControl sees it on everysolve, for an internal call between two packages of the organization. So this issue is split in two:Step 1, now (for a quick release):
duals=Dict(label => value), split withCTModels.Models.constraint_rows(ocp, label)(after the division by the time step for the path rows; a number for a one-row boundary label).dual(sol, ocp, :label)must be unchanged.:exa: option (b) of the description: nothing is passed for the path and boundary labels (unknown:dualthrows aPreconditionError, instead of the silent0of today), andinfos[:missing_duals]says why (not yet returned by the:exagetter, see Keep the :exa constraint handles by label and return the path/boundary multipliers by label CTParser.jl#414). This is a user-visible change, to record inCHANGELOG.md.:exa);dualunchanged with ADNLP for every path and boundary label;dualthrows with:exafor a path and a boundary label, and its message carries the note.Step 2, later: the
:exaduals by label, once control-toolbox/CTParser.jl#414 is in.Plots of an
:exasolution: checked, no problemIn CTModels 0.21.1 the plots read the duals only through
has_dual/dual, never as a0:src/PlotCase/rows.jl: a path constraint is always a row, withrow.dual = has_dual(sol, model, label); a box is a row only when its dual is known; boundary and variable-box labels are not plotted.src/PlotCase/build.jl: the dual samples are read only when a drawn path row has a known dual. A path row whose dual is unknown gets the constraint on the left, and on the right either nothing (no dual column at all when no row has a known dual) or an empty panel annotateddual not known(when another row, e.g. a box, has one).test/suite/plotting/test_plot_rows.jl, thedual not knownannotation).So an
:exasolution plots its path constraints, without their duals, and the box duals as before. Worth adding to the tests of step 1: plotting an:exasolution with a path constraint and the:dualgroup does not throw.