Fix #420: Add ConsecutiveBlockMinimization model#668
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #668 +/- ##
========================================
Coverage 97.50% 97.50%
========================================
Files 361 363 +2
Lines 45780 45954 +174
========================================
+ Hits 44636 44806 +170
- Misses 1144 1148 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add the Consecutive Block Minimization satisfaction problem (Garey & Johnson SR17) to the algebraic/ category. Given an m×n binary matrix and bound K, decide whether a column permutation exists yielding at most K maximal blocks of consecutive 1's across all rows. - Model with SatisfactionProblem trait, dims=[n;n] permutation space - CLI create with --matrix (JSON) and --bound-k flags - Unit tests: creation, evaluation, count_blocks, brute_force, serialization, invalid permutation, empty matrix - Paper entry with citations (Kou 1977, Booth 1975, Haddadi 2008) - Example DB fixture with 2×3 matrix instance Co-Authored-By: Claude Opus 4.6 <[email protected]>
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
There was a problem hiding this comment.
Pull request overview
Adds the ConsecutiveBlockMinimization (CBM) satisfaction problem (G&J SR17) to the models::algebraic category, wiring it into the library surface area, CLI instance creation, example DB fixtures, and docs/paper references.
Changes:
- Introduces
ConsecutiveBlockMinimizationmodel implementation + unit tests, and registers it in the algebraic module exports. - Adds CLI support for
pred create ConsecutiveBlockMinimizationvia--matrix(JSON 2D bool) and--bound-k. - Updates example fixtures and generated docs/paper artifacts to include CBM.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/unit_tests/trait_consistency.rs | Adds CBM to the trait/dims consistency sweep. |
| src/unit_tests/models/algebraic/consecutive_block_minimization.rs | New unit tests covering basic properties, evaluation, and brute force behavior. |
| src/models/mod.rs | Re-exports CBM from models. |
| src/models/algebraic/mod.rs | Registers CBM module + exports + example-db specs hook. |
| src/models/algebraic/consecutive_block_minimization.rs | New CBM model, schema registration, Problem/SatisfactionProblem impl, and variant declaration. |
| src/example_db/fixtures/examples.json | Adds a canonical model example fixture for CBM. |
| problemreductions-cli/src/commands/create.rs | Adds CBM to pred create dispatch + example string + --bound-k plumbing. |
| problemreductions-cli/src/cli.rs | Documents CBM flags and adds bound_k arg. |
| docs/src/reductions/reduction_graph.json | Updates reduction graph to include CBM node (but currently corrupted/invalid JSON). |
| docs/src/reductions/problem_schemas.json | Adds CBM schema entry. |
| docs/paper/references.bib | Adds CBM-related bibliography entries. |
| docs/paper/reductions.typ | Adds CBM definition block and example narrative for the paper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Empty matrix: zero blocks, always satisfies any bound. | ||
| return true; |
| { | ||
| "nodes": [ | ||
| { | ||
| "name": "BMF", | ||
| "variant": {}, | ||
| "category": "algebraic", | ||
| "doc_path": "models/algebraic/struct.BMF.html", | ||
| "complexity": "2^(rows * rank + r | ||
| Exported to: docs/src/reductions/reduction_graph.json | ||
|
|
||
| JSON content: | ||
| { |
Review Pipeline Report
Remaining issues for final review
🤖 Generated by review-pipeline |
…-block-minimization # Conflicts: # docs/paper/reductions.typ # docs/paper/references.bib # docs/src/cli.md # docs/src/reductions/problem_schemas.json # docs/src/reductions/reduction_graph.json # problemreductions-cli/src/cli.rs # problemreductions-cli/src/commands/create.rs # problemreductions-cli/tests/cli_tests.rs # src/example_db/fixtures/examples.json # src/models/algebraic/mod.rs # src/models/mod.rs
The ModelExampleSpec struct changed on main (build closure -> instance/optimal_config/optimal_value fields). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Update canonical_model_example_specs to use the 6x6 path graph adjacency matrix with K=6 from the issue. Fix paper to use new optimal_config field format. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…ormat Update from old x.samples.at(0).config to x.optimal_config to match the current ModelExampleSpec format. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Reuse the existing --bound flag instead of adding a separate --bound-k. Other models with bound_k fields (RectilinearPictureCompression, MinimumCardinalityKey, ConsecutiveOnesSubmatrix) already map to --k. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Avoids type conversion between CLI i64 and model usize. Negative bounds correctly mean no permutation can satisfy. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
After renaming --bound-k to --bound, the negative assertion became contradictory with the positive one. Remove since --bound-k no longer exists. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Unify the field name and type for CBM, MinimumCardinalityKey, ConsecutiveOnesSubmatrix, and RectilinearPictureCompression. All now use `bound: i64` matching the CLI --bound flag directly. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Summary
Add ConsecutiveBlockMinimization satisfaction problem (Garey & Johnson SR17) to the algebraic/ category. Given an m×n binary matrix and bound K, decide whether a column permutation exists yielding at most K maximal blocks of consecutive 1's.
Fixes #420