Skip to content

Fix #420: Add ConsecutiveBlockMinimization model#668

Open
GiggleLiu wants to merge 7 commits intomainfrom
issue-420-consecutive-block-minimization
Open

Fix #420: Add ConsecutiveBlockMinimization model#668
GiggleLiu wants to merge 7 commits intomainfrom
issue-420-consecutive-block-minimization

Conversation

@GiggleLiu
Copy link
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

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 97.51553% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.00%. Comparing base (a4c3516) to head (79204ff).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...models/algebraic/consecutive_block_minimization.rs 95.78% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #668      +/-   ##
==========================================
+ Coverage   96.97%   97.00%   +0.02%     
==========================================
  Files         277      281       +4     
  Lines       37161    37594     +433     
==========================================
+ Hits        36038    36467     +429     
- Misses       1123     1127       +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 <noreply@anthropic.com>
@GiggleLiu
Copy link
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

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
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

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

2 participants