The Knapsack Problem: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 14: Line 14:
  i∈S
  i∈S
</font>
</font>
so they all "fit" within the capacity:
so they all "fit" within the capacity W:
<font size=-1>
<font size=-1>
   ∑w<sub>i</sub> ≤ W
   ∑w<sub>i</sub> ≤ W
  i∈S
  i∈S
</font>
</font>

Revision as of 00:10, 28 October 2021

External

Internal

Overview

Problem Defintion

The input is given by n items {i1, i2, ... in}. Each item comes with a non-negative value vi and a non-negative and integral size wi.

Additionally, a non-negative integral capacity W is also given.

The output should be a subset S ⊆ {i1, i2, ... in} that maximizes the value of all objects of the subset:

 ∑vi
i∈S

so they all "fit" within the capacity W:

 ∑wi ≤ W
i∈S