0/1 knapsack with dependent item weight?

后端 未结 3 1874
悲哀的现实
悲哀的现实 2020-12-29 03:15

The standard 0/1 knapsack requires that the weight of every item is independent to others. Then DP is a efficient algorithm towards the solution. But now I met a similar but

3条回答
  •  余生分开走
    2020-12-29 03:31

    In the end I managed to solve the problem with the B&B method proposed by @Holt. Here is the key settings:

    (0) Before running the B&B algorithm, group all items depend on their dependency. All items in one partition have weight dependency with all other items in the same group, but not with items in other groups.

    Settings for B&B:

    (1) Upper-bound: assume that the current item has the minimum weight, i.e. assume all dependencies exist.

    (2) Lower-bound: assume that the current item has the maximum weight, i.e. assume all dependencies do not exist.

    (3) Current weight: Calculate the real current weight.

    All the above calculations can be done in a linear time by playing around with the groups we get in step 0. Specifically, when obtaining those weights, scanning only items in current group (the group which the current item be in) is enough - items in other groups have no dependencies with the current one, so it will not change the real weight of current item.

提交回复
热议问题