Skip to content

[Rule] SteinerTree to ILP #123

@zazabap

Description

@zazabap

Source: SteinerTree
Target: ILP
Motivation: Enables solving Steiner Tree via ILP solvers; the flow-based formulation is the standard in network optimization and VLSI routing tools.
Reference: Wong, 1984; Koch & Martin, 1998

Reduction Algorithm

Notation:

  • Source: undirected weighted graph $G = (V, E, w)$, terminals $T \subseteq V$, $n = |V|$, $m = |E|$, $|T| = k$
  • Target: ILP with binary and continuous variables

Step 1 — Choose a root: Pick any terminal $r \in T$ as the root. Let $T' = T \setminus {r}$ ($k-1$ non-root terminals).

Step 2 — Variables:

  • Edge selection: $y_e \in {0, 1}$ for each edge $e \in E$ (include in tree?)
  • Flow: $f^t_{uv} \in [0, 1]$ for each directed arc $(u,v)$ (both directions of each edge) and each non-root terminal $t \in T'$. Represents one unit of flow from $r$ to $t$.

Step 3 — Constraints:

  1. Flow conservation (for each $t \in T'$ and each vertex $v \in V$):

$$\sum_{u:(u,v) \in A} f^t_{uv} - \sum_{u:(v,u) \in A} f^t_{vu} = \begin{cases} -1 & \text{if } v = r \ +1 & \text{if } v = t \ 0 & \text{otherwise} \end{cases}$$

  1. Capacity linking (for each directed arc $(u,v)$ and each $t \in T'$):

$$f^t_{uv} \leq y_e \quad \text{where } e = {u,v}$$

Objective: minimize $\sum_{e \in E} w_e \cdot y_e$

Solution extraction: Select edges with $y_e = 1$; these form the Steiner tree.

Size Overhead

Target metric (code name) Polynomial (using symbols above)
num_vars $m + 2m(k-1)$ (edge selection + flow variables)
num_constraints $n(k-1) + 2m(k-1)$ (conservation + capacity)

Validation Method

Closed-loop testing: solve SteinerTree by brute-force (enumerate edge subsets), solve the reduced ILP, and verify both give the same optimal cost.

Example

Source: 5 vertices, 7 edges, terminals $T = {0, 2, 4}$.

Edge index Edge Weight
$e_0$ $(0,1)$ 2
$e_1$ $(1,2)$ 2
$e_2$ $(1,3)$ 1
$e_3$ $(3,4)$ 1
$e_4$ $(0,3)$ 5
$e_5$ $(3,2)$ 5
$e_6$ $(2,4)$ 6

ILP construction: root $r = 0$, non-root terminals $T' = {2, 4}$ ($k - 1 = 2$ commodities).

Variables (35 total):

7 edge-selection variables:

$$y_0, y_1, y_2, y_3, y_4, y_5, y_6 \in {0, 1}$$

14 flow variables for commodity $t = 2$:

$$f^2_{01},; f^2_{10},; f^2_{12},; f^2_{21},; f^2_{13},; f^2_{31},; f^2_{34},; f^2_{43},; f^2_{03},; f^2_{30},; f^2_{32},; f^2_{23},; f^2_{24},; f^2_{42} \in [0,1]$$

14 flow variables for commodity $t = 4$:

$$f^4_{01},; f^4_{10},; f^4_{12},; f^4_{21},; f^4_{13},; f^4_{31},; f^4_{34},; f^4_{43},; f^4_{03},; f^4_{30},; f^4_{32},; f^4_{23},; f^4_{24},; f^4_{42} \in [0,1]$$

Constraints (38 total):

Flow conservation for $t = 2$ (5 constraints):

Vertex RHS Constraint
$v=0$ (root) $-1$ $f^2_{10} + f^2_{30} - f^2_{01} - f^2_{03} = -1$
$v=1$ $0$ $f^2_{01} + f^2_{21} + f^2_{31} - f^2_{10} - f^2_{12} - f^2_{13} = 0$
$v=2$ (sink) $+1$ $f^2_{12} + f^2_{32} + f^2_{42} - f^2_{21} - f^2_{23} - f^2_{24} = 1$
$v=3$ $0$ $f^2_{13} + f^2_{03} + f^2_{23} + f^2_{43} - f^2_{31} - f^2_{30} - f^2_{32} - f^2_{34} = 0$
$v=4$ $0$ $f^2_{34} + f^2_{24} - f^2_{43} - f^2_{42} = 0$

Flow conservation for $t = 4$ (5 constraints):

Vertex RHS Constraint
$v=0$ (root) $-1$ $f^4_{10} + f^4_{30} - f^4_{01} - f^4_{03} = -1$
$v=1$ $0$ $f^4_{01} + f^4_{21} + f^4_{31} - f^4_{10} - f^4_{12} - f^4_{13} = 0$
$v=2$ $0$ $f^4_{12} + f^4_{32} + f^4_{42} - f^4_{21} - f^4_{23} - f^4_{24} = 0$
$v=3$ $0$ $f^4_{13} + f^4_{03} + f^4_{23} + f^4_{43} - f^4_{31} - f^4_{30} - f^4_{32} - f^4_{34} = 0$
$v=4$ (sink) $+1$ $f^4_{34} + f^4_{24} - f^4_{43} - f^4_{42} = 1$

Capacity linking (28 constraints, 4 per edge):

Edge Constraints
$e_0 = (0,1)$ $f^2_{01} \leq y_0$, $f^2_{10} \leq y_0$, $f^4_{01} \leq y_0$, $f^4_{10} \leq y_0$
$e_1 = (1,2)$ $f^2_{12} \leq y_1$, $f^2_{21} \leq y_1$, $f^4_{12} \leq y_1$, $f^4_{21} \leq y_1$
$e_2 = (1,3)$ $f^2_{13} \leq y_2$, $f^2_{31} \leq y_2$, $f^4_{13} \leq y_2$, $f^4_{31} \leq y_2$
$e_3 = (3,4)$ $f^2_{34} \leq y_3$, $f^2_{43} \leq y_3$, $f^4_{34} \leq y_3$, $f^4_{43} \leq y_3$
$e_4 = (0,3)$ $f^2_{03} \leq y_4$, $f^2_{30} \leq y_4$, $f^4_{03} \leq y_4$, $f^4_{30} \leq y_4$
$e_5 = (3,2)$ $f^2_{32} \leq y_5$, $f^2_{23} \leq y_5$, $f^4_{32} \leq y_5$, $f^4_{23} \leq y_5$
$e_6 = (2,4)$ $f^2_{24} \leq y_6$, $f^2_{42} \leq y_6$, $f^4_{24} \leq y_6$, $f^4_{42} \leq y_6$

Objective: minimize $2y_0 + 2y_1 + y_2 + y_3 + 5y_4 + 5y_5 + 6y_6$

Optimal ILP solution: $y_0 = y_1 = y_2 = y_3 = 1$, $y_4 = y_5 = y_6 = 0$, objective $= 2 + 2 + 1 + 1 = 6$.

Flow for terminal 2 ($0 \to 1 \to 2$): $f^2_{01} = 1, f^2_{12} = 1$, all others $0$.
Flow for terminal 4 ($0 \to 1 \to 3 \to 4$): $f^4_{01} = 1, f^4_{13} = 1, f^4_{34} = 1$, all others $0$.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoodAn issue passed all checks.ruleA new reduction rule to be added.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions