Skip to content

Fix #219: [Model] SequencingWithinIntervals#222

Open
zazabap wants to merge 11 commits intoCodingThrust:mainfrom
zazabap:issue-219-sequencing-within-intervals
Open

Fix #219: [Model] SequencingWithinIntervals#222
zazabap wants to merge 11 commits intoCodingThrust:mainfrom
zazabap:issue-219-sequencing-within-intervals

Conversation

@zazabap
Copy link
Collaborator

@zazabap zazabap commented Mar 10, 2026

Summary

Add the SequencingWithinIntervals problem model — a satisfaction problem for scheduling tasks within time windows (Garey & Johnson SS1, NP-complete via Theorem 3.8).

This PR contains only the implementation plan. The plan follows the add-model skill steps 1-7:

  • Category: misc/ (scheduling input with unique structure)
  • Satisfaction problem (Metric = bool, SatisfactionProblem trait)
  • Fields: release_times, deadlines, lengths (all Vec<u64>)
  • Configuration: each variable selects a valid start time offset for its task
  • Evaluate: check all tasks within windows + no pairwise overlap

Test plan

  • Implement model in src/models/misc/sequencing_within_intervals.rs
  • Register in misc/mod.rs and models/mod.rs
  • Add CLI dispatch and alias
  • Write unit tests (creation, evaluation, solver, serialization)
  • Document in paper
  • make check passes

Fixes #219

🤖 Generated with Claude Code

zazabap and others added 2 commits March 10, 2026 14:26
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 99.35897% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.91%. Comparing base (53c13f1) to head (339db84).

Files with missing lines Patch % Lines
src/models/misc/sequencing_within_intervals.rs 98.46% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #222      +/-   ##
==========================================
+ Coverage   96.90%   96.91%   +0.01%     
==========================================
  Files         202      204       +2     
  Lines       27679    27835     +156     
==========================================
+ Hits        26823    26977     +154     
- Misses        856      858       +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.

Add a satisfaction problem model for scheduling tasks within time
windows without overlap (Garey & Johnson SS1, NP-complete).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 scheduling satisfaction model, SequencingWithinIntervals, and wires it through the library exports and CLI so it can be created/loaded/serialized and brute-force solved.

Changes:

  • Implement SequencingWithinIntervals model with schema registration, variant complexity, and evaluation logic.
  • Add unit tests covering construction, feasibility checks, brute-force solving, and serde round-trip.
  • Integrate the model into public re-exports and the CLI (alias resolution, dispatch, pred create flags/help).

Reviewed changes

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

Show a summary per file
File Description
src/models/misc/sequencing_within_intervals.rs New model implementation + schema registration + variants + tests hook
src/unit_tests/models/misc/sequencing_within_intervals.rs New unit test suite for the model
src/models/misc/mod.rs Register and re-export the new misc model
src/models/mod.rs Re-export SequencingWithinIntervals from models
src/lib.rs Add the model to the crate prelude re-exports
problemreductions-cli/src/problem_name.rs Add CLI alias mapping for the new model name
problemreductions-cli/src/dispatch.rs Add load/serialize dispatch arms for the new model
problemreductions-cli/src/commands/create.rs Add pred create support + hints/example for new flags
problemreductions-cli/src/cli.rs Add CreateArgs flags for release times / deadlines / lengths
docs/plans/2026-03-10-sequencing-within-intervals.md Plan document for implementing the model
docs/plans/2026-03-10-multiprocessor-scheduling.md New plan document for a future model

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

Comment on lines +80 to +87
for i in 0..release_times.len() {
assert!(
release_times[i] + lengths[i] <= deadlines[i],
"Task {i}: r({}) + l({}) > d({}), time window is empty",
release_times[i],
lengths[i],
deadlines[i]
);
Comment on lines +137 to +145
// Check each variable is within range and compute start times
let dims = self.dims();
let mut starts = Vec::with_capacity(n);
for (i, (&c, &dim)) in config.iter().zip(dims.iter()).enumerate() {
if c >= dim {
return false;
}
let start = self.release_times[i] + c as u64;
// Check task finishes by deadline (should hold by construction)
Comment on lines +153 to +160
for i in 0..n {
for j in (i + 1)..n {
let end_i = starts[i] + self.lengths[i];
let end_j = starts[j] + self.lengths[j];
// Tasks overlap if neither finishes before the other starts
if !(end_i <= starts[j] || end_j <= starts[i]) {
return false;
}
Comment on lines +11 to +22
inventory::submit! {
ProblemSchemaEntry {
name: "SequencingWithinIntervals",
module_path: module_path!(),
description: "Schedule tasks non-overlappingly within their time windows",
fields: &[
FieldInfo { name: "release_times", type_name: "Vec<u64>", description: "Release time r(t) for each task" },
FieldInfo { name: "deadlines", type_name: "Vec<u64>", description: "Deadline d(t) for each task" },
FieldInfo { name: "lengths", type_name: "Vec<u64>", description: "Processing length l(t) for each task" },
],
}
}
Comment on lines +5 to +10
#[test]
fn test_sequencingwithinintervals_creation() {
let problem = SequencingWithinIntervals::new(
vec![0, 0, 0, 0, 5],
vec![11, 11, 11, 11, 6],
vec![3, 1, 2, 4, 1],
zazabap and others added 8 commits March 15, 2026 10:59
Integrate SequencingWithinIntervals (PR) with registry-based dispatch
and new models (main). Use main's registry dispatch for load/serialize,
keep PR's CLI create flags with renamed --lengths field.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add missing display_name, aliases, dimensions fields to ProblemSchemaEntry.
Use 'default sat' prefix in declare_variants! macro.
Rename task_lengths CLI field to lengths to avoid clash with FlowShopScheduling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use checked_add to prevent u64 overflow in constructor
- Rename test functions to snake_case (test_sequencing_within_intervals_*)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add canonical model example in example_db (satisfaction_example)
- Add trait_consistency test entry
- Add paper display-name and problem-def block in reductions.typ

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… use blocks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zazabap
Copy link
Collaborator Author

zazabap commented Mar 15, 2026

Review Pipeline Report

Check Result
Copilot comments 2 fixed (overflow protection in constructor, test naming to snake_case)
Issue/human comments 0 actionable
Structural review 18/18 passed (4 auto-fixed: example_db, trait_consistency, paper entry, display-name)
CI pending (fork PR needs maintainer approval for Actions; local make check GREEN — 2049 lib + 62 integration + 59 doc tests, clippy clean, fmt clean)
Agentic test passed
Needs human decision 1 item
Board Review pool → Under review → Final review

Fixes applied during review

  • Merge conflicts: Resolved 7 files against main (registry-based dispatch, new models, CLI flags)
  • Copilot: overflow protection: Added checked_add in SequencingWithinIntervals::new() constructor
  • Copilot: test naming: Renamed tests from test_sequencingwithinintervals_* to test_sequencing_within_intervals_*
  • Structural: declare_variants!: Updated to default sat SequencingWithinIntervals => "2^num_tasks" (main's new format)
  • Structural: ProblemSchemaEntry: Added missing display_name, aliases, dimensions fields
  • Structural: example_db: Added canonical_model_example_specs() with satisfaction example
  • Structural: trait_consistency: Added check_problem_trait entry for SequencingWithinIntervals
  • Structural: paper: Added display-name entry and full problem-def block with definition, background, NP-completeness sketch, and example
  • Quality: duplicate re-exports: Consolidated SequencingWithinIntervals into existing pub use blocks in mod.rs and lib.rs
  • CLI field clash: Renamed SWI's task_lengths to lengths to avoid conflict with FlowShopScheduling

Remaining issues for final review

  • CI workflow approval: This is a fork PR from a first-time contributor (zazabap). GitHub Actions requires maintainer approval to run workflows on fork PRs. Local make check passes all tests. A maintainer needs to approve the workflow run from the Actions tab.

🤖 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] SequencingWithinIntervals

2 participants