brute_force_knapsack: Brute force solve for the knapsack problem

View source: R/brute_force_knapsack.R

brute_force_knapsackR Documentation

Brute force solve for the knapsack problem

Description

A function that uses brute force to solve the knapsack problem

Usage

brute_force_knapsack(x, W)

Arguments

x

A data frame with two variables w = weight and v = value

W

A numeric scalar with the maximum weight the knapsack is allowed to contain

Value

The function returns a list with the optimum packed value and the corresponding elements

Examples

n <- 10
knapsack_objects <- data.frame(w = sample(1:4000, size = n, replace = TRUE),
                            v = runif(n = n, 0, 10000))
brute_force_knapsack(x = knapsack_objects, W = 3500)


TeaUnn/knapsack documentation built on April 3, 2022, 12:02 a.m.