[ library(fd_global) | Reference Manual | Alphabetic Index ]

bin_packing(+ItemBins, ++ItemSizes, +M, +BinSize)

The one-dimensional bin packing constraint: packing N items into M bins
ItemBins
A collection of N variables or integers (domain/value between 1 and M)
ItemSizes
A collection of N non-negative integers
M
A non-negative Integer, the number of bins
BinSize
A non-negative integer

Description

This constraint is for one-dimensional bin-packing, that is, to pack N items with individual sizes into M bins, such that the sum of sizes of items in each bin does not exceed BinSize. Each element of ItemBins and its corresponding element in ItemSizes represents an item, such that the i'th element of ItemSizes is the size of the i'th item, and the i'th element in ItemBins is the bin this item is packed into.

This constraint can be seen as a special case of the cumulative/4 constraint, where all task durations are equal to 1, each bin represents a time point, and BinSize corresponds to the Resource.

This constraint and the algorithm used to implement it is described in P. Shaw, 'A Constraint for Bin Packing', CP'2004, with a fixed size for the bins. It is also described in the global constraint catalog as bin_packing, but with slightly different arguments: in the catalog, M (the number of bins) is implicitly defined by the domain of the variables in ItemBins, and the representation of item is grouped into a single argument of collection of pairs, each pair representing an item: the bin to pack the item, and its size.

See Also

bin_packing / 3, ic_edge_finder : cumulative / 4, ic_edge_finder3 : cumulative / 4, gfd : cumulative / 4, edge_finder : cumulative / 4, edge_finder3 : cumulative / 4, cumulative : cumulative / 4, ic_cumulative : cumulative / 4