Description Usage Arguments Value Examples
View source: R/dynamic_knapsack.R
Title Dynamic Programming-Knapsack
1 | dynamic_knapsack(x, W)
|
x |
Data frame consist of two columns w and v |
W |
Total Capacity |
Algorithm that can solve the knapsack problem exact by iterating over all possible values of w.
1 2 3 4 5 6 7 | RNGversion(min(as.character(getRversion()),"3.5.3"))
set.seed(42, kind = "Mersenne-Twister", normal.kind = "Inversion")
n <- 2000
knapsack_objects <- data.frame(
w=sample(1:4000, size = n, replace = TRUE),
v=runif(n = n, 0, 10000))
dynamic_knapsack(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.