Skip to content

Fix #420: Add ConsecutiveBlockMinimization model#668

Merged
isPANN merged 16 commits intomainfrom
issue-420-consecutive-block-minimization
Mar 20, 2026
Merged

Fix #420: Add ConsecutiveBlockMinimization model#668
isPANN merged 16 commits intomainfrom
issue-420-consecutive-block-minimization

Conversation

@GiggleLiu
Copy link
Copy Markdown
Contributor

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

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 98.02956% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.50%. Comparing base (aa5e687) to head (9d364fe).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...models/algebraic/consecutive_block_minimization.rs 96.19% 4 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

GiggleLiu and others added 2 commits March 16, 2026 21:08
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]>
@GiggleLiu
Copy link
Copy Markdown
Contributor Author

Implementation Summary

Changes

  • New model file: src/models/algebraic/consecutive_block_minimization.rs — ConsecutiveBlockMinimization satisfaction problem (GJ SR17)
  • Unit tests: src/unit_tests/models/algebraic/consecutive_block_minimization.rs — 7 tests covering creation, evaluation, block counting, brute-force solver, serialization, invalid permutations, empty matrix
  • Module registration: src/models/algebraic/mod.rs, src/models/mod.rs
  • CLI registration: problemreductions-cli/src/commands/create.rs (match arm + example), cli.rs (--bound-k flag)
  • Trait consistency: Added to src/unit_tests/trait_consistency.rs
  • Example DB: Regenerated fixtures with new model entry (2×3 matrix, K=2)
  • Paper: Added problem-def in docs/paper/reductions.typ with 3 bibliography entries
  • Exports: Regenerated problem_schemas.json and reduction_graph.json

Deviations from Plan

  • Changed complexity from num_cols^num_cols * num_rows * num_cols to factorial(num_cols) * num_rows * num_cols per code review — n! is the correct bound for permutation enumeration

Open Questions

  • None

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ConsecutiveBlockMinimization model implementation + unit tests, and registers it in the algebraic module exports.
  • Adds CLI support for pred create ConsecutiveBlockMinimization via --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.

Comment on lines +166 to +167
// Empty matrix: zero blocks, always satisfies any bound.
return true;
Comment on lines 1 to 12
{
"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:
{
@GiggleLiu
Copy link
Copy Markdown
Contributor Author

Review Pipeline Report

Check Result
Copilot comments 2 fixed
Issue/human comments 3 checked, 0 fixed
Structural review 18/18 passed
CI no run on latest head after 15m
Agentic test passed
Needs human decision 1 item
Board Review pool -> Under review -> Final review

Remaining issues for final review

  • GitHub did not schedule any CI workflow for the latest PR head 80dd74ba70d069577344686b74be9a2fec358bec after more than 15 minutes. gh pr view shows an empty statusCheckRollup, and gh run list --commit 80dd74ba70d069577344686b74be9a2fec358bec returns no runs. This was not auto-fixed because it appears external to the PR diff, and adding a no-op retrigger commit would add unrelated history to the contributor branch. Recommended maintainer decision: manually retrigger CI if branch protection requires checks on the latest head, or accept the previous green run on 79204ff4d336b6e9535391a59cb61f96700ae189 together with local verification (make check, valid CBM create/solve path, ragged-matrix error path) if project policy allows.

🤖 Generated by review-pipeline

isPANN and others added 3 commits March 20, 2026 16:58
…-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]>
@isPANN isPANN mentioned this pull request Mar 20, 2026
3 tasks
isPANN and others added 6 commits March 20, 2026 17:23
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]>
@isPANN isPANN merged commit 2228c61 into main Mar 20, 2026
5 checks passed
@GiggleLiu GiggleLiu deleted the issue-420-consecutive-block-minimization branch April 12, 2026 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Model] ConsecutiveBlockMinimization

3 participants