项目作者: danrpts

项目描述 :
Generalized solution to Minimization of Unbounded Knapsack Problem.
高级语言: JavaScript
项目地址: git://github.com/danrpts/min_ukp.git
创建时间: 2017-03-09T22:26:08Z
项目社区:https://github.com/danrpts/min_ukp

开源协议:GNU General Public License v3.0

下载


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.