brute_force_knapsack: Brute force knapsack problem algorithm

Description Usage Arguments Value Examples

View source: R/knapsack.R

Description

Brute force knapsack problem algorithm

Usage

1

Arguments

x

A data frame with two variables, v and w, only containing positive values.

W

Knapsack size.

fast

Logical; whether to run the algorithm via C++ code or R code. Default is FALSE, i.e., R code.

Value

A list containing the value of the knapsack and it's corresponding elements.

Examples

1
2
3
4
5
6
7
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)

Safvenberger/Lab6RT documentation built on Oct. 16, 2020, 1:56 a.m.