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

bin_packing(+ItemBins, ++ItemSizes, +BinLoads)

The one-dimensional bin packing constraint with loads: packing N items into M bins, each bin having a load
ItemBins
A collection of N variables or integers (domain/value between 1 and M)
ItemSizes
A collection of N non-negative integers
BinLoads
A collection of M variables or non-negative integers

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 equals the load of that bin, as specified in BinLoads. 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 of Item is the bin this item is packed into. BinLoads represent the load of each bin, i.e. the sum of the sizes of items assigned to that bin, with the j'th element representing the load for bin j. An (integer finite domain) variable for the load allows a constraint on the load to be specified, such as a minimum and/or maximum load for the bin.

This constraint and the algorithm used to implement it is described in P. Shaw, 'A Constraint for Bin Packing', CP'2004, and is described in the global constraint catalog as bin_packing_capa, where the CAPACITY parameter is replaced by a collection of domain variables

See Also

bin_packing / 4