Is Dynamic 0/1 Knackack a common joke?

I got evidence that would discredit the generally accepted idea about the 0/1 backpack problem, and it's really hard for me to convince myself. I am right because I could not find anything anywhere to support my claims, so I am going to first state my claims and then prove them, and I would be grateful if anyone would try to substantiate my claims or eliminate them. Any cooperation is welcome.

Statements:

  • The size of the bnb algorithm (branches and borders) for solving the knapsack problem does not depend on K (backpack capacity).
  • The size of the full space of the bnb tree is always O (NK), where N is the number of elements and not O (2 ^ N)
  • The bnb algorithm is always better than the standard approach to dynamic programming, both in time and in space.

Preliminary assumptions : the bnb algorithm exposes itself to invalid nodes (if the remaining capacity is less than the weight of the current element, we will not expand it. Also, the bnb algorithm is executed in the first place.

Sloppy Proof:

Here is a recursive formula for solving a backpack problem:

Value (i, k) = max (value (i-1, k), value (n-1, k-weight (i)) + value (i)

however, if k <weight (i): value (i, k) = value (i-1, k)

Now imagine this example:

K = 9
N = 3   
V W:   
5 4   
6 5   
3 2

Now here is a dynamic solution and table for this problem:

enter image description here

, , , , memoization, , - / . memoization :

enter image description here

, , bnb:

enter image description here

:

  • bnb
  • N K
  • bnb K
  • NK, O (NK)
  • bnb- ( , bnb ) O (NK), O (N ^ 2), , , .
  • , .
  • bnb , ( )
  • bnb ( ) , memoization (memoization , , .)
  • memoization, , .
  • bnb , , .

:

- , , :

  • ? , , dp knapsack, - , , , O (K) , ( ) bnb.
  • - , bnb , ( )?

ps: !

:

, , ! memoization , . Branch and Bound , , bnb + (: Coursera - ):

enter image description here

+6
3

, , DP. DP: + . . . , 2, 1. node , , .

- . " DP", (0,0) . - ( ) " ", . .

:

, . N = 3 - . : N = 20, K=63 ( ) . , :

values: [4, 10, 9, 1, 1, 2, 1, 2, 6, 4, 8, 9, 8, 2, 8, 8, 4, 10, 2, 6]
weights: [6, 4, 1, 10, 1, 2, 9, 9, 1, 6, 2, 3, 10, 7, 2, 4, 10, 9, 8, 2]
111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111
011111111111111111111111111111111111111111111111111111111111101
000001011111111111111111111111111111111111111111111111111111101
000000010111111111111111111111111111111111111111111111111111101
000000000010101011111111111111111111111111111111111111111010101
000000000000000000001010101111111111111111111111111111111010101
000000000000000000000000000101010101111111111111111111101010101
000000000000000000000000000001010101011111111111111111101010101
000000000000000000000000000000000101000001111100001111100000101
000000000000000000000000000000000000000000010100000111100000101
000000000000000000000000000000000000000000000000000010100000101
000000000000000000000000000000000000000000000000000000000000101
000000000000000000000000000000000000000000000000000000000000001

. i ( i ), k ( ). 1s - DP, . , 0 , . 68% . DP . , . 2x , , . .

, bnb . , , node , .

" " . , . . . . , K = 10^18 10^16. " " , .

, , , A * bnb. node (i, k) int(k / max(weight[1..i]) * min(values[1..i]) , .

+3

, , - . , .

, , , , : Knapsak-Problems Martello Toth , .

, , - , , , :)

, :

  • memoization, O(2^N) (, , NP-). , , / O(NK).
  • O(K) , , : "bnb- , , ".

, , , .

- "". , , , , ( )?

, , . , ( , ), - - . 2.10.1. !

+3

0/1, :

  • ,
  • node,
  • As you noticed, keeping the last two columns means that the memory requirement is lower
  • The code is simpler (no need for a note table)
+2
source

All Articles