Description Usage Arguments Examples
This function use a heuristic or approximation for the knapsack problem. This algorithm will not give an exact result (but it can be shown that it will return at least 50 description on how to implement the greedy approach can be found here: https://en.wikipedia.org/wiki/Knapsack_problem#Greedy_approximation_algorithm
1 | greedy_knapsack(x, W)
|
x |
data.frame A data.frame that contains the weight and value of each element. |
W |
integer An integer that shows the limit for the weight that can be carried by the knapsack. |
1 2 3 4 5 6 | greedy_knapsack(x = knapsack_objects[1:800,], W = 3500)
# $value
# 192647
# $elements
# 92 574 472 80 110 537 332 117 37 776 577 288 234 255 500 794 55
# 290 436 346 282 764 599 303 345 300 243 43 747 35 77 229 719 564
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.