Fix #443: Add RectilinearPictureCompression model#677
Open
Fix #443: Add RectilinearPictureCompression model#677
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #677 +/- ##
==========================================
+ Coverage 97.04% 97.06% +0.02%
==========================================
Files 284 287 +3
Lines 38037 38347 +310
==========================================
+ Hits 36914 37223 +309
- Misses 1123 1124 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Implement the Rectilinear Picture Compression problem: given an m x n binary matrix M and bound K, determine if at most K axis-aligned all-1 rectangles can cover precisely the 1-entries of M. Includes model file, unit tests, CLI create support, canonical example, trait consistency check, and regenerated fixtures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…(), add solution count assertion
Contributor
Author
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
There was a problem hiding this comment.
Pull request overview
Adds a new satisfaction-problem model, RectilinearPictureCompression, to represent the NP-complete “cover 1-cells with ≤K all-1 rectangles” decision problem, along with CLI creation support and documentation/example catalog integration.
Changes:
- Introduces
RectilinearPictureCompressionmodel + schema registration + example-db spec. - Adds unit tests, CLI
pred createsupport, and fixture examples for the new model. - Regenerates/updates docs artifacts (schemas + reduction graph) and extends the paper with the new definition.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/models/misc/rectilinear_picture_compression.rs |
New model implementation, schema registration, variants, and example-db spec. |
src/models/misc/mod.rs |
Wires the new misc model module + re-export + example-db spec inclusion. |
src/models/mod.rs |
Re-exports the new model from the top-level models module. |
src/unit_tests/models/misc/rectilinear_picture_compression.rs |
Adds comprehensive unit tests for construction, maximal-rectangle enumeration, evaluation, brute-force behavior, and serialization. |
src/unit_tests/trait_consistency.rs |
Adds trait-consistency coverage for the new problem type. |
problemreductions-cli/src/commands/create.rs |
Adds pred create RectilinearPictureCompression instance construction + example flag string. |
problemreductions-cli/src/cli.rs |
Updates help text to document flags for the new problem. |
src/example_db/fixtures/examples.json |
Adds a fixture example instance + sample configs for the example database. |
docs/src/reductions/problem_schemas.json |
Adds generated schema entry for the new problem. |
docs/src/reductions/reduction_graph.json |
Adds generated variant node for the new problem (and reindexes edges accordingly). |
docs/paper/reductions.typ |
Adds paper definition/section + figure for Rectilinear Picture Compression. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+181
to
+194
| // Step 3: Filter to keep only maximal rectangles. | ||
| // A rectangle A is dominated by rectangle B if B contains A as a proper subset. | ||
| let mut maximal = Vec::new(); | ||
| for &(r1, c1, r2, c2) in &candidates { | ||
| let is_dominated = candidates.iter().any(|&(sr1, sc1, sr2, sc2)| { | ||
| sr1 <= r1 | ||
| && sc1 <= c1 | ||
| && sr2 >= r2 | ||
| && sc2 >= c2 | ||
| && (sr1, sc1, sr2, sc2) != (r1, c1, r2, c2) | ||
| }); | ||
| if !is_dominated { | ||
| maximal.push((r1, c1, r2, c2)); | ||
| } |
Comment on lines
+31
to
+33
| /// Given an m x n binary matrix M and a positive integer K, determine whether | ||
| /// there exists a collection of at most K axis-aligned all-1 rectangles that | ||
| /// covers precisely the 1-entries of M. |
docs/paper/reductions.typ
Outdated
| covering entries $M_(i j)$ for $a lt.eq i lt.eq b$ and $c lt.eq j lt.eq d$, | ||
| where every covered entry must satisfy $M_(i j) = 1$. | ||
| ][ | ||
| Rectilinear Picture Compression is a classical NP-complete problem from Garey & Johnson (A4 SR25, p.~232) @garey1979. It arises naturally in image compression, DNA microarray design, integrated circuit manufacturing, and access control list minimization. NP-completeness was established by Masek (1978) via transformation from 3SAT. The best known exact algorithm runs in $O^*(2^(m n))$ by brute-force enumeration over all possible rectangle selections#footnote[No algorithm improving on brute-force is known for the general case of Rectilinear Picture Compression.]. |
| let m = self.num_rows(); | ||
| let n = self.num_cols(); | ||
|
|
||
| // Step 1: Enumerate all all-1 rectangles by extending from each (r1, c1). |
…43-rectilinear-picture-compression # Conflicts: # docs/src/reductions/problem_schemas.json # docs/src/reductions/reduction_graph.json # problemreductions-cli/src/commands/create.rs # src/models/misc/mod.rs # src/models/mod.rs # src/unit_tests/trait_consistency.rs
- allow RectilinearPictureCompression through the crate prelude and add a regression test - replace quadratic maximal-rectangle filtering with prefix-sum extension checks - align Rectilinear documentation with bound_k = 0 support and rephrase the paper complexity note
Contributor
Author
Review Pipeline Report
Follow-up fixes
Remaining issues for final review
🤖 Generated by review-pipeline |
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 the RectilinearPictureCompression satisfaction problem model — a classical NP-complete problem (Garey & Johnson A4 SR25) asking whether a binary matrix can be exactly covered by K or fewer axis-aligned all-1 rectangles.
Fixes #443