Skip to content

Fix #421: Add ConsecutiveSets model#670

Merged
zazabap merged 11 commits intomainfrom
issue-421-consecutive-sets
Mar 18, 2026
Merged

Fix #421: Add ConsecutiveSets model#670
zazabap merged 11 commits intomainfrom
issue-421-consecutive-sets

Conversation

@GiggleLiu
Copy link
Contributor

Summary

Add ConsecutiveSets satisfaction problem model (Garey & Johnson A4 SR18). Given a finite alphabet, collection of subsets, and bound K, decides if a string of length ≤ K exists where each subset's elements appear consecutively.

Fixes #421

@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 99.40476% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.18%. Comparing base (3e409d1) to head (5e24cee).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/models/set/consecutive_sets.rs 98.93% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main     #670    +/-   ##
========================================
  Coverage   97.17%   97.18%            
========================================
  Files         304      306     +2     
  Lines       40061    40229   +168     
========================================
+ Hits        38931    39097   +166     
- Misses       1130     1132     +2     

☔ 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
Copy link
Contributor Author

Implementation Summary

Changes

  • src/models/set/consecutive_sets.rs — New ConsecutiveSets satisfaction model (struct, constructor with validation, Problem/SatisfactionProblem impls, ProblemSchemaEntry, declare_variants!, canonical example)
  • src/unit_tests/models/set/consecutive_sets.rs — 11 unit tests (creation, evaluation, NO instance brute force, solver, serialization, empty subsets, wrong config length, internal unused rejection, 3 should_panic constructors)
  • src/models/set/mod.rs — Module registration and example spec chain
  • src/models/mod.rs — Re-export
  • src/lib.rs — Prelude re-export
  • src/unit_tests/trait_consistency.rs — Added ConsecutiveSets entry
  • src/example_db/fixtures/examples.json — Regenerated with new model
  • docs/src/reductions/problem_schemas.json — Regenerated schemas
  • docs/src/reductions/reduction_graph.json — Regenerated graph
  • docs/paper/reductions.typ — problem-def + display-name entry with worked example
  • docs/paper/references.bib — Added Kou 1977 and Booth & Lueker 1976

Deviations from Plan

  • None

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 a new NP-complete set-based satisfaction model, ConsecutiveSets, and wires it into the library’s schema/variant registry, examples, docs, and unit tests.

Changes:

  • Introduce ConsecutiveSets model (schema registration, Problem/SatisfactionProblem impl, variants, example-db spec).
  • Add unit tests + trait-consistency coverage for the new model.
  • Update example fixtures and generated docs assets (schemas + reduction graph) and paper references/definitions.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/unit_tests/trait_consistency.rs Adds ConsecutiveSets to the generic Problem trait consistency check.
src/unit_tests/models/set/consecutive_sets.rs New unit tests for construction, evaluation, brute-force solving, and serde round-trip.
src/models/set/mod.rs Registers and re-exports the new set model; includes example-db spec hook.
src/models/set/consecutive_sets.rs New ConsecutiveSets model implementation + schema/variants + example-db spec + test module link.
src/models/mod.rs Re-exports ConsecutiveSets from the top-level models module.
src/lib.rs Re-exports ConsecutiveSets in the crate prelude.
src/example_db/fixtures/examples.json Adds canonical example fixture entry for ConsecutiveSets.
docs/src/reductions/reduction_graph.json Adds node for ConsecutiveSets and updates indices/edges accordingly (generated artifact).
docs/src/reductions/problem_schemas.json Adds schema entry for ConsecutiveSets (generated artifact).
docs/paper/references.bib Adds citations relevant to Consecutive Sets / consecutive ones property.
docs/paper/reductions.typ Adds paper section entry/definition/example for ConsecutiveSets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +163 to +170
let mut found = false;
for start in 0..=(str_len - subset_len) {
let window = &w[start..start + subset_len];
// Check if window is a permutation of subset
let mut window_sorted: Vec<usize> = window.to_vec();
window_sorted.sort();
if window_sorted == *subset {
// subset is already sorted
Comment on lines +163 to +167
let mut found = false;
for start in 0..=(str_len - subset_len) {
let window = &w[start..start + subset_len];
// Check if window is a permutation of subset
let mut window_sorted: Vec<usize> = window.to_vec();
…21-consecutive-sets

# Conflicts:
#	docs/src/reductions/problem_schemas.json
#	docs/src/reductions/reduction_graph.json
#	src/example_db/fixtures/examples.json
#	src/lib.rs
#	src/models/mod.rs
#	src/unit_tests/trait_consistency.rs
@GiggleLiu
Copy link
Contributor Author

Review Pipeline Report

Check Result
Copilot comments 2 addressed
Issue/human comments 3 checked, 0 new fixes
Structural review 16/16 passed
CI green
Agentic test passed
Needs human decision none
Board Review pool -> Under review -> Final review

Remaining issues for final review

  • None.

🤖 Generated by review-pipeline

Integrate ComparativeContainment, MinimumCardinalityKey, LongestCommonSubsequence,
MinimumMultiwayCut, StaffScheduling, and StringToStringCorrection from main alongside
ConsecutiveSets additions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@zazabap zazabap merged commit 514d5ff into main Mar 18, 2026
5 checks passed
@zazabap zazabap deleted the issue-421-consecutive-sets branch March 18, 2026 09:13
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] ConsecutiveSets

3 participants