Description Details Author(s) References
The knapsack problem is a discrete optimization problem, in the package there are three different algorithms to approach it: Brute force search, Dynamic programming, Greedy heuristic.
This package contains three different functions for solving the knapsack problem:
brute_force_knapsack(x,W)
: goes through all possible combinations of item and return the maximum value found;
knapsack_dynamic(x,W)
: iterates over all possible values of w to find the optimum;
greedy_knapsack(x,W)
: sorts the items of decreasing order of value per unit of weight and then it proceeds to insert them into the sack until there is not more room in the sack.
All three functions take two elements:
a dataframe containing the values and the weights of each item (x
);
the knapsack maximum weight (W
).
All of them return the maximum value they found and the elements choosen to reach that value.
Barakat Bruno [aut, cre], De Biase Alessia [aut]
Maintainer: Alessia De Biase <alessia_debiase@libero.it>
https://en.wikipedia.org/wiki/Knapsack_problem
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.