Resource Dilation Factor for Scheduling

Data Pipelines, Monitoring & Reliability DS practice problem on Onlearn.

Difficulty: medium.

Topics: Resource Dilation Factor for Scheduling, Critical Path Method, Over-provisioning Ratio, Little's Law, Tail Latency Percentiles, Dynamic Scaling Thresholds, Distributed Systems, Operations Research, Performance Engineering, Cloud Infrastructure, Stochastic Modeling, Task Scheduling Algorithms, Resource Provisioning, Queueing Theory, Latency Analysis, Capacity Planning.

Implement a function that computes the resource dilation factor for a set of tasks scheduled under limited resource capacity. In resource constrained scheduling (relevant to multi agent RL, job scheduling MDPs, and planning under constraints), the dilation factor measures how much longer the actual schedule takes compared to an ideal theoretical lower bound. You are given: tasks: A list of dictionaries, each with keys: "duration": positive number, the time to complete the task "resources": positive integer, the number of resource units the task requires while running "dependencies": list of task indices that must complete before this task can start capacity: total number of available resource units at any time Your function should: 1. Compute the critical path length through the dependency DAG (the longest chain of sequential task durations, ignoring resource constraints). 2. Compute the total work (sum of duration times resources across all tasks). 3. Determine the lower bound on makespan as the maximum of the critical path length and total work divided by capacity. 4. Simulate a greedy list schedule: at each time step, process task completions, then attempt to schedule all ready tasks (dependencies met, not yet scheduled) in order of their index, as long as sufficient resources remain. 5. Compute the actual makespan (latest finish time) and the dilation factor (actual makespan divided by lower bound). Return a dictionary with keys: "dilation factor": the dilation factor, rounded to 4 decimal places "actual makespan": the scheduled makespan, rounded to 4 decimal places "lower bound": the theoretical lower bound, rounded to 4 decimal places "start times": list of start times for each task, rounded to 4 decimal places