Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Solutions · 11. Dependency graphs: critical paths, maximum flow and Braess’s paradox

School of Engineering, Nazarbayev University

Worked solutions to the three exercises of Lecture 11. Each solution is computed here and checked with assert statements against an exact identity or an independent calculation. The first code cell sets up the notebook and runs Demonstration 1 of the lecture without showing its output, because some of the solutions use its variables.

Exercise 1

Problem. Across 50 random positive task-duration vectors on the 9-task turnaround DAG, verify exact primal–dual LP duality between Minimum-Time Feasible Milestone Scheduling (T∗=project_durationT^* = \mathrm{project\_duration}) and Maximum Source-to-Sink Path Length (max⁡P∑u∈Pdu\max_P \sum_{u \in P} d_u), along with precedent feasibility and complementary slackness.


Exercise 1: 50-trial primal-dual verification — min makespan == max DAG path length
===================================================================================
Enumerated 4 source-to-sink paths | Verified 50/50 random duration vectors
Maximum Primal-Dual gap |T_makespan - L_longest_path| = 1.421e-14 hours

Explanation. Along any path P=(u0,u1,…,uk)P = (u_0, u_1, \dots, u_k), telescoping the primal precedence inequalities tui+1−tui≥duit_{u_{i+1}} - t_{u_i} \geq d_{u_i} plus T≥tuk+dukT \geq t_{u_k} + d_{u_k} and tu0≥0t_{u_0} \geq 0 gives Weak Duality T≥∑u∈PduT \geq \sum_{u \in P} d_u. Forward-pass earliest start times tu∗=ES(u)t_u^* = \mathrm{ES}(u) construct a feasible schedule whose finish time equals a specific predecessor-tight chain P∗P^*, proving Strong Duality T∗=max⁡P∑u∈PduT^* = \max_P \sum_{u \in P} d_u.


Exercise 2

Problem. Verify all ValueError guards on critical_path_dag (empty tasks, negative duration, unknown dependency task, and a cyclic dependency deadlock vs. naive unguarded DFS), then audit a Critical Path Shift scenario where crashing a primary task by 10 h10\ \mathrm{h} yields only 4 h4\ \mathrm{h} of net schedule reduction.


Exercise 2: Failure-mode audit — cyclic deadlock detection and critical path shift trap
=======================================================================================
Cycle detection : Kahn's in-degree check raised clean ValueError; naive DFS crashed with RecursionError
Critical Path Shift : Crashed Primary_Fab by 10.0 h, saved only 4.0 h (25 -> 21 h); 6.0 h wasted as Secondary_Pkg became critical

Explanation. (a) In any cycle CC, every node u∈Cu \in C has at least one predecessor inside CC, so its in-degree never drops to 0 during Kahn’s peel-off (len(topo) < len(tasks) detects every cycle in O(∣V∣+∣E∣)\mathcal{O}(|V|+|E|)). (b) Maximum single-task effective crash depth is bounded by the minimum slack of all parallel bypass paths (4.0 h); crashing deeper than 4.0 h requires simultaneously crashing both parallel branches.


Exercise 3

Problem. Implement pert_monte_carlo_schedule(tasks_abc, dependencies, n_trials=4000, seed=42) using exact Beta-PERT task-duration sampling (mean = (a + 4m + b)/6). Demonstrate Jensen’s Merge-Bias Inequality (E[TPERT]>TCPM(μ)\mathbb{E}[T_{\mathrm{PERT}}] > T_{\mathrm{CPM}}(\boldsymbol{\mu})) on a parallel chip-tapeout DAG and compute P50 / P90 completion quantiles plus per-task Criticality Index (probability each task lies on the realized critical path).


Exercise 3: Implement it yourself — beta-PERT stochastic scheduling and Jensen's merge bias
===========================================================================================
Deterministic CPM on Mean Durations : 23.00 days (optimistically biased)
Stochastic Beta-PERT Expected Time  : 25.50 days (Jensen merge bias = +2.50 days)
Schedule Risk Quantiles             : P50 = 25.48 d | P90 = 28.58 d | P95 = 29.56 d
Parallel Branch Criticality Indices : Core=0.33, SerDes=0.32, MemCtrl=0.35
<Figure size 814x440 with 1 Axes>

Figure S11.1. Distribution of the project duration over 4,000 Beta-PERT samples. The mean, 25.50 days (solid), lies 2.50 days above the deterministic critical-path value (dashed); the dotted line is the 90th percentile.

Summary. Because max⁡(X1,X2,X3)\max(X_1, X_2, X_3) is a convex function of parallel branch durations, Jensen’s Inequality guarantees E[max⁡kXk]≥max⁡kE[Xk]\mathbb{E}[\max_k X_k] \geq \max_k \mathbb{E}[X_k]—with strict inequality whenever parallel branches have overlapping uncertainty. Vectorized Beta-PERT simulation shows both the merge bias, +2.50 days, and the tail of the distribution (P90=28.58P_{90} = 28.58 days), which a deterministic CPM on mean durations does not show.