brute_force_knapsack: brute_force_knapsack

Description Usage Arguments Value Examples

View source: R/brute_force_knapsack.R

Description

Given data frame x, max weight W, give the best solution with brutal force of O(2^n)

Usage

1

Arguments

x,

a data frame of items with different values and weights

W,

the capacity of knapsack

fast,

logical signal when Rcpp function activated

Value

a list with best value and selected elements

Examples

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

LiU-Task/FancyPackRLiU6 documentation built on Oct. 30, 2019, 8:24 p.m.