Skip to content

Fix #498: [Model] SequencingToMinimizeWeightedTardiness#672

Merged
isPANN merged 6 commits intomainfrom
issue-498-sequencing-to-minimize-weighted-tardiness
Mar 19, 2026
Merged

Fix #498: [Model] SequencingToMinimizeWeightedTardiness#672
isPANN merged 6 commits intomainfrom
issue-498-sequencing-to-minimize-weighted-tardiness

Conversation

@GiggleLiu
Copy link
Copy Markdown
Contributor

Summary

Add the execution plan and implementation for SequencingToMinimizeWeightedTardiness.

Fixes #498

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.46%. Comparing base (fa40ce7) to head (819005f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #672    +/-   ##
========================================
  Coverage   97.45%   97.46%            
========================================
  Files         351      353     +2     
  Lines       44931    45097   +166     
========================================
+ Hits        43788    43954   +166     
  Misses       1143     1143            

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

Copy link
Copy Markdown

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, SequencingToMinimizeWeightedTardiness (1 || Σ w_j T_j), and integrates it across the crate (exports, schema/variants, examples, CLI creation support, tests, and documentation/paper).

Changes:

  • Introduces SequencingToMinimizeWeightedTardiness model with Lehmer-code encoding, schema registration, and declared default variant complexity.
  • Adds unit tests + example-db fixture entry for the new model.
  • Extends pred create CLI support (flags, examples, tests) and regenerates docs JSON + paper section/bibliography.

Reviewed changes

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

Show a summary per file
File Description
src/models/misc/sequencing_to_minimize_weighted_tardiness.rs New problem model implementation + schema entry + variants + example-db spec + test wiring
src/models/misc/mod.rs Registers and re-exports the new misc model; adds to example-db aggregation
src/models/mod.rs Re-exports the new model at the top-level models module
src/lib.rs Re-exports the new model in the public prelude
src/unit_tests/models/misc/sequencing_to_minimize_weighted_tardiness.rs New model-focused unit tests (evaluation, invalid configs, solver, serialization)
src/unit_tests/trait_consistency.rs Adds the new model to trait consistency checks
src/example_db/fixtures/examples.json Adds a canonical example instance + sample/optimal configs
problemreductions-cli/src/commands/create.rs Adds pred create SequencingToMinimizeWeightedTardiness parsing + example usage text
problemreductions-cli/src/cli.rs Documents required flags for the new pred create problem type
problemreductions-cli/tests/cli_tests.rs Adds CLI tests for successful creation, mismatch rejection, and help output
docs/src/reductions/problem_schemas.json Adds generated schema entry for the new model
docs/src/reductions/reduction_graph.json Adds generated graph node for the new model and reindexes affected edges
docs/paper/references.bib Adds bibliography entries referenced by the new paper section
docs/paper/reductions.typ Adds the paper definition + example/figure block for the new model

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

Comment on lines +920 to +926
// SequencingToMinimizeWeightedTardiness
"SequencingToMinimizeWeightedTardiness" => {
let sizes_str = args.sizes.as_deref().ok_or_else(|| {
anyhow::anyhow!(
"SequencingToMinimizeWeightedTardiness requires --sizes, --weights, --deadlines, and --bound\n\n\
Usage: pred create SequencingToMinimizeWeightedTardiness --sizes 3,4,2,5,3 --weights 2,3,1,4,2 --deadlines 5,8,4,15,10 --bound 13"
)
Comment thread docs/paper/references.bib
}

@article{tanaka2009,
author = {Shunji Tanaka and Shuji Fujikuma and Mituhiko Araki},
@GiggleLiu
Copy link
Copy Markdown
Contributor Author

Agentic Review Report

Structural Check

# Check Status
1 Model file exists at src/models/misc/sequencing_to_minimize_weighted_tardiness.rs PASS
2 inventory::submit! present PASS
3 #[derive(...Serialize, Deserialize)] on struct PASS
4 Problem trait impl PASS
5 SatisfactionProblem impl PASS
6 #[cfg(test)] + #[path = "..."] test link PASS
7 Test file exists with >= 3 test functions PASS (10 tests)
8 Registered in misc/mod.rs PASS
9 Re-exported in models/mod.rs PASS
10 declare_variants! entry PASS — default sat, complexity "factorial(num_tasks)"
11 CLI create support PASS
12 Canonical model example registered PASS
13 Paper display-name entry PASS
14 Paper problem-def block PASS

Build: make test PASS, make clippy PASS, make fmt-check PASS

Issue Compliance (Issue #498): 8/8 checks passed. Lehmer code encoding (vs raw position indices) is a justified deviation — standard in this codebase. Canonical example uses K=13 (uniquely satisfying) instead of issue's K=15 — beneficial tightening.

Semantic Review:

  • evaluate(): Correct — decodes Lehmer code, computes per-job completion times and weighted tardiness with u128 overflow protection, returns total <= bound
  • dims(): Correct — [n, n-1, ..., 2, 1] for Lehmer code domain
  • Invalid inputs: Properly handled — bad digit or wrong-length config returns false
  • Complexity string "factorial(num_tasks)": Appropriate for strongly NP-complete problem with no known sub-factorial exact algorithm

Whitelist deviation: cli.rs modified with a single help-text line (not a functional concern).

Result: 14/14 structural checks passed. 0 critical, 0 important issues.


Quality Check

Design Principles:

  • DRY (Minor, pre-existing): Lehmer decode logic duplicated across 4 scheduling models in src/models/misc/. The PR follows the existing pattern (and improves on it by extracting a named decode_schedule method). A shared utility would eliminate all 4 copies, but this is pre-existing technical debt.
  • KISS: OK — clean decode_schedule / schedule_weighted_tardiness / total_weighted_tardiness decomposition
  • HC/LC: OK — single-responsibility model file, well-scoped private helpers

HCI (CLI changed):

  • Error messages: OK — actionable, include usage examples
  • Discoverability: OK — --example and help text work
  • Consistency (Minor): CLI flag --sizes maps to struct field lengths and mathematical concept "processing times." The reuse of --sizes from BinPacking is pragmatic but creates a vocabulary mismatch. A --task-lengths flag (already used by FlowShopScheduling) would be more consistent.

Test Quality:

  • 10 test functions: creation/accessors, exact tardiness computation, evaluate yes/no, invalid Lehmer digits, wrong-length config, brute-force solver (sat/unsat), paper example uniqueness verification, serialization round-trip
  • All tests are substantive with concrete value assertions
  • Minor gap: All tests use the same 5-job instance (varying only the bound). A second structurally different instance would marginally improve confidence.

Issues:

# Severity Description
1 Minor CLI --sizes vs struct lengths naming mismatch (create.rs:948)
2 Minor (pre-existing) Lehmer decode duplicated in 4 scheduling models
3 Minor All 10 unit tests use the same base instance

Agentic Feature Tests

Test Command Status
1. pred list pred list PASS — appears in catalog with complexity O(factorial(num_tasks))
2. pred show pred show SequencingToMinimizeWeightedTardiness PASS — fields, description, complexity all correct
3. pred create --example pred create --example SequencingToMinimizeWeightedTardiness PASS — valid JSON, 5-job instance
4. pred solve pred solve --solver brute-force <file> PASS — solution [0,0,2,1,0], total weighted tardiness = 13
5. pred create (manual) pred create SequencingToMinimizeWeightedTardiness --sizes ... PARTIAL PASS

Issues:

# Severity Description
1 Important Help text shows --lengths as parameter but only --sizes works. Running pred create SequencingToMinimizeWeightedTardiness displays contradictory output: Parameters section lists --lengths, Example section shows --sizes. Fix: add "lengths" => "sizes" mapping in cli_flag_name() at create.rs:217.
2 Suggestion --sizes clap help text says "Item sizes for BinPacking" — now shared with 3 problems, should use generic description

Generated by review-pipeline

isPANN and others added 2 commits March 20, 2026 02:09
…ocks, format

- Update canonical_model_example_specs to use new ModelExampleSpec struct fields
- Fix duplicate #{ block opener in reductions.typ from merge
- Restore missing load-model-example and prefix-sums bindings for CumulativeCost
- Run cargo fmt to fix import line wrapping

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The auto-generated Parameters section showed --lengths (from the schema
field name) while the Example and actual handler used --sizes. Add a
field-name override so both are consistent.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@isPANN isPANN merged commit 1bafa02 into main Mar 19, 2026
3 checks passed
@GiggleLiu GiggleLiu deleted the issue-498-sequencing-to-minimize-weighted-tardiness branch April 12, 2026 00:53
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] SequencingToMinimizeWeightedTardiness

3 participants