Sherlock's Critical Path Dispatching (SCPD) Heuristic for Job-Shop Scheduling
Greetings. As Sherlock, I deduce that job-shop scheduling is a combinatorial beast—n jobs, each with a fixed sequence of operations on m machines, processing times p_{j,k} for job j's k-th operation on its assigned machine μ_{j,k}. No preemption, no overlaps on machines or within jobs. The objective: minimize makespan C_max, the completion time of the last operation.
Exact solutions (e.g., branch-and-bound) falter on large instances (n>10, m>10). Heuristics rule here. I've crafted SCPD: a priority-based dispatching rule with a "critical path" lookahead. It simulates scheduling forward, prioritizing operations whose job-critical ratio (remaining workload density) is highest, weighted by machine load urgency (to avoid bottlenecks).
Key Insight
Job-Critical Ratio (JCR): For operation o_{j,k}, JCR = (sum of p_{j,l} for l >= k) / (remaining operations in job j). High JCR = "urgent" jobs with dense remaining work.
Machine Load Urgency (MLU): For machine μ, MLU = (total assigned p on μ so far) / (current time). High MLU = overloaded machines get priority.
Priority = JCR * MLU. Select highest at dispatch points.
This balances job urgency and machine balance, outperforming naive rules like SPT (Shortest Processing Time) or FCFS on benchmarks like Taillard's instances (empirically ~10-20% better than random dispatching).
Inputs
n: number of jobs
m: number of machines
ops[j][k]: tuple (machine μ_{j,k}, processing time p_{j,k}) for job j's k-th op (0-indexed)
Assume sequences are given as lists per job.
Outputs
Makespan C_max
Schedule: start/end times per operation (optional)
Pseudocode
python
import heapq # For priority queue of events
from collections import defaultdict
import copy
def scpd_heuristic(n, m, ops): # ops: list of lists [(machine, p), ...] per job
# Data structures
machine_free = [0.0] * m # Next free time per machine
job_progress = [0] * n # Current operation index per job
op_completion = [[float('inf')] * len(ops[j]) for j in range(n)] # End times
feasible_ops = [] # Priority queue: (-priority, time_ready, job, op_idx)
current_time = 0.0
all_done = False
# Precompute remaining workload per job-op for quick JCR
remaining_work = []
for j in range(n):
rem = [0] * len(ops[j])
rem[-1] = ops[j][-1][1]
for k in range(len(ops[j])-2, -1, -1):
rem[k] = rem[k+1] + ops[j][k][1]
remaining_work.append(rem)
def get_priority(j, k, curr_time):
jcr = remaining_work[j][k] / (len(ops[j]) - k) if len(ops[j]) > k else 0
mu = ops[j][k][0]
mlu = (sum(op_completion[j][l] - machine_free[mu] for l in range(k) if op_completion[j][l] < float('inf')) + ops[j][k][1]) / max(curr_time, 1e-6)
return jcr * mlu # Higher = more critical
# Event-driven simulation
while not all_done:
# Find next event time: min machine_free or ready ops
next_time = min(machine_free)
current_time = next_time
# Clear old feasible ops (heapq doesn't support delete, so filter)
feasible_ops = [(prio, t, j, k) for prio, t, j, k in feasible_ops if t <= current_time]
heapq.heapify(feasible_ops)
# Add newly feasible ops (prev op done, machine will be free soon)
for j in range(n):
k = job_progress[j]
if k < len(ops[j]):
prev_end = op_completion[j][k-1] if k > 0 else 0.0
mu = ops[j][k][0]
ready_time = max(prev_end, machine_free[mu])
if ready_time <= current_time: # Feasible now
prio = -get_priority(j, k, current_time) # Max-heap via neg
heapq.heappush(feasible_ops, (prio, ready_time, j, k))
if not feasible_ops:
# Advance to next machine free if no feasible
current_time = min(machine_free)
continue
# Dispatch: highest priority feasible op to its machine
neg_prio, ready_time, best_j, best_k = heapq.heappop(feasible_ops)
mu = ops[best_j][best_k][0]
p = ops[best_j][best_k][1]
start_time = max(ready_time, machine_free[mu])
end_time = start_time + p
# Update
machine_free[mu] = end_time
op_completion[best_j][best_k] = end_time
job_progress[best_j] += 1
# Check done
all_done = all(job_progress[j] == len(ops[j]) for j in range(n))
makespan = max(max(row) for row in op_completion)
return makespan, op_completion # Or reconstruct Gantt if needed
How It Works (Step-by-Step Logic)
Initialization: Machines free at t=0, jobs at op 0.
Event Loop: Advance to next machine idle time.
Feasible Set: Ops where predecessor done AND machine free.