brute_force_knapsack: Solve the knapsack problem using a brute force approach.

Description Usage Arguments Value Examples

View source: R/lab06.R

Description

Solve the knapsack problem using a brute force approach.

Usage

1

Arguments

x

A data frame object, containing two variables v and w. v contains the value of the object n and w its value.

W

An integer, representing the capacity of the knapsack.

Value

A list with two objects: $value which is the value of the knapsack and an object $elements which are the elements contained in the knapsack.

Examples

1
2
3
4
\code{set.seed(42)}
\code{x <- data.frame(w=sample(1:4000, size = 10, replace = TRUE), v=runif(n = 10, 0, 10000))}
\code{W <- 3500}
\code{brute_force_knapsack(x, W)}

josme478/lab06 documentation built on Nov. 4, 2019, 3:21 p.m.