https://github.com/danrpts/min_ukp
Generalized solution to Minimization of Unbounded Knapsack Problem.
https://github.com/danrpts/min_ukp
algorithm dynamic-programming knapsack minimization
Last synced: 3 months ago
JSON representation
Generalized solution to Minimization of Unbounded Knapsack Problem.
- Host: GitHub
- URL: https://github.com/danrpts/min_ukp
- Owner: danrpts
- License: gpl-3.0
- Created: 2017-03-09T22:26:08.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-24T20:51:24.000Z (over 7 years ago)
- Last Synced: 2024-12-31T00:33:40.563Z (5 months ago)
- Topics: algorithm, dynamic-programming, knapsack, minimization
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Problem
Given a set of items each with a weight w_i and cost c_i, add 0 or more of each item to a knapsack such that the total weight of the knapsack is at least some minimum weight W and the total cost C is minimized.## Solution
Let x be the minimum weight desired for some arbitrary knapsack, and let M[x] be its minimum cost. Using dynamic programming, we define M[x] = min_{i=1}^{n} (c_i + m[x - w_i]). The optimal cost for a knapsack with minimum weight W is then given by M[W]. Using a backtracking algorithm the optimal solution can also be found.