Home > Back-end >  How to understand the state transition equation of 01 knapsack?
How to understand the state transition equation of 01 knapsack?

Time:09-20

Feeling of this code is not very understanding
 
F [I] [v]=Max {f [v], [I - 1] f] [I - 1 - c [I] [v] [I] + w}

"[I - 1 f] [v] represent just don't put this item in a backpack, and f [I - 1] - [v [I]] c + w [I] is a representative to the case of a value that is put in the bag after I compare the two value, it is concluded that the biggest value into now backpack,"
An object into a backpack than not, however, in the value of the big ah, this is necessary?

CodePudding user response:

You didn't write a judgment conditions, this is the capacity as a subscript, you have to consider whether the backpack is full

CodePudding user response:

Look at this is not necessary to certain

CodePudding user response:

[v] [I f - 1 - c [I]] + w. [I]
To remove a change into another

CodePudding user response:

The
refer to the original poster Jennie Libra response:
feel on a piece of code that's not a understand
 
F [I] [v]=Max {f [v], [I - 1] f] [I - 1 - c [I] [v] [I] + w}

"[I - 1 f] [v] represent just don't put this item in a backpack, and f [I - 1] - [v [I]] c + w [I] is a representative to the case of a value that is put in the bag after I compare the two value, it is concluded that the biggest value into now backpack,"
An object into a backpack than not, however, in the value of the big ah, this is necessary?


Don't put the backpack is not consumption capacity, can put a backpack after the total value is bigger

CodePudding user response:

Two is not the same package into the corresponding is so to compare two different scheme
If & lt;=total quality is to choose the item is placed in the specific package
If & gt;=total quality is above the inheritance in the specific package (packet enumeration)
  • Related