[ library(gfd) | Reference Manual | Alphabetic Index ]
bin_packing(+Items, ++ItemSizes, +BinLoads)
The one-dimensional bin packing constraint with loads: packing M items into N bins, each bin having a load
- Items
- A collection of M (domain) variables or integers (domain/value between 1 and N)
- ItemSizes
- A collection of M non-negative integers
- BinLoads
- A collection of N (domain) variables or non-negative integers
Description
This constraint is for one-dimensional bin-packing, that is, to pack M
items with individual sizes into N 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 Items 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.
Note that the Gecode implementation of this constraint has index starting
from 0, i.e. the numbering for the bins starts from 0. These native
indices are mapped to the ECLiPSe indices starting from 1 with an
additional dummy zero'th bin that is assigned a dummy item 0. A version
of this constraint that uses native Gecode indexing is available
as bin_packing_g/3.
The global constraint catalog describes this constraint as a
variation of their bin_packing constraint where the fixed capacity for
every bin is replaced by the BinLoads variables. In addition, a more
restricted version of this constraint is also described in the global
constraint catalog as bin_packing_capa, where instead of BinLoads,
each bin is given its own integer capacity, the maximum load that
bin can take, this is equivalent to giving the corresponding variable
for the bin in BinLoads the domain 0..Capacity.
This constraint is implemented using Gecode's binpacking() constraint.
Examples
[eclipse 7]: bin_packing([3,1,3], [4,3,1], [L1,L2,L3,L4]).
L1 = 3
L2 = 0
L3 = 5
L4 = 0
See Also
bin_packing / 4, bin_packing_g / 3, fd_global : bin_packing / 3, ic_global : bin_packing / 3