greedy_knapsack: Greedy knapsack problem

Description Usage Arguments Value Examples

View source: R/greedy_knapsack.R

Description

Calulate with the greedy method how to get the maximum value out of optimal weight.

Usage

1

Arguments

x

must be a data frame with variables v (value) and w (weight)

W

integer. Specify the maximum value for the knapsack.

Value

Returns a list of the maximum value and which elemets used.

Examples

1
2
3
4
5
6
knapsack_objects <-
data.frame(
 w=sample(1:4000, size = 2000, replace = TRUE),
 v=runif(n = 2000, 0, 10000))
 greedy_knapsack(x = knapsack_objects[1:800,], W = 3500)
 greedy_knapsack(x = knapsack_objects[1:1200,], W = 2000)

herwineric/Lab6_Albin_Eric documentation built on May 21, 2019, 3:03 a.m.