Skip to content

fix: give the path and boundary duals by label; unknown with :exa - #680

Merged
ocots merged 4 commits into
mainfrom
feat/duals-by-label
Nov 13, 2026
Merged

ocots merged 4 commits into
mainfrom
feat/duals-by-label

Conversation

@ocots

@ocots ocots commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

First step of #672 (see the scope comment), plus the record of a change that #677 left out: the sign of the multipliers of a maximisation (below). #677 is merged, the base is main.

Conventions applied: ct-conventions v0.13.0, ct-agents v0.5.0.

Why

With CTModels 0.21.1 (#677), every solve printed the deprecation warning of path_constraints_dual / boundary_constraints_dual (49 times in the test suite): a user of OptimalControl saw it on every solve.

What

build_OCP_solution (src/DOCP_data.jl):

  • :adnlp: the path and boundary multipliers are given by label, duals=Dict(label => value), split with CTModels.Models.constraint_rows (path: the columns of the label, after the division by the time step as before; boundary: a number for one row, a vector otherwise). The values read with dual(sol, ocp, :label) are unchanged.
  • :exa: its getter does not return these multipliers yet (Keep the :exa constraint handles by label and return the path/boundary multipliers by label CTParser.jl#414). Instead of zeros, nothing is given: the labels are unknown and dual throws a PreconditionError, whose message is the note infos[:missing_duals] (CTParser#414, and the :adnlp modeler as workaround). User-visible: recorded as a bug fix and a near-breaking note in BREAKING.md.
  • Box duals unchanged.
  • Project.toml: CTModels = "0.21.1", the first version with duals=.

Plots of an :exa solution: the CTModels case layer reads the duals through has_dual only, so the path constraints are drawn without their duals (checked in the test with the backend-agnostic CTModels.PlotCase.build_figure).

Tests

test/ci/test_duals.jl, a problem with a path label of one row (active), one of two rows, two boundary labels and a control box:

  • :adnlp: @test_nowarn on the solve; dual for each label equals the rows of the stacked duals;
  • :exa: @test_nowarn; path and boundary labels unknown, PreconditionError carrying the note; the box dual still known; the figure is built.

Local results (with --depwarn=yes):

  • new file alone: 126/126 pass;
  • the same file against the code of chore: compat CTModels 0.21, CTSolvers 0.7, CTParser 0.9.6 #677: 11 failures (the warning with both modelers, and with :exa the duals present and no exception), so the tests do catch the change;
  • full suite: 661/661 pass, no deprecation warning left in the log (49 before).

The sign of a maximisation, left out of #677

#677 said "no breaking changes", which was wrong for one case. CTSolvers 0.7 returns the multipliers of the equivalent minimisation, and CTDirect passes them on. Measured on one problem, written as min ∫u² and max -∫u² (:adnlp, Ipopt), CTSolvers 0.5.8 against 0.7.0:

before after
costate, max against min opposite same
path and boundary duals, max against min opposite same
any of them, min unchanged unchanged

Recorded as near-breaking (maintainer's decision: the API is unchanged and CTSolvers documents the change): a note with a migration block in BREAKING.md, a line in the CHANGELOG.md dependencies, and the compatibility footer updated. Not measured: the box duals (the box was inactive in the problem), and whether the convention matches what CTModels expects for the costate of a max problem.

Out of scope

The :exa duals by label (step 2, CTParser#414); the box duals (#639); the docs (#660).

🤖 Generated with Claude Code

ocots and others added 3 commits November 13, 2026 16:39
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ocots ocots added run breakage Trigger the Breakage workflow on this PR run ci github-runner Trigger the CI workflow on GitHub-hosted runners run ci occidata-runner Trigger the CI workflow on the self-hosted occidata runner (GPU/CUDA) labels Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Breakage — packages

Tested commit: 68ed9e2a846066bcbb0e4b6ab35077feb86fa639. Each package is tested at its default branch (Latest) and its newest tag (Stable).

Package Check Latest Stable
OptimalControl test ❌ main, compat v1.1.8-beta ❌ v2.2.1-beta, compat v1.1.8-beta

Base automatically changed from chore/compat-ctx to main November 13, 2026 15:44
@ocots ocots added the ci on main: changes only Before merging: on main, rerun only the jobs the merged files can affect (never on a release PR) label Nov 13, 2026
…lvers 0.7

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ocots ocots added run ci kkt-runner Trigger the CI workflow on the self-hosted kkt runner and removed run ci occidata-runner Trigger the CI workflow on the self-hosted occidata runner (GPU/CUDA) labels Nov 13, 2026
@ocots
ocots marked this pull request as ready for review November 13, 2026 18:52
@ocots
ocots merged commit 0b308c6 into main Nov 13, 2026
48 of 50 checks passed
@ocots
ocots deleted the feat/duals-by-label branch November 13, 2026 18:53
@github-actions github-actions Bot mentioned this pull request Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci on main: changes only Before merging: on main, rerun only the jobs the merged files can affect (never on a release PR) run breakage Trigger the Breakage workflow on this PR run ci github-runner Trigger the CI workflow on GitHub-hosted runners run ci kkt-runner Trigger the CI workflow on the self-hosted kkt runner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants