PACK
bin_packing_constraint-1 <…bin_packing_constraint-n> ;
where bin_packing_constraint is specified in the following form:
( ( <… >) ( <… >) ( <… > ) )
The PACK constraint is used to assign items to bins, subject to the sizes of the items and the capacities of the bins. The item variable assigns a bin to the th item. The variable holds the size or weight of the th item. The domain of the load variable constrains the capacity of bin .
For example, suppose there are three bins with capacities 3, 4, and 5. There are five items with sizes 4, 3, 2, 2, and 1 to be assigned to these three bins. The following statements formulate the problem and find a solution:
proc clp out=out; var bin1 = [0,3]; var bin2 = [0,4]; var bin3 = [0,5]; var (item1-item5) = [1,3]; pack ((item1-item5) (4,3,2,2,1) (bin1-bin3)); run;
Each row of Table 3.2 represents a solution to the problem. The number in each item column is the number of the bin to which the corresponding item is assigned.
Table 3.2: Bin Packing Solutions
Item Variable |
|||||
---|---|---|---|---|---|
item1 |
item2 |
item3 |
item4 |
item5 |
|
2 |
3 |
3 |
1 |
1 |
|
2 |
3 |
1 |
3 |
1 |
|
2 |
1 |
3 |
3 |
3 |
|
3 |
1 |
2 |
2 |
3 |
Note: In specifying a PACK constraint, it can be more efficient to list the item variables in order by nonincreasing size and to specify VARSELECT=FIFO in the PROC CLP statement.