Fix #220: Add MinimumTardinessSequencing model#634
Merged
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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>
Collaborator
Author
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
There was a problem hiding this comment.
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
MinimumTardinessSequencingmodel (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 createflags 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)] |
…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>
Collaborator
Author
Review Pipeline Report
Key fixes applied
🤖 Generated by review-pipeline |
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
MinimumTardinessSequencingmodel -- 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 notation1|prec, pj=1|sum Uj.Fixes #220