Skip to content

Fix #220: Add MinimumTardinessSequencing model#634

Merged
GiggleLiu merged 8 commits intomainfrom
issue-220-minimum-tardiness-sequencing
Mar 15, 2026
Merged

Fix #220: Add MinimumTardinessSequencing model#634
GiggleLiu merged 8 commits intomainfrom
issue-220-minimum-tardiness-sequencing

Conversation

@zazabap
Copy link
Collaborator

@zazabap zazabap commented Mar 13, 2026

Summary

Add MinimumTardinessSequencing model -- a classical NP-complete single-machine scheduling problem (SS2 from Garey & Johnson, 1979) where unit-length tasks with precedence constraints and deadlines must be scheduled to minimize the number of tardy tasks. Corresponds to scheduling notation 1|prec, pj=1|sum Uj.

Fixes #220

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

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.88%. Comparing base (e9f6077) to head (9b33cb8).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #634      +/-   ##
==========================================
+ Coverage   96.87%   96.88%   +0.01%     
==========================================
  Files         266      268       +2     
  Lines       35384    35563     +179     
==========================================
+ Hits        34277    34456     +179     
  Misses       1107     1107              

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

zazabap and others added 2 commits March 13, 2026 11:42
Add MinimumTardinessSequencing, a classical NP-complete single-machine
scheduling problem (SS2 from Garey & Johnson) corresponding to the
scheduling notation 1|prec, pj=1|sum Uj.

- Model: num_tasks, deadlines, precedences with permutation-based configs
- OptimizationProblem: minimize tardy task count (Value = usize)
- Complexity: 2^num_tasks (subset DP baseline)
- CLI: dispatch, alias, create support with --deadlines/--precedence-pairs
- Tests: 15 unit tests covering evaluation, brute force, serialization

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 13, 2026

Implementation Summary

Changes

  • src/models/misc/minimum_tardiness_sequencing.rs -- New model: MinimumTardinessSequencing struct with num_tasks, deadlines, precedences fields. Implements Problem (dims = vec![num_tasks; num_tasks], evaluate checks permutation validity + precedence constraints + counts tardy tasks) and OptimizationProblem (Minimize, Value = usize). Complexity: 2^num_tasks.
  • src/unit_tests/models/misc/minimum_tardiness_sequencing.rs -- 15 unit tests: basic properties, evaluate (optimal/invalid permutation/out-of-range/wrong length/precedence violation/all on time/all tardy), brute force (with and without precedences), serialization, empty instance, single task, constructor panics.
  • src/models/misc/mod.rs -- Register module and re-export.
  • src/models/mod.rs -- Add to misc re-exports.
  • src/lib.rs -- Add to prelude re-exports.
  • problemreductions-cli/src/dispatch.rs -- Add load_problem and serialize_any_problem match arms.
  • problemreductions-cli/src/problem_name.rs -- Add minimumtardinesssequencing alias.
  • problemreductions-cli/src/cli.rs -- Add --deadlines and --precedence-pairs flags, update help table.
  • problemreductions-cli/src/commands/create.rs -- Add creation handler for MinimumTardinessSequencing.

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 scheduling model, MinimumTardinessSequencing, to the misc models set, along with unit tests and CLI plumbing so instances can be created/loaded/serialized via pred.

Changes:

  • Introduces MinimumTardinessSequencing model (schema registration, evaluation logic, variant declaration).
  • Adds comprehensive unit tests for validity checks, objective evaluation, brute-force solving, and serde round-trip.
  • Extends CLI alias resolution, dispatch (load/serialize), and pred create flags to support the new model.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/models/misc/minimum_tardiness_sequencing.rs New model implementation + schema registration + variant declaration + test module hook
src/unit_tests/models/misc/minimum_tardiness_sequencing.rs New unit tests covering evaluation/validity/serialization/solver behavior
src/models/misc/mod.rs Registers the new misc model module and re-exports it
src/models/mod.rs Re-exports MinimumTardinessSequencing at the models root
src/lib.rs Adds the model to the crate prelude exports
problemreductions-cli/src/problem_name.rs Adds CLI alias resolution for the canonical name
problemreductions-cli/src/dispatch.rs Adds load/serialize support for the new optimization problem type
problemreductions-cli/src/commands/create.rs Adds pred create MinimumTardinessSequencing support (deadlines + precedence pairs parsing)
problemreductions-cli/src/cli.rs Adds new CLI flags for deadlines and precedence pairs + help text entry

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

#[test]
fn test_minimum_tardiness_sequencing_brute_force_no_precedences() {
// Without precedences, Moore's algorithm gives optimal
// 3 tasks: deadlines 1, 2, 1. Best is to schedule task with deadline 1 first.
Comment on lines +13 to +24
inventory::submit! {
ProblemSchemaEntry {
name: "MinimumTardinessSequencing",
module_path: module_path!(),
description: "Schedule unit-length tasks with precedence constraints and deadlines to minimize the number of tardy tasks",
fields: &[
FieldInfo { name: "num_tasks", type_name: "usize", description: "Number of tasks |T|" },
FieldInfo { name: "deadlines", type_name: "Vec<usize>", description: "Deadline d(t) for each task (1-indexed finish time)" },
FieldInfo { name: "precedences", type_name: "Vec<(usize, usize)>", description: "Precedence pairs (predecessor, successor)" },
],
}
}
Comment on lines +517 to +547
let num_tasks = args.n.ok_or_else(|| {
anyhow::anyhow!(
"MinimumTardinessSequencing requires --n (number of tasks)\n\n\
Usage: pred create MinimumTardinessSequencing --n 5 --deadlines 5,5,5,3,3"
)
})?;
let deadlines: Vec<usize> = util::parse_comma_list(deadlines_str)?;
let precedences: Vec<(usize, usize)> = match args.precedence_pairs.as_deref() {
Some(s) if !s.is_empty() => s
.split(',')
.map(|pair| {
let parts: Vec<&str> = pair.trim().split('>').collect();
anyhow::ensure!(
parts.len() == 2,
"Invalid precedence format '{}', expected 'u>v'",
pair.trim()
);
Ok((
parts[0].trim().parse::<usize>()?,
parts[1].trim().parse::<usize>()?,
))
})
.collect::<Result<Vec<_>>>()?,
_ => vec![],
};
(
ser(MinimumTardinessSequencing::new(
num_tasks,
deadlines,
precedences,
))?,
#[arg(long)]
pub deadlines: Option<String>,
/// Precedence pairs for MinimumTardinessSequencing (e.g., "0>3,1>3,1>4,2>4")
#[arg(long)]
zazabap and others added 3 commits March 15, 2026 08:42
…diness-sequencing

# Conflicts:
#	problemreductions-cli/src/cli.rs
#	problemreductions-cli/src/commands/create.rs
#	problemreductions-cli/src/dispatch.rs
#	problemreductions-cli/src/problem_name.rs
#	src/lib.rs
#	src/models/mod.rs
- Fix declare_variants! syntax (add default opt)
- Add missing ProblemSchemaEntry fields (aliases, dimensions, display_name)
- Fix test comment to match actual data (deadlines 1,3,2 not 1,2,1)
- Add CLI input validation for deadlines/precedences
- Regenerate docs JSON (problem_schemas.json, reduction_graph.json)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Switch to Lehmer code encoding for permutations (dims=[n,n-1,...,1])
  matching FlowShopScheduling pattern — reduces brute-force from n^n to n!
- Add canonical model example in example_db
- Add trait_consistency entry (Problem trait + Direction::Minimize)
- Add paper problem-def and display-name entries
- Add cyclic precedences test
- Regenerate docs JSON

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 4 addressed (test comment fix, ProblemSchemaEntry fields, CLI validation, docs JSON regen)
Issue/human comments 4 checked, 0 actionable (all bot/informational)
Structural review 18/18 passed (fixed: example_db, trait_consistency, paper entries, Lehmer encoding)
CI green (Test, Clippy, Code Coverage all pass)
Agentic test passed (CLI list/show/create/solve, library API, edge cases all work)
Board Review pool → Under review → Final review

Key fixes applied

  • Merged main and resolved 6 file conflicts
  • Fixed declare_variants! syntax (default opt)
  • Added missing ProblemSchemaEntry fields (aliases, dimensions, display_name)
  • Added CLI input validation for deadlines/precedences
  • Switched to Lehmer code encoding for permutations (dims=[n,n-1,...,1], matching FlowShopScheduling)
  • Added canonical model example in example_db
  • Added trait_consistency entry
  • Added paper display-name and problem-def entries
  • Added cyclic precedences test
  • Regenerated docs JSON

🤖 Generated by review-pipeline

GiggleLiu and others added 2 commits March 15, 2026 19:52
…diness-sequencing

# Conflicts:
#	docs/src/reductions/reduction_graph.json
- Add concrete pred create MinimumTardinessSequencing example to docs/src/cli.md
- Add Moore (1968) bibliography entry for the @moore1968 citation in the paper

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@GiggleLiu GiggleLiu merged commit 83be2a5 into main Mar 15, 2026
3 checks passed
@GiggleLiu GiggleLiu deleted the issue-220-minimum-tardiness-sequencing branch March 15, 2026 11:55
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] MinimumTardinessSequencing

3 participants