-
Notifications
You must be signed in to change notification settings - Fork 3
[Model] QuadraticAssignmentProblem #104
Description
Motivation
One of the hardest NP-hard combinatorial optimization problems; has natural reductions to QUBO and ILP. Widely used in VLSI layout, facility planning, and logistics.
Definition
Name: QuadraticAssignmentProblem
Reference: Koopmans & Beckmann, 1957; Sahni & Gonzalez, 1976
Given
Variables
-
Count:
$n^2$ (one binary variable$x_{ik}$ per facility-location pair) -
Per-variable domain: binary
${0, 1}$ -
Meaning:
$x_{ik} = 1$ if facility$i$ is assigned to location$k$ . Permutation constraints:$\sum_k x_{ik} = 1$ for all$i$ ,$\sum_i x_{ik} = 1$ for all$k$ .
Schema (data type)
Type name: QuadraticAssignmentProblem
Variants: symmetric (
| Field | Type | Description |
|---|---|---|
| flow | Vec<Vec<f64>> |
Flow matrix |
| distance | Vec<Vec<f64>> |
Distance matrix |
Problem Size
| Metric | Expression | Description |
|---|---|---|
| num_facilities | Number of facilities (and locations) |
Complexity
- Decision complexity: NP-hard; NP-hard to approximate within any constant factor (Sahni & Gonzalez, 1976)
-
Best known exact algorithm:
$O(2^n \cdot n)$ via dynamic programming; practically solved up to$n \approx 30$ with branch-and-bound - References: Sahni & Gonzalez 1976; QAPLIB benchmark library
Extra Remark
QAP generalizes TSP (set
How to solve
- It can be solved by (existing) bruteforce.
- It can be solved by reducing to integer programming, through a new QAP → ILP rule issue (to be filed).
Bruteforce: enumerate all
Example Instance
Flow matrix
| 0 | 1 | 2 | 3 | |
|---|---|---|---|---|
| 0 | 0 | 3 | 7 | 2 |
| 1 | 3 | 0 | 1 | 5 |
| 2 | 7 | 1 | 0 | 4 |
| 3 | 2 | 5 | 4 | 0 |
Distance matrix
| 0 | 1 | 2 | 3 | |
|---|---|---|---|---|
| 0 | 0 | 1 | 2 | 5 |
| 1 | 1 | 0 | 4 | 3 |
| 2 | 2 | 4 | 0 | 1 |
| 3 | 5 | 3 | 1 | 0 |
Optimal permutation:
| Facility pair | Flow | Assigned locations | Distance | Contribution |
|---|---|---|---|---|
| 7 | 1 | |||
| 5 | 1 | |||
| 4 | 2 | |||
| 3 | 3 | |||
| 2 | 4 | |||
| 1 | 5 |
The two highest-flow pairs (flow 7 and 5) are each assigned distance 1, while the lowest-flow pair (flow 1) absorbs the largest distance 5.
Compare: identity