Skip to content

feat: EmptyDualModel sentinel and has_duals predicate#368

Merged
ocots merged 1 commit into
mainfrom
feat/empty-dual-model
Jul 9, 2026
Merged

feat: EmptyDualModel sentinel and has_duals predicate#368
ocots merged 1 commit into
mainfrom
feat/empty-dual-model

Conversation

@ocots

@ocots ocots commented Jul 9, 2026

Copy link
Copy Markdown
Member

Summary

Introduces EmptyDualModel sentinel type and has_duals() predicate to distinguish solutions with dual variables from dual-free solutions (e.g., those built by flows).

  • Flow-built solutions (via build_solution without dual kwargs) now carry EmptyDualModel instead of all-nothing DualModel
  • New has_duals(sol) predicate returns true only for non-empty dual models
  • No breaking changes; existing code continues to work unchanged
  • Dual blocks in show and plotting are gated by has_duals checks

Design reference

See .reports/constraints-and-duals-design.md section A4 (CTModels phase).

Test plan

  • ✅ Full CTModels test suite: 4004/4004 passing
  • ✅ New test_empty_dual_model.jl: 20 tests covering sentinel, trait, accessors, dual() guard, show
  • ✅ Regression test in test_plot.jl for dual-free solutions with path constraints
  • ✅ Plotting (Plots.plot) with EmptyDualModel: :dual panel correctly omitted

Version bumped to 0.14.2-beta.

🤖 Generated with Claude Code

…olutions

- Add EmptyDualModel singleton type to represent solutions without dual variables
- Implement has_duals(sol) and has_duals(dual_model) predicates
- Refactor DualModel construction in build_solution to use EmptyDualModel when
  all dual arguments are nothing (flow-built solutions)
- Add Solution-level has_duals accessor delegating to dual_model
- Add dual() precondition guard throwing PreconditionError on dual-free solutions
- Implement 8 EmptyDualModel accessor methods returning nothing (compatibility)
- Guard show.jl dual blocks with has_duals checks
- Add test_empty_dual_model.jl: sentinel, trait, accessors, guard, show
- Add regression test in test_plot.jl for dual-free plotting with path constraints
- Update CHANGELOG for 0.14.2-beta

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ocots
ocots merged commit e37cf6d into main Jul 9, 2026
6 checks passed
@ocots
ocots deleted the feat/empty-dual-model branch July 9, 2026 19:54
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.

1 participant