Fix #295: Add DirectedTwoCommodityIntegralFlow model#660
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #660 +/- ##
==========================================
+ Coverage 96.97% 97.00% +0.02%
==========================================
Files 277 279 +2
Lines 37161 37433 +272
==========================================
+ Hits 36038 36311 +273
+ Misses 1123 1122 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
There was a problem hiding this comment.
Pull request overview
Adds a new NP-complete graph satisfaction model, DirectedTwoCommodityIntegralFlow (G&J A2 ND38), and wires it into exports, CLI instance creation, examples, and documentation generation artifacts.
Changes:
- Introduces
DirectedTwoCommodityIntegralFlowmodel with feasibility evaluation, schema registration, variant declaration, and example-db fixture. - Adds unit tests covering creation, evaluation (yes/no), brute-force solving, and serialization.
- Integrates the model into the CLI (
pred create), library re-exports/prelude, and generated docs JSON / paper definition.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/models/graph/directed_two_commodity_integral_flow.rs | New model implementation, schema registration, variant declaration, and example-db spec |
| src/models/graph/mod.rs | Registers the new graph model module, re-export, and example spec wiring |
| src/models/mod.rs | Re-exports the new model from the top-level models module |
| src/lib.rs | Adds the model to the public prelude exports |
| src/unit_tests/models/graph/directed_two_commodity_integral_flow.rs | New model unit tests (feasibility, solver behavior, serde) |
| src/unit_tests/trait_consistency.rs | Adds trait consistency coverage for the new problem type |
| problemreductions-cli/src/cli.rs | Adds CLI flags documentation and new CreateArgs fields for the model |
| problemreductions-cli/src/commands/create.rs | Adds pred create DirectedTwoCommodityIntegralFlow construction + example string |
| src/example_db/fixtures/examples.json | Adds an example-db fixture instance and solutions for the model |
| docs/src/reductions/problem_schemas.json | Adds generated schema entry for the new model |
| docs/src/reductions/reduction_graph.json | Adds generated reduction graph node entry (and index shifts) |
| docs/paper/reductions.typ | Adds paper definition + illustrative figure for the new model |
| docs/paper/references.bib | Adds Even–Itai–Shamir (1976) reference |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| net_flow_in -= config[offset + a] as i64; | ||
| } | ||
| } | ||
| if (net_flow_in as u64) < req { |
| ProblemSchemaEntry { | ||
| name: "DirectedTwoCommodityIntegralFlow", | ||
| display_name: "Directed Two-Commodity Integral Flow", | ||
| aliases: &[], |
| for v in 0..n { | ||
| if terminals.contains(&v) { | ||
| continue; | ||
| } | ||
| let mut flow_in: i64 = 0; | ||
| let mut flow_out: i64 = 0; | ||
| for (a, &(u, w)) in arcs.iter().enumerate() { | ||
| if w == v { | ||
| flow_in += config[offset + a] as i64; | ||
| } | ||
| if u == v { | ||
| flow_out += config[offset + a] as i64; | ||
| } | ||
| } | ||
| if flow_in != flow_out { |
Review Pipeline Report
Remaining issues for final review
Generated by review-pipeline. |
Review Pipeline Report
Remaining issues for final review
Final follow-up fixes after the first pass:
Generated by review-pipeline. |
Merge main into branch, resolving conflicts to include both DirectedTwoCommodityIntegralFlow and main's new models (SteinerTree, SetBasis, LengthBoundedDisjointPaths, UndirectedTwoCommodityIntegralFlow). Regenerated JSON fixtures. Added test for wrong-length config to cover the early return in is_feasible(). Reverted README.md to main. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… requirements) Both DirectedTwoCommodityIntegralFlow and UndirectedTwoCommodityIntegralFlow share the same CLI fields. The merge with main created duplicates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Final Review — Approved
Fixes applied during final review:
|
zazabap
left a comment
There was a problem hiding this comment.
Final review passed — all CI green, quality 82%.
Summary
Add the Directed Two-Commodity Integral Flow problem model (Garey & Johnson A2 ND38) -- a satisfaction problem asking whether two integral flow functions can simultaneously satisfy joint arc capacity, flow conservation, and requirement constraints on a directed graph.
Fixes #295