brute_force_knapsack: Solving the knapsack problem through brute force

Description Usage Arguments Details Value

View source: R/brute_force_knapsack.R

Description

Solving the knapsack problem through brute force

Usage

1

Arguments

x

is a data.frame containing knapsack data. It has two columns: v with values and w with weights.

W

is a numeric scalar which defined the maximum possible weight knapsack can handle before breaking.

parallel

is a boolean for if the function should use parallel programming.

Details

This function solves a the knapsack problem by using the brute force method. It takes a data.frame of weights and values, see function create_knapsack_data() for creating knapsack data. Then specify a maximum weight that the knapsack can hold (parameter W). The function will then return the optimal bag (in terms of value) and the indicies for the items that are put in the optimal bag. The function allows for parallel computations in Unixbased systems and in Windows. If the function is run on a Windows machine the parallel computations will be made using a cluster of instances of R.

Value

a list object containing the best bag value given the weight and the elements that make up the best bag.


TheodorEmanuelsson/knapsack documentation built on Dec. 18, 2021, 4:11 p.m.