Description Usage Arguments Details Value References Examples
This function solves the 0/1 Knapsack problem using dynamic programming
1 | knapsack_dynamic(x, W)
|
x |
A data.frame with two columns named in order |
W |
A numeric scalar which is the limit of the weight the knapsack can carry. |
The Knapsack problem is a combinatorial optimization problem where one tries to fill a limited weight knapsack with objects of as high a total value as possible. Every object has a positive weight and value associated with itself.
list
A list with names $value
, telling the maximum value of the knapsack
and $elements
which indicates which row objects in data.frame x
was put
in the knapsack.
http://en.wikipedia.org/wiki/Knapsack_problem
1 | knapsack_dynamic(data.frame(w=c(20,30,40,50),v=c(2,2,1,2)),W =20)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.