Description Usage Arguments Value Examples
View source: R/knapsack_greedy.R
Greedy approximation algorithm for the knapsak problem.
1 | greedy_knapsack(x, W, show_elements = TRUE, old = FALSE)
|
x |
An object with the class “data frame”, the weight of the data in the first column and price in the second column. |
W |
Maximal capacity of the knapsack. |
show_elements |
Do you want the function to display the elements, default value is to show the eletmes |
old |
Old calculations vs new ones. |
A list of the greatest combined value and the elements.
1 2 3 | x<-knapsack_data(100000)
greedy_knapsack(x,3500,F)
system.time(greedy_knapsack(x,3500))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.