feat: EmptyDualModel sentinel and has_duals predicate#368
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces
EmptyDualModelsentinel type andhas_duals()predicate to distinguish solutions with dual variables from dual-free solutions (e.g., those built by flows).build_solutionwithout dual kwargs) now carryEmptyDualModelinstead of all-nothingDualModelhas_duals(sol)predicate returnstrueonly for non-empty dual modelsshowand plotting are gated byhas_dualschecksDesign reference
See .reports/constraints-and-duals-design.md section A4 (CTModels phase).
Test plan
test_empty_dual_model.jl: 20 tests covering sentinel, trait, accessors, dual() guard, showtest_plot.jlfor dual-free solutions with path constraints:dualpanel correctly omittedVersion bumped to 0.14.2-beta.
🤖 Generated with Claude Code