-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Source: Knapsack
Target: QUBO
Motivation: Enables solving Knapsack on quantum annealers (D-Wave) and via QUBO solvers; the penalty-based formulation embeds the capacity constraint into the quadratic objective.
Reference: Lucas, 2014, Ising formulations of many NP problems; Glover et al., 2019
Reduction Algorithm
Notation:
- Source:
$n$ items with weights$w_0, \ldots, w_{n-1}$ , values$v_0, \ldots, v_{n-1}$ , capacity$C$ - Target: QUBO with
$n + B$ binary variables, where$B = \lfloor \log_2 C \rfloor + 1$
Step 1 — Introduce slack variables:
Convert the inequality
The slack bits encode the unused capacity in binary.
Step 2 — Construct QUBO objective:
where
Variable mapping:
- Item variables:
$x_0, \ldots, x_{n-1}$ (same as source) - Slack variables:
$s_0, \ldots, s_{B-1}$ (auxiliary, discarded after solving)
Solution extraction: Take the
Size Overhead
| Target metric (code name) | Polynomial (using symbols above) |
|---|---|
num_vars |
|
Validation Method
Closed-loop testing: solve Knapsack by brute-force, solve the reduced QUBO, and verify that both give the same optimal value. Verify that the penalty
Example
Source instance:
| Item | Weight | Value |
|---|---|---|
| 0 | 2 | 3 |
| 1 | 3 | 4 |
| 2 | 4 | 5 |
| 3 | 5 | 7 |
QUBO formulation:
- 7 binary variables:
$x_0, x_1, x_2, x_3$ (items) +$s_0, s_1, s_2$ (slack,$B = \lfloor\log_2 7\rfloor + 1 = 3$ ) - Penalty:
$P > 3 + 4 + 5 + 7 = 19$ , so set$P = 20$ - Equality constraint:
$2x_0 + 3x_1 + 4x_2 + 5x_3 + s_0 + 2s_1 + 4s_2 = 7$
Optimal QUBO solution:
- Penalty:
$(2 + 5 + 0 - 7)^2 = 0$ (feasible) - Objective:
$H = -10 + 0 = -10$
Suboptimal feasible:
Infeasible: