greedy_knapsack: Greedy Knapsack

Description Usage Arguments Value

View source: R/greedy_knapsack.R

Description

This is a greedy approach to knapsack problem. Here unit value per weight is calculated for each item. After calculating unit per weight, the items with maximum values are selected in an order. Total value of all selected items must be below knapsack weight W. This approach does not give an exact value but returns at least 50% of the true maximum value. It reduces computational complexity due to O(n*log n).

Usage

1

Arguments

x

Data frame with two numeric columns: weights and values

W

Total weight of the knapsack

Value

List with numbers of items that can be put into knapsack and approximate maximum obtained value


faridmusayev/R_lab06 documentation built on Dec. 20, 2021, 7:44 a.m.