Description Arguments Details Value Author(s) References Examples
This class will generate a dataset for knapsack in initialized function
ks_dataset |
is a data.frame generated by initialzed function which contain variables W and V, weights and values |
ks_size |
is the total size of the knapsack |
Bruteforce, dynamimc programming and greedy algorithm for the knapsack problem
This algorithm gives all possbile values with good accuracy, and also gives the maximum value for the knapsack
This algorithm gives all possbile values with good accuracy, and also gives the maximum value for the knapsack
This algorithm gives all possbile values with good accuracy, and also gives the maximum value for the knapsack
This function will return a list of selected elements and their total values
This function will return a list of selected elements and their total values
This function will return a list of selected elements and their total values
Mahmood Siddique
https://en.wikipedia.org/wiki/Knapsack_problem
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
obj <- knapsack_class$new()
## End(Not run)
## Not run:
obj$brute_force_knapsack(obj$ks_dataset[1:8,],3500)
obj$brute_force_knapsack(obj$ks_dataset[1:12,],3500)
obj$brute_force_knapsack(obj$ks_dataset[1:8,],3500,Paral = TRUE)
## End(Not run)
## Not run:
obj$knapsack_dynamic(obj$ks_dataset[1:8,],3500)
obj$knapsack_dynamic(obj$ks_dataset[1:12,],3500)
obj$knapsack_dynamic(obj$ks_dataset[1:8,],2000)
## End(Not run)
## Not run:
obj$greedy_knapsack(obj$ks_dataset[1:8,],3500)
obj$greedy_knapsack(obj$ks_dataset[1:12,],3500)
obj$greedy_knapsack(obj$ks_dataset[1:8,],2000)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.