-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Source
Knapsack
Target
ILP (Integer Linear Programming)
Motivation
- Connects the orphan Knapsack problem to the main reduction graph (ILP has 13 inbound reductions)
- Enables solving Knapsack instances using any ILP solver
- Classic, well-known textbook reduction
Reference
Papadimitriou, C. H., & Steiglitz, K. (1982). Combinatorial Optimization: Algorithms and Complexity. Prentice-Hall. (Section on Integer Programming formulations of combinatorial problems)
Reduction Algorithm
Given a Knapsack instance with n items, weights
- Create
$n$ binary variables$x_1, \ldots, x_n$ , where$x_i = 1$ means item$i$ is selected. - Set the objective function to maximize
$v_1 x_1 + v_2 x_2 + \cdots + v_n x_n$ . - Add one constraint:
$w_1 x_1 + w_2 x_2 + \cdots + w_n x_n \le C$ . - Each variable is bounded:
$0 \le x_i \le 1$ (binary).
Solution extraction: The binary vector
Size Overhead
| Target metric | Formula |
|---|---|
num_vars |
num_items |
num_constraints |
1 |
Validation Method
Closed-loop test: construct a Knapsack instance, reduce to ILP, solve ILP with brute force, extract solution back to Knapsack, and verify optimality.
Example
Source (Knapsack): 4 items, weights = (1, 3, 4, 5), values = (1, 4, 5, 7), capacity = 7.
Target (ILP):
- Variables:
$x_1, x_2, x_3, x_4 \in {0, 1}$ - Maximize:
$x_1 + 4x_2 + 5x_3 + 7x_4$ - Subject to:
$x_1 + 3x_2 + 4x_3 + 5x_4 \le 7$
Optimal ILP solution:
Extracted Knapsack solution: Select items 2 and 3, total weight = 7, total value = 9.
This example is non-trivial because a greedy-by-value approach would pick item 4 (highest value = 7), leaving only room for item 1, yielding value = 8 < 9.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status