Skip to content

Fix #502: Add ResourceConstrainedScheduling model#628

Open
zazabap wants to merge 8 commits intomainfrom
issue-502-resource-constrained-scheduling
Open

Fix #502: Add ResourceConstrainedScheduling model#628
zazabap wants to merge 8 commits intomainfrom
issue-502-resource-constrained-scheduling

Conversation

@zazabap
Copy link
Collaborator

@zazabap zazabap commented Mar 13, 2026

Summary

Add the ResourceConstrainedScheduling problem model — a classical NP-complete scheduling problem (Garey & Johnson A5 SS10) where unit-length tasks must be assigned to identical processors under processor capacity and resource usage constraints per time slot.

Fixes #502

zazabap and others added 3 commits March 13, 2026 08:26
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add satisfaction problem model in src/models/misc/
- Implement Problem and SatisfactionProblem traits
- Register in CLI (dispatch, alias, create support)
- Add comprehensive unit tests (15 tests)
- Add problem definition to Typst paper

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/resource_constrained_scheduling.rs — New satisfaction problem model with Problem and SatisfactionProblem trait implementations. Struct fields: num_processors, resource_bounds, resource_requirements, deadline. Configuration space: each task assigned to a time slot in {0, ..., D-1}. Evaluation checks processor capacity and resource constraints per slot.
  • src/unit_tests/models/misc/resource_constrained_scheduling.rs — 15 unit tests covering creation, valid/invalid evaluation, brute-force solver, serialization, variant, edge cases (empty tasks, single task, multiple resources, infeasible instances).
  • src/models/misc/mod.rs — Register module and re-export.
  • src/models/mod.rs — Add to re-exports.
  • src/lib.rs — Add to prelude.
  • problemreductions-cli/src/dispatch.rs — Add load_problem and serialize_any_problem match arms using deser_sat.
  • problemreductions-cli/src/problem_name.rs — Add lowercase alias.
  • problemreductions-cli/src/commands/create.rs — Add creation handler with --num-processors, --resource-bounds, --resource-requirements, --deadline flags.
  • problemreductions-cli/src/cli.rs — Add CLI flags and help text.
  • docs/paper/reductions.typ — Add display name and problem-def entry.

Deviations from Plan

  • None

Open Questions

  • None

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #628      +/-   ##
==========================================
+ Coverage   96.86%   96.87%   +0.01%     
==========================================
  Files         264      266       +2     
  Lines       35196    35398     +202     
==========================================
+ Hits        34091    34293     +202     
  Misses       1105     1105              

☔ 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

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 satisfaction problem model, ResourceConstrainedScheduling, and wires it through the library exports, CLI loading/creation, and paper docs so it can be created/serialized/solved like existing models.

Changes:

  • Introduces ResourceConstrainedScheduling model with schema registration, brute-force-compatible dims()/evaluate(), and unit tests.
  • Exposes the model via models/prelude re-exports and adds CLI alias + dispatch (load/serialize) + pred create support.
  • Adds a paper definition entry for the new problem.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/models/misc/resource_constrained_scheduling.rs New model implementation + schema registration + variant declaration
src/unit_tests/models/misc/resource_constrained_scheduling.rs Unit tests for creation, evaluation, brute-force solving, and serde
src/models/misc/mod.rs Registers module and re-exports type from misc
src/models/mod.rs Re-exports model at crate::models::* level
src/lib.rs Adds model to prelude re-exports
problemreductions-cli/src/problem_name.rs Adds alias resolution for the canonical name
problemreductions-cli/src/dispatch.rs Adds load/serialize dispatch for the new model
problemreductions-cli/src/commands/create.rs Adds pred create ResourceConstrainedScheduling ... instance builder
problemreductions-cli/src/cli.rs Adds create flags + help text for the new model
docs/paper/reductions.typ Adds display name mapping + formal problem definition block

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

Comment on lines +11 to +23
inventory::submit! {
ProblemSchemaEntry {
name: "ResourceConstrainedScheduling",
module_path: module_path!(),
description: "Schedule unit-length tasks on m processors with resource constraints and a deadline",
fields: &[
FieldInfo { name: "num_processors", type_name: "usize", description: "Number of identical processors m" },
FieldInfo { name: "resource_bounds", type_name: "Vec<u64>", description: "Resource bound B_i for each resource i" },
FieldInfo { name: "resource_requirements", type_name: "Vec<Vec<u64>>", description: "R_i(t) for each task t and resource i (n x r matrix)" },
FieldInfo { name: "deadline", type_name: "u64", description: "Overall deadline D" },
],
}
}
.split(';')
.map(|row| util::parse_comma_list(row.trim()))
.collect::<Result<Vec<_>>>()?;

Comment on lines +152 to +163
let mut resource_usage = vec![0u64; r];

for (t, &slot) in config.iter().enumerate() {
if slot == u {
task_count += 1;
// Accumulate resource usage
for (usage, &req) in resource_usage
.iter_mut()
.zip(self.resource_requirements[t].iter())
{
*usage += req;
}
Comment on lines +130 to +135
vec![self.deadline as usize; self.num_tasks()]
}

fn evaluate(&self, config: &[usize]) -> bool {
let n = self.num_tasks();
let d = self.deadline as usize;
.iter_mut()
.zip(self.resource_requirements[t].iter())
{
*usage += req;
Comment on lines +143 to +173
// Check all time slots are in range
if config.iter().any(|&slot| slot >= d) {
return false;
}

// Check processor capacity and resource constraints at each time slot
for u in 0..d {
// Collect tasks scheduled at time slot u
let mut task_count = 0usize;
let mut resource_usage = vec![0u64; r];

for (t, &slot) in config.iter().enumerate() {
if slot == u {
task_count += 1;
// Accumulate resource usage
for (usage, &req) in resource_usage
.iter_mut()
.zip(self.resource_requirements[t].iter())
{
*usage += req;
}
}
}

// Check processor capacity
if task_count > self.num_processors {
return false;
}

// Check resource bounds
for (usage, bound) in resource_usage.iter().zip(self.resource_bounds.iter()) {
zazabap and others added 5 commits March 15, 2026 08:32
Update ProblemSchemaEntry to include display_name, aliases, dimensions fields.
Update declare_variants! to use 'default sat' prefix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Validate resource_requirements shape matches resource_bounds length in new()
- Assert deadline > 0
- Use saturating_add for resource usage accumulation to prevent overflow

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add canonical_model_example_specs for ResourceConstrainedScheduling
- Register in misc/mod.rs example specs chain
- Add trait_consistency test entry

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Check resource_requirements round-trip in serialization test
- Add #[should_panic] tests for zero deadline and mismatched requirements
- Add test for single task exceeding resource bound (infeasible instance)

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
Merge with main Conflicts resolved (8 files), API updates applied
Copilot comments 6 reviewed, 3 fixed (input validation, saturating_add, declare_variants update)
Issue/human comments 2 checked, 0 actionable
Structural review 18/18 passed (after fixing: added example-db entry, trait_consistency entry)
Test improvements Added serialization round-trip, #[should_panic] tests, adversarial cases
CI green (Test + Clippy + Coverage)
Agentic test passed — library API, CLI create, CLI solve all work correctly
Board Review pool → Under review → Final review

Commits Added

  1. Merge origin/main + fix for updated ProblemSchemaEntry/declare_variants APIs
  2. Address Copilot review: validate inputs in new(), use saturating_add
  3. Add canonical example-db entry and trait_consistency check
  4. Improve test coverage: serialization round-trip, panic tests, adversarial cases

Minor Friction Points (from agentic test, non-blocking)

  • CLI --example flag must come before problem name (contradicts pred create <Name> [flags] pattern)
  • Multi-resource --resource-requirements format not documented in CLI help

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

2 participants