Fix #502: Add ResourceConstrainedScheduling model#628
Open
Conversation
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>
Collaborator
Author
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
ResourceConstrainedSchedulingmodel with schema registration, brute-force-compatibledims()/evaluate(), and unit tests. - Exposes the model via
models/preludere-exports and adds CLI alias + dispatch (load/serialize) +pred createsupport. - 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()) { |
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>
Collaborator
Author
Review Pipeline Report
Commits Added
Minor Friction Points (from agentic test, non-blocking)
🤖 Generated by review-pipeline |
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 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