brute_force_knapsack: brute_force_knapsack

Description Usage Arguments Examples

Description

The brute force search (the algorithm that has been used here in this funciton) by going through all possible alternatives and return the maximum value found is the only solution that is guaranteed to give a correct answer in all situations for the knapsack problem. The knapsack problem is a discrete optimization problem where we have a knapsack that can take a limited weight W and we want to fill this knapsack with a number of items i = 1, ..., n, each with a weight wi and a value vi. The goal is to find the knapsack with the largest value of the elements added to the knapsack.This problem is NP-hard. You can see more details about this problem here: https://en.wikipedia.org/wiki/Knapsack_problem

Usage

1

Arguments

x

data.frame A data.frame that contains the weight and value of each element.

W

integer An integer that shows the limit for the weight that can be carried by the knapsack.

parallel

boolean deciding if computation should be done in parallel or concurrent

Examples

1
2
3
4
5
brute_force_knapsack(x = knapsack_objects[1:8,], W = 3500)
# $value
# 16770
# $elements
# 5 8

Yusur/Rlab06 documentation built on May 13, 2019, 11:09 a.m.