Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 44

Job Shop Scheduling with Interval Variables

Recommended resources

Hello! Welcome back to our module on Constraint Programming.

In our last lesson, we established the core ideas of Constraint Satisfaction Problems (CSPs) and Constraint Optimization Problems (COPs). We learned that CP is a declarative approach where we define variables, their domains, and the constraints that govern them, letting a specialized solver find a feasible or optimal solution.

Today, we'll bridge the gap between that abstract framework and the practical task of modeling scheduling problems. You've seen how job shop problems can be represented with disjunctive graphs and formulated as MILPs. Now, we'll explore the CP approach, which uses specialized constructs that are often more intuitive and powerful for scheduling. Our goal is to model a job shop scheduling problem using interval variables and temporal constraints.

1. Beyond Integer Variables: The Need for Scheduling Abstractions

When we formulated scheduling problems as MILP models, we primarily used continuous or integer variables to represent points in time (e.g., start_time, completion_time). While this is a valid approach, it forces us to manually express all temporal logic. For example, a simple "no overlap" constraint between two operations, and , on the same machine requires a disjunction and big-M formulation:

This becomes very cumbersome as the number of operations grows. Constraint Programming for scheduling introduces higher-level modeling objects that capture the essence of time and resources more directly.

To understand this motivation, let's look at a short presentation from Philippe Laborie, a key architect of IBM's CP Optimizer.

Planning/Scheduling with CP Optimizer

These slides argue that traditional modeling approaches lack the right tools for scheduling. The key insight is that concepts like 'intervals' and 'functions over time' are the natural language for these problems.

Please review slides 11 through 14. Focus on the argument for why simple numerical variables are insufficient and why concepts like 'Intervals' and 'Functions' are more natural for scheduling.

This brings us to the central building block of CP scheduling models: the interval variable.


2. The Interval Variable: A Richer Representation of an Operation

Instead of representing an operation with separate variables for its start and end times, CP combines them into a single, powerful object: an interval variable.

An interval variable represents an unknown interval of time. Its value in a solution is a specific time range [start, end). The solver's job is to determine these values. An interval variable encapsulates several key properties:

  • Start: The start time of the interval.
  • End: The end time of the interval.
  • Length: The duration of the interval (end - start).
  • Size: The required processing time. In basic cases, length equals size. We will see later that this can differ if, for example, work is not continuous (e.g., pausing over a weekend).

Crucially, an interval variable can also be optional. An optional interval has an additional state: "absent." This means the solver can decide whether to include the operation in the schedule at all. This feature is immensely powerful for modeling alternatives, which is a cornerstone of the Flexible Job Shop Problem (FJSP) you are focusing on for your thesis.

Let's ground these ideas in a more formal definition.

IBM ILOG CP Optimizer for Detailed Scheduling Illustrated ...

The following paper, 'IBM ILOG CP Optimizer for Detailed Scheduling Illustrated ...', provides a clear definition of interval variables, including the concept of optionality.

Please read Section 2.1, 'Interval Variables' (the first two pages of the document). Pay close attention to the definition of an interval variable's domain and the meaning of an 'optional' interval.

The image below provides a great visual summary of these concepts.

Illustrations of Interval Variables and Temporal Constraints in Constraint Programming
Diagrams illustrating key CP scheduling concepts. (a) shows a basic interval variable α. (b) shows an optional interval β that is absent from the solution. The other diagrams illustrate constraints we will discuss next.

3. Temporal Constraints: Weaving Intervals Together

Once we model each operation as an interval variable, we need to define the rules that connect them. In CP, these rules are expressed using temporal constraints and global constraints.

Precedence Constraints

In a job shop, operations within the same job have a strict technological order. If operation must be completed before operation can begin, we can express this with a simple precedence constraint. The most common one is endBeforeStart.

endBeforeStart(a, b): This constraint ensures that if both interval variables a and b are present in the solution, the end of a must be less than or equal to the start of b.

Resource Constraints

The defining challenge of a job shop is that multiple jobs compete for the same set of machines. A machine is a unary resource (or disjunctive resource), meaning it can only process one operation at a time.

Instead of writing pairwise disjunctions for all operations on a machine, CP offers a powerful global constraint called noOverlap.

noOverlap([a, b, c, ...]): This constraint takes a set of interval variables and ensures that no two present intervals in the set overlap in time.

Illustrations of Interval Variables and Temporal Constraints in Constraint Programming
As shown in diagram (c), the `noOverlap` constraint enforces that intervals α and β do not overlap. It can also include a minimum separation time.

This is a major advantage of CP modeling. The noOverlap constraint encapsulates the complex disjunctive logic internally. The solver has highly efficient, specialized algorithms (called "propagation") to reason about this constraint, making it far more effective than a generic MILP solver handling a large number of binary variables and disjunctions.


4. Constructing a Job Shop Model

Let's now assemble these pieces to model a standard job shop scheduling problem.

Problem Definition:

  • A set of jobs .
  • A set of machines .
  • Each job consists of a sequence of operations .
  • Each operation has a specified processing time and must be processed on a specific machine .
  • Objective: Minimize the makespan (), which is the completion time of the last operation.

CP Model Formulation:

  1. Variables:

    • For each operation , create an interval variable op[i][j] with size = p_ij.
    • Create an integer variable Cmax to represent the makespan.
  2. Constraints:

    • Precedence Constraints: For each job and for each adjacent pair of operations , add a precedence constraint:
      endBeforeStart(op[i][j], op[i][j+1])
    • Resource (No-Overlap) Constraints: For each machine , create one noOverlap constraint. This constraint includes all interval variables corresponding to operations that require machine :
      noOverlap(all (i,j) such that m_ij = k: op[i][j])
    • Makespan Definition: The makespan must be greater than or equal to the end time of every operation. A simpler way is to constrain it by the end times of only the last operation of each job:
      Cmax >= endOf(op[i][last]) for all jobs .
  3. Objective:

    • minimize(Cmax)

This structure is elegant and directly maps the physical problem to the model's components. To see what this looks like in a concrete modeling language (OPL), let's examine a provided model for a flow shop, which is very similar.

IBM ILOG CP Optimizer for Detailed Scheduling Illustrated ...

The following resource provides a complete OPL model for a flow-shop problem. A flow shop is a special case of a job shop where all jobs follow the same machine sequence. The modeling principles are identical.

Please review 'Model 1' on page 154. Identify the lines that correspond to our three main components: Defining the interval variables for the operations (line 9). Defining the precedence constraints (lines 15-16). Defining the resource (no-overlap) constraints (lines 18-19).

In the flow-shop model, the noOverlap constraint at line 19 is looped over for each machine j, and for that machine, it gathers all operations (all(i in 1..n) op[i][j]). This is exactly the logic we need for a job shop as well.

Test your understanding!

Consider a simple Job Shop problem with 2 jobs and 2 machines.

  • Job 1: Operation on Machine 1 (duration 3), then Operation on Machine 2 (duration 4).
  • Job 2: Operation on Machine 2 (duration 5), then Operation on Machine 1 (duration 2).

Using the concepts we've learned, write down the variables and temporal constraints needed to model this problem.

Show answer

1. Variables:

  • op11: Interval variable with size 3.
  • op12: Interval variable with size 4.
  • op21: Interval variable with size 5.
  • op22: Interval variable with size 2.

2. Constraints:

  • Precedence Constraints (within jobs):
    • endBeforeStart(op11, op12)
    • endBeforeStart(op21, op22)
  • Resource Constraints (on machines):
    • Machine 1 is used by and : noOverlap([op11, op22])
    • Machine 2 is used by and : noOverlap([op12, op21])

These four constraints, along with an objective to minimize the makespan, completely define the problem for a CP solver.


Conclusion

In this lesson, we have taken a significant step towards building practical scheduling models using Constraint Programming. We moved beyond generic integer variables and embraced the specialized, powerful abstractions that make CP so well-suited for scheduling.

Key Takeaways:

  • Interval variables are the primary building blocks for modeling operations in time. They encapsulate start, end, and duration.
  • Optional intervals allow the solver to decide whether an activity should be part of the final schedule, a key feature for modeling problems with alternatives like FJSP.
  • Temporal constraints like endBeforeStart define the required sequencing of operations within a job.
  • The noOverlap global constraint provides an elegant and efficient way to model unary resources (like machines), ensuring that no two operations on the same machine run concurrently.

Preview of the Next Lesson:

Now that we have a solid grasp of modeling a standard job shop, we'll expand our toolkit. In the next lesson, we will explore other powerful global constraints, such as the Cumulative constraint for resources that can handle multiple tasks at once (e.g., a team of workers). We will also formally see how to model the Flexible Job Shop Problem by using the alternative constraint, which allows an operation to choose between several optional intervals representing its execution on different machines. This will bring us one step closer to modeling the full complexity of your thesis problem.