greedy_knapsack: greedy_knapsack

Description Usage Arguments Examples

Description

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

Usage

1

Arguments

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.

Examples

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

Yusur/Rlab06 documentation built on May 13, 2019, 11:09 a.m.