箱装:设置箱数,希望最小化最大箱重

use*_*062 5 optimization complexity-theory combinations bin-packing

给定n 个无限容量的箱子,我想将m个物品装入其中(每个物品都有特定的重量),同时最小化最重箱子的重量。

这不是传统的垃圾箱包装/背包问题,其中垃圾箱的容量有限,并且您试图最大限度地减少垃圾箱的使用量;我有一定数量的垃圾箱,并且想将它们全部使用,以使最重的垃圾箱的重量尽可能低。

这个问题有名字吗?我查阅了很多带有关键词的论文,但没有发现类似的内容。

干杯。

Geo*_*met 0

这是二维装箱问题的一种形式。第一个维度是每个箱的容量限制(=硬约束),第二个维度是最小化最重箱的重量(=软约束)。

使用Drools Planner,我将从云平衡示例开始并按如下方式实现:

rule "maxCapacity"
  when
    // When there is a bin ...
    $bin : Bin($binCapacity : binCapacity)
    // ... where the total of the item capacity is bigger than the bin capacity ...
    $itemCapacityTotal : Number(intValue > $binCapacity) from accumulate(
        ItemAssignment(
            bin == $bin,
            $itemCapacity : itemCapacity),
        sum($itemCapacity)
    )
  then
    // ... then lower the hard score with the insufficient capacity
    insertLogical(new IntConstraintOccurrence("maxCapacity",
            ConstraintType.NEGATIVE_HARD,
            $itemCapacityTotal.intValue() - $binCapacity,
            $bin));
end


rule "calculateWeight"
  when
    $bin : Bin()
    $itemWeightTotal : Number() from accumulate(
        ItemAssignment(
            bin == $bin,
            $itemWeight : itemWeight),
        sum($itemWeight)
    )
  then
    insertLogical(new BinToWeight($bin, $itemWeightTotal);
end
rule "minimizeWeight"
  when
    BinToWeight($bin : bin, $itemWeightTotal : itemWeightTotal)
    not BinToWeight (itemWeightTotal > $itemWeightTotal,  bin != $bin)
  then
    insertLogical(new IntConstraintOccurrence("minimizeWeight",
            ConstraintType.NEGATIVE_SOFT,
            $itemWeightTotal,
            $bin));
end
Run Code Online (Sandbox Code Playgroud)