SDSC6007 Course 2

#sdsc6007

English / 中文

Shortest Path Problems (SPP)

Problem Definition

Given node set {1,2,,N,t}\{1,2,\dots,N,t\} (tt=destination),

  • aija_{ij}: Cost from node ii to jj (aij=a_{ij} = \infty if no direct path)

  • Key assumption: All cycles have non-negative cost ( cycles ij1jki, total cost0\forall \text{ cycles } i \to j_1 \to \cdots \to j_k \to i,\ \text{total cost} \geq 0)

  • Goal: Find min-cost path from any ii to tt

Significance of Non-negative Cycle Assumption

Core implication: Guarantees existence of optimal solution with finite path length

  1. Prevents infinite cost reduction:

    If  negative cycle cycleaij<0total cost can be arbitrarily reduced\text{If } \exists \text{ negative cycle } \sum_{\text{cycle}} a_{ij} < 0 \Rightarrow \text{total cost can be arbitrarily reduced}

    Example: Repeated traversal of negative-cost cycle drives cost to -\infty

  2. Self-loop constraint:

    aii0(if self-transitions allowed)a_{ii} \geq 0 \quad (\text{if self-transitions allowed})

  3. Path length bound:

    Optimal path contains at most N moves\text{Optimal path contains at most } N \text{ moves}

    • Can enforce exactly NN moves by setting aii=0a_{ii} = 0 (allowing self-loops)

Dynamic Programming Formulation

Define value function:

Jk(i)=Min cost from i to t in exactly k stepsJ_k(i) = \text{Min cost from } i \text{ to } t \text{ in exactly } k \text{ steps}

Recursion:

Jk(i)=minj[aij+Jk1(j)]J_k(i) = \min_{j} \left[ a_{ij} + J_{k-1}(j) \right]

Boundary conditions:

J0(t)=0,J0(i)= (it)J_0(t) = 0, \quad J_0(i) = \infty \ (i \neq t)

​​Practical meaning of non-negative cycle assumption​​:

This assumption ensures the shortest path problem is well-posed with a finite optimal solution. Negative-cost cycles would cause algorithms to loop indefinitely without convergence.

In real-world applications (routing, network optimization), this condition is naturally satisfied when costs represent physical quantities like distance or latency.

Deterministic Dynamic Programming

Characteristics of Deterministic Systems

Key feature: No stochastic disturbance (wkw_k absent or known constant)

  1. Fully predictable state transition:

    xk+1=fk(xk,uk)x_{k+1} = f_k(x_k, u_k)

    • State trajectory can be exactly computed given x0x_0 and policy {μ0,,μN1}\{\mu_0,\dots,\mu_{N-1}\}
  2. No advantage of closed-loop control:

    Jclosed-loop=Jopen-loopJ^{\text{closed-loop}} = J^{\text{open-loop}}

    • Optimal open-loop sequence (u0,u1,,uN1)(u_0^*,u_1^*,\dots,u_{N-1}^*) achieves same cost as closed-loop policy

Why no closed-loop advantage:

In deterministic systems, future states are entirely determined by current decisions. State feedback provides no new information, so closed-loop policies cannot improve upon precomputed open-loop sequences.

Finite-State System Modeling

State transition graph representation:

  • Nodes: States xkSkx_k \in \mathcal{S}_k (finite set)

  • Directed edges: State transitions driven by control uku_k

    xkukxk+1=fk(xk,uk)x_k \xrightarrow{u_k} x_{k+1} = f_k(x_k, u_k)

  • Edge cost: Stage cost gk(xk,uk)g_k(x_k, u_k)

Key simplification:

For each state transition xkxk+1x_k \to x_{k+1}, keep only minimum-cost decision:

ck(xk,xk+1)=minukUk(xk)fk(xk,uk)=xk+1gk(xk,uk)c_k(x_k, x_{k+1}) = \min_{\substack{u_k \in U_k(x_k) \\ f_k(x_k,u_k)=x_{k+1}}} g_k(x_k, u_k)

Dynamic Programming Equations

Value function recursion:

Jk(xk)=minxk+1[ck(xk,xk+1)+Jk+1(xk+1)]J_k(x_k) = \min_{x_{k+1}} \left[ c_k(x_k, x_{k+1}) + J_{k+1}(x_{k+1}) \right]

Boundary condition:

JN(xN)=gN(xN)J_N(x_N) = g_N(x_N)

Computational implication: Transforms problem into multi-stage shortest path

Essence of finite-state systems:

Modeling as state transition graphs reduces the problem to finding minimum-cost paths. DP becomes a backward graph traversal algorithm in this context.

Equivalence: Deterministic Finite-State Systems & Shortest Path Problems

Deterministic System → SPP

Transformation:

  1. Define nodes:

    • ss: Initial state node (corresponds to x0x_0)
    • tt: Terminal node (artificially added)
  2. Edge costs:

    • Stage kk transition: aijk=minukgk(i,uk)a_{ij}^k = \min_{u_k} g_k(i, u_k) (when fk(i,uk)=jf_k(i,u_k)=j)
      • ii: Current state
      • jj: Next state
      • uku_k: Control decision
      • gkg_k: Stage cost function
    • Terminal cost: aitN=gN(i)a_{it}^N = g_N(i)
      • gNg_N: Terminal cost function
  3. Path cost:

    Total cost=k=0N1axkxk+1k+axNtN\text{Total cost} = \sum_{k=0}^{N-1} a_{x_k x_{k+1}}^k + a_{x_N t}^N

Core equivalence: Optimal cost =J0(s)== J_0(s) = Shortest path length from ss to tt

Backward DP Algorithm

Value function:

Jk(i)=Min cost from state i at stage k to terminal tJ_k(i) = \text{Min cost from state } i \text{ at stage } k \text{ to terminal } t

  • kk: Current stage

  • ii: Current state

Recursion:

JN(i)=aitNiSN(Terminal cost: direct cost from state i to t)Jk(i)=minjSk+1[aijk+Jk+1(j)]k=N1,,0(Minimize: transition cost aijk + optimal future cost Jk+1(j))\begin{aligned} J_N(i) &= a_{it}^N \quad \forall i \in S_N \\ & \quad \text{(Terminal cost: direct cost from state } i \text{ to } t\text{)} \\ J_k(i) &= \min_{j \in S_{k+1}} \left[ a_{ij}^k + J_{k+1}(j) \right] \quad k = N-1,\dots,0 \\ & \quad \text{(Minimize: transition cost } a_{ij}^k \text{ + optimal future cost } J_{k+1}(j)\text{)} \end{aligned}

Optimal solution: J0(s)J_0(s) gives shortest path length (min cost from initial state ss to terminal tt)

SPP → Deterministic System

Transformation:

  1. Fix number of stages NN (guaranteed by non-negative cycles)

  2. Value function:

    Jk(i)=Min cost from i to t in Nk stepsJ_k(i) = \text{Min cost from } i \text{ to } t \text{ in } N-k \text{ steps}

    • NkN-k: Remaining steps
  3. Recursion:

    JN1(i)=ait(One-step transition cost)Jk(i)=minj=1,,N[aij+Jk+1(j)]k=0,,N2(Minimize: current transition cost aij + optimal future cost Jk+1(j))\begin{aligned} J_{N-1}(i) &= a_{it} \\ & \quad \text{(One-step transition cost)} \\ J_k(i) &= \min_{j=1,\dots,N} \left[ a_{ij} + J_{k+1}(j) \right] \quad k=0,\dots,N-2 \\ & \quad \text{(Minimize: current transition cost } a_{ij} \text{ + optimal future cost } J_{k+1}(j)\text{)} \end{aligned}

Key point: J0(i)J_0(i) gives shortest path cost from ii to tt

Forward DP Algorithm (Special Property)

Only for deterministic SPP:

  • Value function:

    J~k(j)=Min cost from s to j (stage k)\tilde{J}_k(j) = \text{Min cost from } s \text{ to } j \text{ (stage } k\text{)}

    • kk: Current stage
    • jj: Current state
  • Recursion:

    J~1(j)=asj0jS1(Cost from initial state s to stage 1 state j)J~k(j)=miniSk1[aijNk+1+J~k1(i)]k=2,,N(Minimize: transition cost aijNk+1 + optimal past cost J~k1(i))J~0(t)=miniSN[aitN+J~N(i)](Terminal cost: from state i to t + optimal cost to i)\begin{aligned} \tilde{J}_1(j) &= a_{sj}^0 \quad \forall j \in S_1 \\ & \quad \text{(Cost from initial state } s \text{ to stage 1 state } j\text{)} \\ \tilde{J}_k(j) &= \min_{i \in S_{k-1}} \left[ a_{ij}^{N-k+1} + \tilde{ J}_{k-1}(i) \right] \quad k=2,\dots,N \\ & \quad \text{(Minimize: transition cost } a_{ij}^{N-k+1} \text{ + optimal past cost } \tilde{J}_{k-1}(i)\text{)} \\ \tilde{J}_0(t) &= \min_{i \in S_N} \left[ a_{it}^N + \tilde{J}_N(i) \right] \\ & \quad \text{(Terminal cost: from state } i \text{ to } t \text{ + optimal cost to } i\text{)} \end{aligned}

Comparison:
Backward DP computes “cost-to-go”, forward DP computes “cost-to-arrive”.
Equivalent in deterministic SPP due to path symmetry, but forward method inapplicable to stochastic problems.

Shortest Path Application: Critical Path Analysis

Problem Description

Application scenario: Activity scheduling optimization in project management

Core objectives:

  1. Determine minimum project duration

  2. Identify critical activities (delays cause project delay)

Case Study: Dr. Yang’s Schedule Optimization

Activity decomposition:

Activity Description
Meeting with TAs Must complete
Replying emails
Lunch
Meeting with PhD students
MSc program work
Teaching

Phase division:

  • Nodes represent schedule phases (N=5N=5)

  • Edge (i,j)(i,j) represents activity with duration tij>0t_{ij}>0

  • Node 1: Start of day (no incoming edges)

  • Node 5: End of day (no outgoing edges)

截屏2025-09-10 15.22.28.png

Critical Path Algorithm

Variable Symbol Definition
Path Duration DpD_p Total duration of path pp
Calculation: Dp=(i,j)ptijD_p = \sum_{(i,j)\in p} t_{ij}
Earliest Completion Time TiT_i Earliest completion time at node ii
Calculation: Ti=maxall paths p from 1 to iDpT_i = \max_{\text{all paths } p \text{ from 1 to } i} D_p
Activity Duration tjit_{ji} Duration of activity (j,i)(j,i)
(Edge weight from node jj to ii)
Predecessor Set Pred(i)\text{Pred}(i) Set of direct predecessor nodes of ii
(Nodes with edges pointing directly to ii)
Critical Activity Condition Ti=Tj+tjiT_i = T_j + t_{ji} Necessary and sufficient condition for activity (j,i)(j,i) to be critical
(Activity has zero slack when this holds)
Slack Time Slackji\text{Slack}_{ji} Delay tolerance for non-critical activities
Calculation: Slackji=Ti(Tj+tji)\text{Slack}_{ji} = T_i - (T_j + t_{ji})

Path duration calculation:

Dp=(i,j)ptij(total duration of path p)D_p = \sum_{(i,j)\in p} t_{ij} \quad \text{(total duration of path } p\text{)}

Earliest completion time:

Ti=maxall paths p from 1 to iDp(earliest completion time at node i)T_i = \max_{\text{all paths } p \text{ from 1 to } i} D_p \quad \text{(earliest completion time at node } i\text{)}

Critical path definition:

Critical path=argmaxpDp(longest path from node 1 to 5)\text{Critical path} = \arg\max_{p} D_p \quad \text{(longest path from node 1 to 5)}

Dynamic Programming Solution

Value function:

Ti=Earliest completion time at node iT_i = \text{Earliest completion time at node } i

Recursion:

Ti=maxjPred(i)(Tj+tji)T_i = \max_{j \in \text{Pred}(i)} \left( T_j + t_{ji} \right)

where Pred(i)\text{Pred}(i) is the set of direct predecessors of node ii

Boundary condition:

T1=0T_1 = 0

Critical activity identification:
Activity (j,i)(j,i) is critical iff:

Ti=Tj+tjiT_i = T_j + t_{ji}

截屏2025-09-10 15.23.14.png

Algorithm Properties

  1. Acyclic graph guarantee:

    • Project network has no cycles → finite paths
    • Ensures max\max operation is well-defined
  2. Critical activity property:

    • All activities on critical path are critical
    • Non-critical activities have slack time:

      Slack=Ti(Tj+tji)\text{Slack} = T_i - (T_j + t_{ji})

Managerial insight:
Optimizing critical activities reduces total duration, non-critical activities allow resource flexibility