View source: R/brute_force_knapsack.R
brute_force_knapsack | R Documentation |
A function that uses brute force to solve the knapsack problem
brute_force_knapsack(x, W)
x |
A data frame with two variables w = weight and v = value |
W |
A numeric scalar with the maximum weight the knapsack is allowed to contain |
The function returns a list with the optimum packed value and the corresponding elements
n <- 10 knapsack_objects <- data.frame(w = sample(1:4000, size = n, replace = TRUE), v = runif(n = n, 0, 10000)) brute_force_knapsack(x = knapsack_objects, W = 3500)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.