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.
Tutorial
The Job Shop Problem and Interval Variables
A job shop scheduling problem consists of:
- jobs, each an ordered sequence of tasks;
- machines;
- a fixed assignment of every task to one specific machine for an integer duration.
A valid schedule must satisfy two rules:
- Precedence. Within a job, task cannot start before task ends.
- 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 ). We create it with
The integer variables start and end are given the domain , where is a horizon — any safe upper bound on completion time. The standard, always-valid choice is the sum of all task durations:
For example, the instance with Job 0 = and Job 1 = has tasks, so the model needs interval variables, and we may take .