同步操作将从 Gitee 极速下载/javascript-algorithms 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
The knapsack problem or rucksack problem is a problem in combinatorial optimization: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible.
It derives its name from the problem faced by someone who is constrained by a fixed-size knapsack and must fill it with the most valuable items.
Example of a one-dimensional (constraint) knapsack problem: which boxes should be chosen to maximize the amount of money while still keeping the overall weight under or equal to 15 kg?
The most common problem being solved is the 0/1 knapsack problem,
which restricts the number xi
of copies of each kind of item to zero or one.
Given a set of n items numbered from 1
up to n
, each with a
weight wi
and a value vi
, along with a maximum weight
capacity W
,
maximize
subject to
and
Here xi
represents the number of instances of item i
to
include in the knapsack. Informally, the problem is to maximize
the sum of the values of the items in the knapsack so that the
sum of the weights is less than or equal to the knapsack's
capacity.
The bounded knapsack problem (BKP) removes the restriction
that there is only one of each item, but restricts the number
xi
of copies of each kind of item to a maximum non-negative
integer value c
:
maximize
subject to
and
The unbounded knapsack problem (UKP) places no upper bound
on the number of copies of each kind of item and can be
formulated as above except for that the only restriction
on xi
is that it is a non-negative integer.
maximize
subject to
and
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。