Job Shop Scheduling in CP-SAT

Model the classical job shop scheduling problem in CP-SAT: create one interval variable per task, enforce in-job precedence with start/end inequalities, prevent machine conflicts with AddNoOverlap, and minimize the makespan with AddMaxEquality.

Step 1 of 157%

Tutorial

The Job Shop Problem and Interval Variables

A job shop scheduling problem consists of:

  • nn jobs, each an ordered sequence of tasks;
  • mm machines;
  • a fixed assignment of every task to one specific machine for an integer duration.

A valid schedule must satisfy two rules:

  1. Precedence. Within a job, task k+1k+1 cannot start before task kk ends.
  2. No overlap. Each machine processes at most one task at a time.

The standard objective is to minimize the makespan — the time at which all jobs are complete.

In CP-SAT, every task becomes an interval variable with three parts: a start, a fixed duration, and an end (equal to start+duration\text{start}+\text{duration}). We create it with

interval=NewIntervalVar(start, duration, end).\text{interval} = \text{NewIntervalVar}(\text{start},\ \text{duration},\ \text{end}).

The integer variables start and end are given the domain [0,H][0, H], where HH is a horizon — any safe upper bound on completion time. The standard, always-valid choice is the sum of all task durations:

H=j,kdj,k.H = \sum\limits_{j,\,k} d_{j,k}.

For example, the instance with Job 0 = [(M0,3),(M1,2)][(M_0,3),(M_1,2)] and Job 1 = [(M1,4),(M0,1)][(M_1,4),(M_0,1)] has 44 tasks, so the model needs 44 interval variables, and we may take H=3+2+4+1=10H = 3+2+4+1 = 10.

navigate · Enter open · Esc close · ⌘K/Ctrl K toggle