| Crates.io | u-ras |
| lib.rs | u-ras |
| version | 0.2.0 |
| created_at | 2025-11-23 09:13:55.248214+00 |
| updated_at | 2025-12-05 06:29:21.957044+00 |
| description | Universal Resource Allocation and Scheduling - Domain-agnostic optimization with GA, CP-SAT, dispatching rules, and time constraints |
| homepage | |
| repository | https://github.com/iyulab/U-RAS |
| max_upload_size | |
| id | 1946328 |
| size | 206,999 |
Universal Resource Allocation and Scheduling - Domain-agnostic optimization algorithms in Rust
U-RAS provides domain-agnostic optimization algorithms that can be applied to various scheduling and resource allocation problems:
[dependencies]
u-ras = "0.2"
[dependencies]
u-ras = { git = "https://github.com/iyulab/U-RAS" }
use u_ras::models::{Task, Activity, Resource, ActivityDuration};
use u_ras::scheduler::SimpleScheduler;
// Create a task with activities
let task = Task::new("T1")
.with_priority(5)
.with_activity(
Activity::new("A1", "T1", 1)
.with_duration(ActivityDuration::fixed(5000))
.with_resources("machine", vec!["M1".into(), "M2".into()])
);
// Create resources
let resources = vec![
Resource::primary("M1").with_efficiency(1.0),
Resource::primary("M2").with_efficiency(0.9),
];
// Schedule
let scheduler = SimpleScheduler::new();
let schedule = scheduler.schedule(&[task], &resources, 0);
println!("Makespan: {} ms", schedule.makespan_ms);
use u_ras::dispatching::{RuleEngine, SchedulingContext, rules};
// Create multi-layer rule engine
let engine = RuleEngine::new()
.with_rule(rules::CriticalRatio) // Primary: CR (Critical Ratio)
.with_tie_breaker(rules::Spt) // Tie-breaker: SPT
.with_tie_breaker(rules::Fifo); // Final: FIFO
// Sort activities by priority
let context = SchedulingContext::default();
let sorted = engine.sort(&activities, &context);
use u_ras::models::time_constraints::{TimeWindow, PertEstimate};
// Create deadline constraint
let window = TimeWindow::deadline(86400000) // 24 hours
.soft(1.5); // Soft constraint with penalty
// PERT 3-point estimation
let pert = PertEstimate::new(
4000, // Optimistic: 4 sec
6000, // Most Likely: 6 sec
14000 // Pessimistic: 14 sec
);
println!("Expected duration: {} ms", pert.mean_ms()); // ~7000 ms
println!("95% confidence: {} ms", pert.p95()); // ~9800 ms
| Concept | Description | Examples |
|---|---|---|
| Task | Unit of work to schedule | Job, Surgery, Delivery |
| Activity | Step within a task | Operation, Procedure, Leg |
| Resource | Allocatable entity | Machine, Doctor, Truck |
| Constraint | Rules for valid schedules | Precedence, Capacity, TimeWindow |
| Schedule | Output assignments | Activity → Resource → Time |
Core data structures for scheduling problems:
Task - Work unit containing activitiesActivity - Atomic step requiring resourcesResource - Allocatable entity with capabilitiesCalendar - Time availability windowsConstraint - Scheduling rules and limitsSchedule - Solution with assignmentsTimeWindow - Time boundary constraints (hard/soft)PertEstimate - 3-point duration estimationDurationDistribution - Probabilistic duration modelsScheduling algorithms:
SimpleScheduler - Priority-based greedy algorithmScheduleKpi - Quality metrics (makespan, tardiness, utilization)Genetic Algorithm implementations:
GaScheduler - Single-objective GAGaConfig - Algorithm parameters (population, mutation rate, etc.)Constraint Programming:
CpSat - CP-SAT solver for optimal solutionsPriority-based dispatching rules:
| Rule | Description |
|---|---|
Spt |
Shortest Processing Time |
Lpt |
Longest Processing Time |
Lwkr |
Least Work Remaining |
Mwkr |
Most Work Remaining |
| Rule | Description |
|---|---|
Edd |
Earliest Due Date |
Mst |
Minimum Slack Time |
CriticalRatio |
Critical Ratio (CR) |
SlackPerOperation |
Slack per Remaining Operation (S/RO) |
| Rule | Description |
|---|---|
Fifo |
First In First Out |
Winq |
Work In Next Queue |
Lpul |
Least Pool Utilization Level |
| Rule | Description |
|---|---|
Atc |
Apparent Tardiness Cost |
Wspt |
Weighted Shortest Processing Time |
// Combine rules with tie-breakers
let engine = RuleEngine::new()
.with_rule(rules::Atc::new(0.5)) // ATC with k-factor
.with_tie_breaker(rules::Edd)
.with_tie_breaker(rules::Fifo);
Input validation utilities:
┌─────────────────────────────────────────────────┐
│ U-RAS Core │
├─────────────────────────────────────────────────┤
│ Models: Task, Activity, Resource, TimeWindow │
│ Algorithms: GA, CP-SAT, Greedy │
│ Dispatching: 14+ rules, Multi-layer engine │
│ FFI: C-compatible interface │
└─────────────────────────────────────────────────┘
▲ ▲ ▲
│ │ │
┌──────┴───┐ ┌─────┴────┐ ┌────┴─────┐
│ U-APS │ │ Medical │ │ Logistics│
│(Manufact)│ │ Scheduler│ │ Planner │
└──────────┘ └──────────┘ └──────────┘
U-RAS compiles to a C-compatible dynamic library:
// C example
extern int uras_schedule(const char* request_json, char** result_ptr);
extern void uras_free_string(char* ptr);
// C# example
[LibraryImport("u_ras")]
public static partial int uras_schedule(string request, out IntPtr result);
Benchmarks on typical scheduling problems:
| Problem Size | GA (1000 gen) | CP-SAT | Greedy |
|---|---|---|---|
| 10 jobs, 5 resources | 50ms | 20ms | 1ms |
| 100 jobs, 20 resources | 500ms | 2s | 10ms |
| 500 jobs, 50 resources | 5s | timeout | 100ms |
Licensed under either of:
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.