-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Source: Knapsack
Target: ILP
Motivation: Enables solving Knapsack via ILP solvers; the most direct formulation since Knapsack is a single-constraint ILP.
Reference: Kellerer, Pferschy & Pisinger, Knapsack Problems, 2004, Ch. 12
Reduction Algorithm
Notation:
- Source:
$n$ items with weights$w_0, \ldots, w_{n-1}$ , values$v_0, \ldots, v_{n-1}$ , capacity$C$ - Target: ILP with binary variables, one linear constraint, and a maximize objective
Variable mapping:
Each Knapsack variable maps directly to an ILP variable (identity mapping).
Constraint:
Objective:
Solution extraction: The ILP solution
Size Overhead
| Target metric (code name) | Polynomial (using symbols above) |
|---|---|
num_vars |
|
num_constraints |
Validation Method
Closed-loop testing: solve Knapsack by brute-force (
Example
Source instance:
| Item | Weight | Value |
|---|---|---|
| 0 | 2 | 3 |
| 1 | 3 | 4 |
| 2 | 4 | 5 |
| 3 | 5 | 7 |
ILP formulation:
- 4 binary variables:
$x_0, x_1, x_2, x_3$ - 1 constraint:
$2x_0 + 3x_1 + 4x_2 + 5x_3 \leq 7$ - Objective: maximize
$3x_0 + 4x_1 + 5x_2 + 7x_3$
Optimal ILP solution:
Extracted Knapsack solution: select items