Fix #253: [Model] MultipleChoiceBranching#656
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #656 +/- ##
==========================================
+ Coverage 96.97% 97.02% +0.05%
==========================================
Files 277 281 +4
Lines 37161 37804 +643
==========================================
+ Hits 36038 36681 +643
Misses 1123 1123 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
There was a problem hiding this comment.
Pull request overview
Adds the new MultipleChoiceBranching graph model (Garey & Johnson ND11) to the core library and wires it through the example DB, docs, and CLI so it can be created/serialized/solved with existing tooling.
Changes:
- Introduces
MultipleChoiceBranchingmodel implementation + variant/schema registration and example-db spec. - Adds unit tests (model correctness + trait consistency), example fixtures, and CLI create/solve round-trip tests.
- Regenerates/updates docs artifacts (schemas + reduction graph) and paper content to include the new model.
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/multiple_choice_branching.rs | New model implementation, schema entry, variants, and example-db spec hook |
| src/models/graph/mod.rs | Registers module, re-exports type, and includes canonical example specs |
| src/models/mod.rs | Re-exports MultipleChoiceBranching from graph models |
| src/lib.rs | Adds MultipleChoiceBranching to the public prelude |
| src/unit_tests/models/graph/multiple_choice_branching.rs | New unit tests covering construction, validation, evaluate(), brute-force, and serde round-trip |
| src/unit_tests/trait_consistency.rs | Adds trait-consistency smoke test instantiation for the new model |
| src/example_db/fixtures/examples.json | Adds canonical example instance + satisfying/optimal configs for the model |
| problemreductions-cli/src/cli.rs | Adds --partition flag and documents MCB flags/examples in help text |
| problemreductions-cli/src/commands/create.rs | Implements pred create MultipleChoiceBranching/... parsing, including --partition parsing helper |
| problemreductions-cli/tests/cli_tests.rs | Adds CLI tests for create, example create, and create→solve piping |
| docs/src/reductions/problem_schemas.json | Adds generated schema entry for MultipleChoiceBranching |
| docs/src/reductions/reduction_graph.json | Adds node entry for MultipleChoiceBranching and regenerates graph indices |
| docs/paper/reductions.typ | Adds paper section + figure for MultipleChoiceBranching based on the canonical fixture |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let threshold = args.bound.ok_or_else(|| { | ||
| anyhow::anyhow!( | ||
| "MultipleChoiceBranching requires --bound\n\n\ | ||
| Usage: pred create MultipleChoiceBranching/i32 --arcs \"0>1,0>2,1>3,2>3,1>4,3>5,4>5,2>4\" --weights 3,2,4,1,2,3,1,3 --partition \"0,1;2,3;4,7;5,6\" --bound 10" | ||
| ) | ||
| })? as i32; | ||
| ( | ||
| ser(MultipleChoiceBranching::new( | ||
| graph, | ||
| weights, | ||
| partition, | ||
| threshold, | ||
| ))?, |
| let arcs = graph.arcs(); | ||
| let mut in_degree = vec![0usize; graph.num_vertices()]; | ||
| for (index, &selected) in config.iter().enumerate() { | ||
| if selected == 1 { | ||
| let (_, target) = arcs[index]; | ||
| in_degree[target] += 1; | ||
| if in_degree[target] > 1 { | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| let selected_arcs: Vec<bool> = config.iter().map(|&selected| selected == 1).collect(); | ||
| if !graph.is_acyclic_subgraph(&selected_arcs) { | ||
| return false; |
| /// Parse `--partition` as semicolon-separated groups of comma-separated arc indices. | ||
| /// E.g., "0,1;2,3;4,7;5,6" | ||
| fn parse_partition_groups(args: &CreateArgs) -> Result<Vec<Vec<usize>>> { | ||
| let partition_str = args.partition.as_deref().ok_or_else(|| { | ||
| anyhow::anyhow!( | ||
| "MultipleChoiceBranching requires --partition (e.g., \"0,1;2,3;4,7;5,6\")" | ||
| ) | ||
| })?; | ||
|
|
||
| partition_str | ||
| .split(';') | ||
| .map(|group| { | ||
| group.trim() | ||
| .split(',') | ||
| .map(|s| { | ||
| s.trim() | ||
| .parse::<usize>() | ||
| .map_err(|e| anyhow::anyhow!("Invalid partition index: {}", e)) | ||
| }) | ||
| .collect() | ||
| }) | ||
| .collect() | ||
| } |
Review Pipeline Report
Remaining issues for final review
Generated by review-pipeline |
Resolve merge conflicts with main (SteinerTree, SetBasis, LengthBoundedDisjointPaths, UndirectedTwoCommodityIntegralFlow, DirectedTwoCommodityIntegralFlow). Regenerate JSON fixtures. Add unit tests for deserialization error paths and set_weights validation to cover previously untested lines. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Final Review — Approved
Fixes applied during final review:
|
Summary
MultipleChoiceBranchingFixes #253