Description Usage Arguments Value References Examples
Dynamic programming in in knapsack problem
1 | knapsack_dynamic(x, W)
|
x |
A dataframe with two columns: the values (v) and the weights (w) of each item to put in the knapsack. |
W |
A positive number representing the knapsack size. |
A list of two elements: a positive number with the maximum knapsack value
and a vector of all the elements
in the knapsack size.
https://en.wikipedia.org/wiki/Knapsack_problem#0.2F1_knapsack_problem
1 2 3 4 | set.seed(42)
n <- 2000
knapsack_objects <-data.frame(w=sample(1:4000, size = n, replace = TRUE),v=runif(n = n, 0, 10000))
knapsack_dynamic(x = knapsack_objects[1:8,], W = 3500)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.