Modeling Setup Times and Precedences

Extend job shop scheduling models in CP-SAT by encoding precedence constraints between tasks, fixed setup delays between consecutive tasks, and sequence-dependent setup times using conditional Boolean literals.

Step 1 of 157%

Tutorial

Precedence Constraints

In a scheduling model, a precedence constraint requires one task to finish before another begins. Given interval variables for tasks AA and B,B, the requirement that BB starts only after AA ends is expressed as the linear inequality

model.Add(b_start >= a_end).\texttt{model.Add(b\_start >= a\_end)}.

We write this as AB,A \prec B, read "AA precedes BB."

For example, suppose two tasks have been declared with start, duration, and end variables. Task AA has duration 55 and task BB has duration 3.3. Adding the single line

model.Add(b_start >= a_end)\texttt{model.Add(b\_start >= a\_end)}

forces the solver to choose values such that b_starta_end.b\_start \geq a\_end. One feasible assignment is

a_start=0,a_end=5,b_start=5,b_end=8.a\_start = 0,\quad a\_end = 5,\quad b\_start = 5,\quad b\_end = 8.

The constraint is a pure inequality between integer variables; no Boolean machinery is needed when the order of the two tasks is fixed in advance.

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