Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #667 +/- ##
==========================================
+ Coverage 96.97% 97.02% +0.04%
==========================================
Files 277 281 +4
Lines 37161 37685 +524
==========================================
+ Hits 36038 36564 +526
+ Misses 1123 1121 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add satisfaction problem for the Consecutive Ones Submatrix problem (Garey & Johnson A4 SR14): given an m×n binary matrix and bound K, decide if K columns can be selected and permuted so each row's 1-entries are consecutive (C1P). - Model in src/models/algebraic/ with Heap's algorithm for permutations - 14 unit tests including Tucker matrix examples - CLI support (pred create ConsecutiveOnesSubmatrix --matrix --k) - Paper entry with CeTZ figure and bibliography - Trait consistency and example_db registration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
There was a problem hiding this comment.
Pull request overview
Adds a new algebraic satisfaction model, ConsecutiveOnesSubmatrix, to the core library, along with CLI support, examples/fixtures, tests, and regenerated schema/reduction-graph documentation.
Changes:
- Implement
ConsecutiveOnesSubmatrixmodel (schema registration, evaluation, variants, example-db spec). - Add unit tests and wire the model into trait-consistency checks and module re-exports.
- Integrate with CLI
pred create, example fixtures, and regenerate docs JSON / paper references & section.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/unit_tests/trait_consistency.rs | Adds trait/dims sanity check coverage for the new model. |
| src/unit_tests/models/algebraic/consecutive_ones_submatrix.rs | Introduces model-specific unit tests, brute-force solver checks, and serialization tests. |
| src/models/mod.rs | Re-exports ConsecutiveOnesSubmatrix from the models top-level module. |
| src/models/algebraic/mod.rs | Registers the new algebraic module and adds example-db spec wiring. |
| src/models/algebraic/consecutive_ones_submatrix.rs | Implements the model, registers schema metadata, declares variants, and adds example-db entry + tests module. |
| src/example_db/fixtures/examples.json | Adds a fixture instance + sample/optimal configs for the new model. |
| problemreductions-cli/src/commands/create.rs | Adds pred create ConsecutiveOnesSubmatrix instance construction via --matrix and --k. |
| problemreductions-cli/src/cli.rs | Documents the new problem’s CLI flags in the help text. |
| docs/src/reductions/reduction_graph.json | Adds the model node to the generated reduction graph docs (including shifted indices). |
| docs/src/reductions/problem_schemas.json | Adds the model schema to the generated schema docs. |
| docs/paper/references.bib | Adds Booth (1975) and Booth–Lueker (1976) references. |
| docs/paper/reductions.typ | Adds a paper definition + worked example/figure block for the model. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+133
to
+164
| /// Check if any permutation of the given columns has C1P. | ||
| fn any_permutation_has_c1p(&self, cols: &[usize]) -> bool { | ||
| let k = cols.len(); | ||
| if k == 0 { | ||
| return true; | ||
| } | ||
| let mut perm: Vec<usize> = cols.to_vec(); | ||
| // Generate all permutations using Heap's algorithm | ||
| let mut c = vec![0usize; k]; | ||
| if self.has_c1p(&perm) { | ||
| return true; | ||
| } | ||
| let mut i = 0; | ||
| while i < k { | ||
| if c[i] < i { | ||
| if i % 2 == 0 { | ||
| perm.swap(0, i); | ||
| } else { | ||
| perm.swap(c[i], i); | ||
| } | ||
| if self.has_c1p(&perm) { | ||
| return true; | ||
| } | ||
| c[i] += 1; | ||
| i = 0; | ||
| } else { | ||
| c[i] = 0; | ||
| i += 1; | ||
| } | ||
| } | ||
| false | ||
| } |
| impl SatisfactionProblem for ConsecutiveOnesSubmatrix {} | ||
|
|
||
| crate::declare_variants! { | ||
| default sat ConsecutiveOnesSubmatrix => "2^(num_cols) * num_rows", |
docs/paper/reductions.typ
Outdated
| let selected = cfg.enumerate().filter(((i, v)) => v == 1).map(((i, v)) => i) | ||
| [ | ||
| #problem-def("ConsecutiveOnesSubmatrix")[ | ||
| Given an $m times n$ binary matrix $A$ and a positive integer $K <= n$, determine whether there exists a subset of $K$ columns of $A$ whose columns can be permuted so that in each row all 1's occur consecutively (the _consecutive ones property_). |
Comment on lines
+3
to
+6
| //! Given an m×n binary matrix A and a positive integer K ≤ n, determine whether | ||
| //! there exists a subset of K columns whose columns can be permuted so that in | ||
| //! each row all 1's occur consecutively. NP-complete (Booth, 1975) via | ||
| //! transformation from Hamiltonian Path. |
…17-consecutive-ones-submatrix # Conflicts: # docs/paper/reductions.typ # docs/src/reductions/problem_schemas.json # docs/src/reductions/reduction_graph.json # problemreductions-cli/src/commands/create.rs # src/example_db/fixtures/examples.json
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
Add ConsecutiveOnesSubmatrix model — a satisfaction (decision) problem from Garey & Johnson A4 SR14. Given an m×n binary matrix and integer K, determines whether K columns can be selected and permuted so that each row's 1-entries are consecutive.
Fixes #417