我有2个小袋,让我们说:
$pouches = array(
array(
'id' => 1,
'weight_capacity' => 10,
'price' => 10,
),
array(
'id' => 2,
'weight_capacity' => 30,
'price' => 30,
),
);
我要插入大量文件:
$documents = array(
array(
'doc_id' => 1,
'shipping_weight' => 8,
),
array(
'doc_id' => 2,
'shipping_weight' => 7,
),
array(
'doc_id' => 3,
'shipping_weight' => 6,
),
array(
'doc_id' => 4,
'shipping_weight' => 5,
),
array(
'doc_id' => 5,
'shipping_weight' => 7,
),
array(
'doc_id' => 6,
'shipping_weight' => 8,
),
array(
'doc_id' => 7,
'shipping_weight' => 9,
),
array(
'doc_id' => 8,
'shipping_weight' => 10,
),
);
小袋只能处理文件shipping_weight
,因此找出最佳算法以寻找最有效的费用。
我目前正在使用Knapsack Algorithm - 有更好的算法吗?
我不想获得任何代码,只是算法。