AddNoOverlap2D for Bin-Packing in Time and Space

Model 2D non-overlap of rectangles using the AddNoOverlap2D global constraint. Apply it to 2D bin packing and to scheduling problems where tasks need both a time interval and a contiguous block of resource slots.

Step 1 of 157%

Tutorial

The AddNoOverlap2D Constraint

A rectangle in a constraint-programming model is a pair of intervals (Xi,Yi)(X_i, Y_i), where

Xi=[six,eix],Yi=[siy,eiy]X_i = [s^x_i,\, e^x_i], \qquad Y_i = [s^y_i,\, e^y_i]

are its projections onto the xx- and yy-axes. The rectangle covers the region Xi×YiX_i \times Y_i in the plane.

The AddNoOverlap2D constraint requires that for every pair of distinct rectangles iji \ne j,

XiXj=orYiYj=.X_i \cap X_j = \emptyset \quad \text{or} \quad Y_i \cap Y_j = \emptyset.

Equivalently: two rectangles overlap in 2D iff both projections overlap in 1D.

Following the half-open scheduling convention, two 1D intervals [a,b][a, b] and [c,d][c, d] overlap iff

a<dandc<b.a < d \quad \text{and} \quad c < b.

Touching endpoints (e.g. [0,3][0,3] and [3,5][3,5]) do not count as an overlap.

For instance, take

  • R1R_1: X1=[0,3],Y1=[0,2]X_1 = [0, 3],\, Y_1 = [0, 2]
  • R2R_2: X2=[2,5],Y2=[3,4]X_2 = [2, 5],\, Y_2 = [3, 4]

The xx-projections overlap on [2,3][2, 3], but the yy-projections are disjoint since 232 \le 3. One projection disjoint \Rightarrow AddNoOverlap2D is satisfied.

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