Cheatsheet

Discrete Optimization

All topics on one page

4modules
12articles
108definitions
21formulas

01

Fundamentals of Discrete Optimization and Combinatorics

Introduction to discrete optimization, classical problems, and complexity theory

Introduction to Discrete Optimization: Problems, Models, Complexity

Why Is Discrete Optimization Everywhere? → Problem Scale → Classic Discrete Optimization Problems → Integer Linear Programming (ILP) → Complexity Theory: NP-Completeness → Complete Analysis: Knapsack Problem

Definitions

Traveling Salesman Problem (TSP)
Given $n$ cities with distances $d_{ij}$ between them. Find the shortest route visiting each city exactly once and returning to the start.
Knapsack Problem
$n$ items with values $c_i$ and weights $w_i$. The knapsack can hold $W$ kg. Choose a set of items with maximal total value.
Set Cover Problem
Given a universal set $U$ and a family of subsets $S_1,...,S_m$. Choose the minimal subfamily covering $U$. Applications: minimal number of fire stations to cover an entire city.
MAX-CUT
Graph $G=(V,E)$. Split $V$ into two sets $S$, $V \setminus S$, maximizing the number of edges between them. Applications: data clustering, VLSI layout.
Example (TSP as ILP)
$x_{ij} \in \{0,1\}$—use of edge $(i,j)$. Constraints: $\sum_j x_{ij} = 1$ (entering each city), $\sum_i x_{ij} = 1$ (exiting), $y_i - y_j + n x_{ij} \leq n-1$ for $i \neq j \neq 1$ (elimination of subroutes).
Class P
problems solvable in polynomial time $O(n^k)$. Examples: sorting $O(n \log n)$, shortest path in a graph $O(n^2)$, linear programming $O(n^{3.5})$.
Class NP
problems whose solution can be verified in polynomial time. Example: TSP—a given route can be checked in $O(n)$. But finding the optimum—we don't know how.
NP-complete problems
hardest in NP. Any NP problem can be polynomially reduced to any NP-complete problem. The first NP-complete problem: SAT (Cook, 1971).
What this means in practice
three strategies for NP-hard problems:
Data
$W = 10$ kg, 4 items: $(c_1,w_1) = (6,4)$, $(c_2,w_2) = (5,3)$, $(c_3,w_3) = (4,2)$, $(c_4,w_4) = (3,1)$.
Optimum
$\{1,2,3,4\}$ with $c=18$. But for $n = 50$ items—$2^{50} > 10^{15}$ options, enumeration is unrealistic.

FedEx delivers 15 million parcels per day. The route of each truck is a sequence of stops. How should the routes be assigned so the total mileage is minimized? This is a vehicle routing problem—a discrete optimization problem. Or: an airline must schedule flights, assigning crews to routes so as ...

It may seem that one could simply enumerate all options. But the scale makes this impossible. The traveling salesman problem (find the shortest route through n cities): number of possible routes = $(n−1)!/2$. For $n = 20$: ≈ 60 quintillion routes. At 1 billion operations per second, enumeration w...

The solution? Smart algorithms that find the optimum (or a good approximation) in reasonable time.

Traveling Salesman Problem (TSP): Given $n$ cities with distances $d_{ij}$ between them. Find the shortest route visiting each city exactly once and returning to the start.

Graph Theory in Optimization: Flows and Matchings

Graphs as Models of the Real World → Maximum Flow → Matchings in Bipartite Graphs → Minimum Spanning Tree (MST) → Shortest Paths

Definitions

Formulation
a directed network G = (V, E) with capacities c(e) > 0 on each edge. Source s, sink t. Find the maximum flow from s to t.
Ford-Fulkerson Theorem
max flow = min cut.
Ford-Fulkerson Algorithm
we search for an "augmenting path" in the residual network: a path from s to t where each edge has a residual capacity > 0. We increase the flow along the path. We repeat until there is no such path.
Complexity
O(E · f_max) for rational capacities. The Edmonds-Karp algorithm uses BFS to find the shortest path → O(V E²).
Full Example Analysis
network: s→a (c=4), s→b (c=3), a→t (c=3), a→b (c=2), b→t (c=4).
Bipartite graph
V = A ∪ B, edges only between A and B.
Hopcroft-Karp Algorithm
O(E√V). Searches for augmenting paths using BFS (finds all shortest augmenting paths simultaneously), then DFS to find the maximum matching of this length.
Hungarian Algorithm (assignment problem)
given a complete bipartite graph with weights wᵢⱼ (cost of assigning task i to executor j). Find the minimal assignment (= matching of minimal total weight). Complexity: O(n³).
MST problem
find a spanning tree with the minimal total weight of edges.
Kruskal’s Algorithm
O(E log E)
Prim’s Algorithm
O(E log V) with heap
Proof of optimality (cut property)
for any cut (S, V∖S), the minimal edge through the cut belongs to any MST.
Full analysis
graph with 4 vertices: a-b (4), a-c (3), b-c (2), b-d (5), c-d (1).
Applications
laying cables for a network with minimal cable length (telephone, electrical networks), data clustering (single-linkage), approximation algorithms for TSP.
Dijkstra's Algorithm
non-negative weights. O((V+E) log V) with binary heap. Idea: greedily expand the "front" of shortest paths from s.

Formulas

Formulation: a directed network G = (V, E) with capacities c(e) > 0 on each edge. Source s, sink t. Find the maximum flow from s to t.Cut (S, V∖S) with s ∈ S, t ∈ V∖S: capacity of the cut = sum of capacities of edges from S to V∖S. The minimal cut is the "bottleneck" of the network.Full Example Analysis: network: s→a (c=4), s→b (c=3), a→t (c=3), a→b (c=2), b→t (c=4).Bipartite graph: V = A ∪ B, edges only between A and B.Spanning tree of a graph G = (V, E): a connected acyclic subgraph including all vertices. Number of edges = |V| − 1.
  • ·Assigning teachers to classes in a school
  • ·Distribution of orders among taxi drivers (Yandex.Taxi — a real-time matching problem!)
  • ·Medicine: compatibility of kidney donors and recipients
  • ·Recommendation systems: matching users with content

A graph is a mathematical abstraction of a network: vertices (nodes) and edges (connections). The Internet is a graph of routers. A social network is a graph of users. A transportation network is a graph of cities and roads. Many discrete optimization problems are graph problems. Three classical ...

Formulation: a directed network G = (V, E) with capacities c(e) > 0 on each edge. Source s, sink t. Find the maximum flow from s to t.

Flow f: flow on edge (u,v) ≤ c(u,v), in each vertex (except s, t) the sum of incoming flows equals the sum of outgoing flows.

Cut (S, V∖S) with s ∈ S, t ∈ V∖S: capacity of the cut = sum of capacities of edges from S to V∖S. The minimal cut is the "bottleneck" of the network.

Linear Programming as the Foundation of ILP

The Bridge Between Continuous and Discrete → The Geometry of Linear Programming → LP Relaxation of ILP → Totally Unimodular Matrices → LP Duality for Approximation Algorithms → Full Analysis: Shortest Path Problem via LP → Simplex Method: Key Details → Interior Methods → LP in Machine Learning

Definitions

Standard form of LP
min $c^\top x$ subject to $Ax \leq b$, $x \geq 0$.
ILP
min $c^\top x$ subject to $Ax \leq b$, $x \in \{0,1\}^n$.
LP relaxation
min $c^\top x$ subject to $Ax \leq b$, $0 \leq x \leq 1$. (Drop integrality)
Example
knapsack problem with $W=5$, $n=3$: $(c_1, w_1)=(4,3)$, $(c_2, w_2)=(3,2)$, $(c_3, w_3)=(2,1)$.
Definition
a matrix $A$ is called totally unimodular (TU) if the determinant of every square submatrix is in $\{-1, 0, +1\}$.
Theorem (Hoffman-Kruskal)
if $A$ is a TU matrix and $b$ is integer, then the vertices of the polytope $\{x: Ax \leq b, x \geq 0\}$ are all integer. Thus, LP optimum = ILP optimum—you can solve the ILP via LP!
Corollary
the maximum matching problem, the maximum flow problem, and the shortest path problem—all can be solved by LP!
LP duality
for the problem (P): min $c^\top x$ subject to $Ax \geq b$, $x \geq 0$ the dual (D) is: max $b^\top y$ subject to $A^\top y \leq c$, $y \geq 0$.
Weak duality
any feasible $y$ gives $b^\top y \leq c^\top x$ for any feasible $x$. Corollary: $b^\top y$ is a lower bound on the optimum of (P).
Primal-Dual Method
simultaneously construct a feasible integer solution $\hat{x}$ and a feasible dual solution $\hat{y}$. Guarantee: $c^\top \hat{x} \leq \rho \cdot b^\top \hat{y} \leq \rho \cdot OPT \rightarrow \rho$-approximation.
Guarantee
$\ln n$-approximation ($\ln n$ is the maximum degree of a vertex in the cover hypergraph).
Graph
$V = \{1,2,3,4\}$, edges: $(1,2)=2$, $(1,3)=4$, $(2,3)=1$, $(2,4)=5$, $(3,4)=2$. Find the shortest path from 1 to 4.
Flow LP formulation
$x_{ij} \geq 0$—flow through edge $(i,j)$. Problem: min $\sum d_{ij} x_{ij}$ subject to flow-balance constraints (flow 1 from source, $-1$ at sink, 0 elsewhere).
Solution
simplex yields $x_{12}=1$, $x_{23}=1$, $x_{34}=1$ (path $1 \rightarrow 2 \rightarrow 3 \rightarrow 4$, cost = $2+1+2=5$). Solution is integer (network matrix is TU)!
Dual LP
vertex potentials: max $\pi_4-\pi_1$ subject to $\pi_j-\pi_i \leq d_{ij}$. Optimum: $\pi_1=0$, $\pi_2=2$, $\pi_3=3$, $\pi_4=5$. Dual optimum = 5 = primal ✓ (strong duality).

Formulas

Example: knapsack problem with $W=5$, $n=3$: $(c_1, w_1)=(4,3)$, $(c_2, w_2)=(3,2)$, $(c_3, w_3)=(2,1)$.Graph: $V = \{1,2,3,4\}$, edges: $(1,2)=2$, $(1,3)=4$, $(2,3)=1$, $(2,4)=5$, $(3,4)=2$. Find the shortest path from 1 to 4.
  • ·The incidence matrix of a bipartite graph (rows—vertices, columns—edges)
  • ·The “constraints” matrix of the maximum flow problem
  • ·The “schedule” matrix for problems with ordered intervals

Integer optimization problems are discrete by their very nature. Yet the key tool for solving them is linear programming, a continuous problem. The idea: “relax” the integer constraints to continuous ones, solve a much simpler problem, and use the result to find the integer optimum. This is “LP r...

The feasible set—the intersection of half-spaces—is a polytope (a convex polyhedron).

Key theorem: the optimal solution to an LP is always achieved at a vertex of the polytope (provided an optimum exists). A vertex is a point where $n$ constraints are “active” (hold as equalities).

Number of vertices: up to $C_{m+n}^n \approx m^n/n!$ (exponential). But in practice, the simplex method traverses only $O(m)$ vertices. Karmarkar’s method (1984): polynomial—$O(n^{3.5})$, moves “through the center” of the polytope.

02

Branch-and-Bound Methods

Branch-and-Bound, Branch-and-Cut, and their applications in MILP

Branch and Bound Method

The Principle of "Intelligent Enumeration" → Structure of the Algorithm → Branch and Bound Algorithm → Branching Strategies → Lower Bounds: LP and Lagrangian Relaxation → Full Analysis: Knapsack Problem via B&B → Performance in Practice → Search Heuristics in B&B → Parallelization → Applications

Definitions

Search tree
each node is a subproblem with additional constraints. The root is the original problem without any additional constraints.
Pruning rule
if LB(node) ≥ incumbent, this node is useless — we prune (cut off) it along with all descendants.
LP bound
solve the LP relaxation. Good bound, but computationally expensive.
Lagrangian relaxation
“soften” some constraints by adding them to the objective with penalties $\lambda$.
Task
$W=10$, items $(c,w)$: (6,4), (5,3), (4,2), (3,1).
Root node
LP relaxation. Greedy strategy by $c/w$ ratio: take 4 ($c=3$, $w=1$), 3 ($c=4$, $w=2$), 2 ($c=5$, $w=3$). Remaining 4 kg → take $6/4 = 1.5$ units of item 1: $x_1=1$, $x_2=1$, $x_3=1$, $x_4=1$, value = $3+4+5+6=18$. $LB = 18$ (integer!).
  • ·If the LP has no solution: prune (the problem is infeasible).
  • ·If LB ≥ incumbent: prune (not better than the current solution).
  • ·If the LP optimum is integer: update incumbent.
  • ·Down branch: add $x_i \leq \lfloor \alpha \rfloor$
  • ·Up branch: add $x_i \geq \lceil \alpha \rceil$
  • ·Most Fractional: select $x_i$ closest to 0.5 (the most “fractional”)
  • ·Strong Branching: solve LP relaxations of both branches for several candidates and select the best. Expensive, but leads to fewer nodes.
  • ·Pseudocost Branching: use the history of previous branchings to predict “usefulness”
  • ·Best-First Search: choose the node with the minimum lower bound. Quickly reaches the optimum, but requires a lot of memory.
  • ·Depth-First Search: go deep along one branch. Quickly finds feasible solutions (updates incumbent), saves memory.
  • ·Combination: depth-first until finding an incumbent, then best-first.
  • ·Variable selection heuristics for branching: pseudocost branching, strong branching, reliability branching
  • ·Node selection heuristics: best-first, depth-first, best-estimate
  • ·Presolve: simplifying the problem before search starts (fixing variables, aggregating constraints)
  • ·Simple heuristics for integer solution search: feasibility pump, RINS, local branching — allow one to quickly find an incumbent for aggressive pruning

A complete enumeration of all options is impossible for large n. But we can be smarter: if at some step we know that "nothing good will come further," we can cut off an entire branch of the search tree. The Branch and Bound (B&B) method systematizes this idea. This is the foundation of all indust...

Search tree: each node is a subproblem with additional constraints. The root is the original problem without any additional constraints.

Lower bound (LB) for a node: the minimally possible value of the objective function in this node. Usually this is the optimum of the LP relaxation of the subproblem.

Pruning rule: if LB(node) ≥ incumbent, this node is useless — we prune (cut off) it along with all descendants.

Cutting Planes and Branch-and-Cut

Idea: "Cutting off" fractional vertices → What is a cutting plane? → Gomory Cuts → Cuts for TSP: Subtour Inequalities → Branch-and-Cut: Algorithm → Types of Cuts in Modern Solvers → Full Analysis: Subtour Cuts for TSP → Types of Cutting Planes → Branch-and-Cut Workflow → Applications

Formulas

Gomory Cut: $\sum_j f_j s_j \geq f_0$. This is violated for the current solution ($s_j = 0 \rightarrow 0 \geq f_0 > 0$), but holds for integer ones.Data: 4 cities, distance matrix $d = [[0,2,9,10],[1,0,6,4],[15,7,0,8],[6,3,12,0]]$.Violated subtour inequality: For $S = \{1,2\}: x_{12} + x_{21} \leq 1$. Current value: $0.5 + 0.5 = 1$. Not strictly violated—look for another.
  • ·Find a violated inequality (separation problem)
  • ·Add it to the LP
  • ·Resolve the LP
  • ·Gomory cuts: general for any MILP
  • ·Cover cuts: specifically for knapsack problems (cover inequalities)
  • ·Clique cuts: for problems with clique constraints
  • ·Flow cuts: for problems with network structure
  • ·MIR cuts (Mixed Integer Rounding): generalization of Gomory
  • ·MIR cuts (Mixed Integer Rounding): Gomory generalization for mixed problems
  • ·Cover cuts: for knapsack problems—if a subset of items exceeds $W$, not all its elements can be taken
  • ·Clique cuts: for the conflict graph of variables—if in clique $K$ at most one variable can be 1, add $\sum x_i \leq 1$
  • ·Flow cover cuts: for network problems
  • ·Lift-and-project cuts (Balas, Ceresa, Cornuéjols): strong cuts from 0-1 constraints

LP relaxation may yield fractional optima (x₁ = 1.5, x₂ = 0.7...). Is it possible to add "smart" linear constraints that "cut off" these fractional solutions without removing any integer ones? This is precisely what cutting planes do. Instead of branching immediately, we add such planes to "pull"...

Definition: an inequality $a^\top x \leq b$ is called a *cutting plane* for MILP if: 1. It holds for all integer feasible points $x \in \{0,1\}^n$ 2. It is violated by the current LP optimum $x^*$ (fractional)

By adding such an inequality, we "cut off" the fractional $x^*$, but do not lose any integer solution. The new LP relaxation gives a better (higher) lower bound.

Ralph Gomory's idea (1958): take a row of the simplex tableau for a fractional variable and generate a cutting plane.

Dynamic Programming in Discrete Optimization

Principle of Optimality: Decomposing the Problem into Subproblems → Bellman Principle of Optimality → The Knapsack Problem: Classic DP → Shortest Paths: DP on a Graph → Longest Common Subsequence (LCS) → TSP via Held-Karp DP

Definitions

Formulation
the optimal solution contains optimal solutions to all its subproblems.
Statement
n items with values cᵢ and weights wᵢ, knapsack capacity W.
State
V[i][w] = maximum value using the first i items and capacity w.
Initial conditions
V[0][w] = 0 for all w (no items—no value).
Complexity
O(nW) in time and memory—pseudo-polynomial (not polynomial, since W can be enormous).
Bellman-Ford
d[v] = min_{(u,v)∈E} {d[u] + w(u,v)}.
Negative cycle detection
if d[n][v] < d[n−1][v] for some v — negative cycle!
Floyd-Warshall
all pairs shortest paths.
Problem
given strings s₁ and s₂. Find the longest common subsequence (not necessarily contiguous).
Applications
bioinformatics—DNA sequence alignment (the BLAST program). Systems programming—diff algorithm for comparing files in git. Data compression—LZW uses common substrings.
Recurrence
dp[S][v] = min_{u ∈ S{v}} {dp[S{v}][u] + d(u,v)}.
Answer
min_{v ≠ 1} {dp[{2,...,n}][v] + d(v,1)}.

Formulas

State: LCS[i][j] = length of LCS of strings s₁[1..i] and s₂[1..j].State: dp[S][v] = length of the shortest path starting at vertex 1, visiting all vertices from S ⊆ {2,...,n} exactly once, and ending at v ∈ S.Complexity: O(2ⁿ · n²)—exponential, but much better than O(n!) with brute-force. For n=20: 2²⁰ · 400 ≈ 4 · 10⁸—feasible.
i/w012345
0000000
1000444
2003447
3023567
  • ·Do not take item i: V[i][w] = V[i−1][w]
  • ·Take item i (if w ≥ wᵢ): V[i][w] = V[i−1][w−wᵢ] + cᵢ
  • ·V[i][w] = max(V[i−1][w], V[i−1][w−wᵢ] + cᵢ) if w ≥ wᵢ
  • ·s₁[i] = s₂[j]: LCS[i][j] = LCS[i−1][j−1] + 1 (take the match)
  • ·s₁[i] ≠ s₂[j]: LCS[i][j] = max(LCS[i−1][j], LCS[i][j−1]) (skip one character)

Dynamic Programming (DP) is one of the most elegant methods in discrete optimization. The idea is both simple and profound: the optimal solution to a large problem is constructed from optimal solutions to smaller subproblems. This is the Bellman principle of optimality. DP “remembers” the results...

Formulation: the optimal solution contains optimal solutions to all its subproblems.

When is the principle satisfied? When subproblems are independent (the solution to one does not interfere with another) and the structure of the optimal solution allows a recursive decomposition.

When is it NOT satisfied? When global constraints must be considered (for example, the traveling salesman problem—the subproblems are connected through the constraint “visit each city exactly once”). Nevertheless, TSP can also be solved by DP in O(2ⁿ n²)!

03

Approximation Algorithms

Approximation theory, greedy algorithms, and PTAS

Theory of Approximation: Guarantees and Boundaries

A Good Solution Instead of a Perfect One → Approximation Ratio → Vertex Cover: 2-Approximation → APX-hardness and Approximation Barriers → Bin Packing: Algorithm Analysis → Full Analysis: Metric Facility Location Problem → Classification by Guarantees → Lower Bounds of Approximability → Applications

Definitions

Vertex Cover problem
graph $G = (V, E)$. Find a minimal cardinality set of vertices $C \subseteq V$ such that every edge $(u,v)$ has at least one endpoint in $C$.
Proof of 2-approximation
$M$ is a matching (edges in $M$ have no common vertices). Therefore, $|M| \leq OPT$ (the optimum must cover all edges in $M$ $\rightarrow$ needs $\geq |M|$ vertices). $|C| = 2|M| \leq 2 \cdot OPT$. ✓
Example
$K_4$ (complete graph with 4 vertices). $OPT = 2$ (do any 2 vertices cover all 6 edges? No: 2 vertices cover 5 edges. $OPT = 3$). The algorithm picks 2 edges $\rightarrow$ 4 vertices. Approximation $= 4/3 < 2$. ✓
APX-hard problems
there is no PTAS (Polynomial-Time Approximation Scheme) if $P \neq NP$.
Max-3-SAT
APX-hard. Best known approximation: $7/8$ (randomized—assign each variable randomly). Impossible to do better if $P \neq NP$ (Håstad 2001).
Problem
$n$ items with sizes $s_i \in (0,1]$. Minimal number of unit bins to fit all items.
First-Fit (FF)
for each item, place in first bin that fits. If none—open new bin. Approximation: $\leq \frac{17}{10} OPT + 2$ — not very good.
First-Fit Decreasing (FFD)
sort items in decreasing order, then apply FF.
Theorem (Johnson, 1974)
$FFD(I) \leq \frac{11}{9} OPT(I) + 4$.
How it is proven
analyze how much "space" is wasted in each bin. When sorted in decreasing order, losses are minimized.
FPTAS for Bin Packing
if sizes are known in advance, there exists a $(1+\epsilon)$-approximation in $O(n \log n + f(1/\epsilon))$ — Fernandez de la Vega & Lueker (1981). Split items into "large" ($s_i > \epsilon$) and "small" ($s_i \leq \epsilon$), process differently.
$k$-Median problem
given $n$ clients and $n$ "warehouse" points, metric $d$. Choose $k$ warehouses to minimize the sum of distances from clients to nearest warehouse.
Guarantee
in local optimum, the algorithm gives $\leq (3+\epsilon) \cdot OPT$. Proof: amortized analysis of swaps. Application: optimal server placement, regional center distribution.
  • ·$\rho = 1$: exact algorithm. Exists only for P-problems.
  • ·$\rho = 2$: solution no more than twice as bad as optimum.
  • ·$\rho = O(\log n)$: logarithmic approximation (characteristic for Set Cover).
  • ·Select any uncovered edge $(u,v)$
  • ·Add both endpoints to $C$: $C = C \cup \{u,v\}$
  • ·Add edge to $M$: $M = M \cup \{(u,v)\}$
  • ·Vertex Cover cannot be approximated better than $(2-\epsilon)$ for any $\epsilon > 0$
  • ·MAX-CUT cannot be approximated better than $0.878$
  • ·If the swap decreases cost—make the swap
  • ·Constant approximation ($\rho$): $ALG \leq \rho \cdot OPT$ for some fixed $\rho$. For example, Vertex Cover—2-approximation (Bar-Yehuda, 1981).
  • ·Logarithmic ($O(\log n)$): Set Cover—$\ln n$-approximation via greedy (Johansson, Lovász, Chvátal).
  • ·PTAS (Polynomial-Time Approximation Scheme): for any $\epsilon > 0$ there exists an algorithm with guarantee $(1+\epsilon)$, polynomial in $n$ (but possibly exponential in $1/\epsilon$).
  • ·FPTAS (Fully PTAS): polynomial in both $n$ and $1/\epsilon$. Exists for knapsack, does not exist for TSP (if $P \neq NP$).
  • ·MAX-3SAT: cannot approximate better than $7/8$ (Håstad, 1997)
  • ·Vertex Cover: not better than $1.36$ (Dinur-Safra)
  • ·Set Cover: not better than $(1-\epsilon)\ln n$ (Feige, Moskovitz)

If a problem is NP-hard, we cannot (presumably) find an optimal solution in polynomial time. But often we do not need perfect precision—"good enough" is sufficient. Approximation algorithms find solutions with guaranteed quality: no worse than $\rho$ times the optimum. For $\rho = 1.5$ this means...

An algorithm $A$ is called $\rho$-approximation ($\rho \geq 1$), if for any input $I$:

For minimization problems: $A(I) \leq \rho \cdot OPT(I)$. For maximization: $A(I) \geq OPT(I)/\rho$.

Vertex Cover problem: graph $G = (V, E)$. Find a minimal cardinality set of vertices $C \subseteq V$ such that every edge $(u,v)$ has at least one endpoint in $C$.

Greedy Algorithms and Matroids

When Is Greed Optimal? → Greedy Algorithm for MST: Proof → Matroid: Definition → Examples of Matroids → Rado-Edmonds Theorem → Corollaries → Intersection of Matroids → Full Example: Greedy Algorithm for Weighted Matroid

Definitions

Kruskal’s Algorithm
sort the edges by weight. Greedily add the minimum edge that does not create a cycle.
Cut Lemma
for any cut (S, V∖S), the minimum edge crossing the cut is included in the MST.
Proof
let $e^*$ be the minimum edge crossing the cut, and let $T$ be an MST not containing $e^*$. Add $e^*$ to $T$ → a cycle is formed, which crosses the cut at least in one other edge $e'$. Since $e^*$ is minimal in the cut: $w(e^*) \leq w(e')$. Replac...
Basis of a matroid
a maximal independent set. By I3 all bases have the same size (the rank of the matroid).
Linear matroid
$E$ = columns of matrix $A$ over field $F$, $I$ = linearly independent subsets of columns. The rank of the matroid equals the rank of the matrix.
Partition matroid
$E$ is partitioned into groups $E_1, ..., E_k$. $I$ = sets with no more than 1 element from each $E_i$. Used to represent schedules.
Theorem
the greedy algorithm is optimal for the maximum-weight independent set problem if and only if $(E, I)$ is a matroid.
Greedy algorithm
sort the elements in order of decreasing weight. Add the next element if after adding the set remains independent.
MST
graphic matroid → Kruskal’s algorithm is optimal ✓.
Assignment problem
bipartite graph $G$, need to pick $k$ edges, none incident to the same vertex (= matching of size $k$). This is the intersection of two partition matroids! → polynomially solvable (Edmonds’ algorithm).
Huffman’s problem
optimal prefix code for compression. Huffman’s greedy algorithm is optimal — the structure is matroidal.
Problem
find the largest independent set $I \in I_1 \cap I_2$ (intersection of two matroids).
Algorithm
$O(r^2 \cdot T_{oracle})$, where $r$ is the rank, $T_{oracle}$ is the time to check independence. Polynomial!
Intersection of 3 matroids
NP-hard. This is the boundary of polynomial-time solvability.

Formulas

Matroid $M = (E, I)$: $E$ — the “elements”, $I \subseteq 2^E$ — the “independent” sets. Axioms:Graphic matroid (cycle matroid): $E$ = edges of graph $G$, $I$ = acyclic subgraphs (forests). Basis = spanning tree (MST!).Uniform matroid $U_{k n}$: $I$ = all subsets of $E$ of size $\leq k$. This is a “$k$-sparse” matroid.
  • ·Maximum matching in a bipartite graph = intersection of two partition matroids
  • ·Coloring a bipartite graph = intersection of two matroids (color assignment)

A greedy algorithm makes the locally best choice at each step, never revisiting past decisions. Simple and fast — but not always optimal. The greedy algorithm for the knapsack problem does not produce an optimum. Kruskal’s greedy algorithm for MST — produces an optimum. Why? The answer is the mat...

Kruskal’s Algorithm: sort the edges by weight. Greedily add the minimum edge that does not create a cycle.

Cut Lemma: for any cut (S, V∖S), the minimum edge crossing the cut is included in the MST.

Proof: let $e^*$ be the minimum edge crossing the cut, and let $T$ be an MST not containing $e^*$. Add $e^*$ to $T$ → a cycle is formed, which crosses the cut at least in one other edge $e'$. Since $e^*$ is minimal in the cut: $w(e^*) \leq w(e')$. Replace $e'$ with $e^*$ in $T$ → new tree $T'$, w...

PTAS and FPTAS: Precise Approximation Schemes

A Family of Algorithms Instead of One → PTAS: Definition and Examples → FPTAS: Polynomial in $1/\varepsilon$ → Why Does TSP on Arbitrary Metrics Not Have a PTAS? → Arora’s Algorithm for Euclidean TSP → PTAS for Scheduling Problems → Idea of PTAS on the Knapsack Example → Metric TSP and Christofides' Algorithm → Impossibility for General TSP → Applications

Formulas

Knapsack Problem—FPTAS: Scaling gives time $O(n^3/\varepsilon) = O(n^2 \cdot n/\varepsilon)$—polynomial in $n$ and $1/\varepsilon$!
  • ·For any $\varepsilon > 0$, algorithm $A_\varepsilon$ finds a $(1+\varepsilon)$-approximation
  • ·The running time is polynomial in $n$ (the input size) for fixed $\varepsilon$

A conventional approximation algorithm provides a fixed guarantee: for example, a 2-approximation. But what if we need more precision—for instance, a 1.01-approximation? PTAS (Polynomial-Time Approximation Scheme) is not a single algorithm, but an entire family of algorithms $A_\varepsilon$, para...

Important: the dependence on $\varepsilon$ can be arbitrary. For instance, $O(n^{1/\varepsilon})$ is a PTAS, but $O(2^{1/\varepsilon}\cdot n)$ is also a PTAS.

1. Find the maximum value $c_{\max} = \max c_i$ 2. Scale: $\tilde{c}_i = \left\lfloor c_i \cdot n/(\varepsilon \cdot c_{\max}) \right\rfloor$ (round down) 3. Solve DP with scaled values: time $O\left(n\cdot \sum \tilde{c}_i\right) = O\left(n\cdot n^2/\varepsilon\right) = O(n^3/\varepsilon)$ 4. Re...

Theorem: This is a $(1+\varepsilon)$-approximation. Proof: losses from scaling are $\leq \varepsilon \cdot OPT/n$ per item, total $\leq \varepsilon \cdot OPT$.

04

Metaheuristics

Simulated annealing, genetic algorithms, and local search

Local Search and Its Improvements

Idea: Movement Across the Solution Landscape → Basic Local Search → 2-opt for TSP: The Classic → Variable Neighborhood Search (VNS) → Tabu Search → Detailed Example: 2-opt for 5-city TSP

Definitions

Neighborhood selection is a key issue
a small neighborhood → fast iteration but weak improvement. Large → slow but high-quality improvement.
2-opt neighborhood
remove 2 edges from the tour and rebuild. For the route a→b→c→d→e→a: remove (b,c) and (d,e), add (b,d) and (c,e)—restructuring.
Practice
2-opt often gives tours that are 3-5% off the optimum. For a 1000-city problem works in seconds.
3-opt
remove 3 edges—O(n³) operations. Better quality, more expensive.
Lin-Kernighan (LK)
adaptive k-opt with "smart" candidate selection. Best-known TSP heuristic. Gives tours within 0.5-1% from optimum. Used in the LKH (Lin-Kernighan-Helsgott) program—industry standard.
Idea
if local search gets stuck in $N_1$-optimum, "jump" randomly into the $N_2$ neighborhood and descend again. If a local optimum there—$N_3$ and so on.
Motivation
basic LS may "oscillate" between several solutions. Tabu Search prohibits recently visited solutions.
Aspiration criterion
allow tabu transition if it improves BestSolution. This lets us "accept" a good solution even if it is forbidden.
Cities
A(0,0), B(2,0), C(2,2), D(0,2), E(1,1). Initial tour: A→B→C→D→E→A.
Result
the initial tour A→B→C→D→E→A is 2-opt optimal for these cities.
  • ·Initial solution s (random or greedy)
  • ·Neighborhood function N(s) = set of "neighboring" solutions
  • ·Improvement criterion (first improvement or best improvement)
  • ·s ← s' (first improvement: take the first better one; best improvement: the best among all)
  • ·Compute the improvement from replacing two edges
  • ·If improvement > 0: do the swap, restart
  • ·$s' = \text{random\_neighbor}(N_i(s))$
  • ·$s'' = \text{local\_search}(s')$
  • ·If $f(s'') < f(s)$: $s = s''$, $i = 1$ (found an improvement—start over)
  • ·Else: $i++$ (move to a wider neighborhood)
  • ·Find the best solution $s' \in N(s) \setminus \text{TabuList}$
  • ·If $s'$ is absent → allow Tabu (aspiration)
  • ·$s \leftarrow s'$
  • ·If $f(s) < f(\text{BestSolution})$: BestSolution = $s$
  • ·Add $s$ to TabuList (remove oldest if the list is full)
  • ·Length of TabuList: usually $\sqrt{n}$ or $n$. Too small—oscillation. Too big—search too restricted.
  • ·What to store: the solution itself (memory intensive) or just the "move" (variable shift)

Imagine the "landscape" of the solution space: each solution is a point, its "height" is the value of the objective function. We want to find a deep valley (minimum). Local search is a "descent across the landscape": we start from an arbitrary point and iteratively move to a "neighboring" point w...

Algorithm: 1. Current solution s = s₀ 2. While N(s) contains a better solution s': 3. Return s (local optimum)

Neighborhood selection is a key issue: a small neighborhood → fast iteration but weak improvement. Large → slow but high-quality improvement.

2-opt neighborhood: remove 2 edges from the tour and rebuild. For the route a→b→c→d→e→a: remove (b,c) and (d,e), add (b,d) and (c,e)—restructuring.

Simulated Annealing and Its Applications

Physical Analogy: Slow Cooling → Simulated Annealing Algorithm → Theoretical Guarantees → Tuning SA Parameters → SA for VLSI Layout → SA vs. Other Methods → Simulated Annealing Nuances → Theoretical Convergence → Parallel Variants → Hybrid Methods

Definitions

Probability of accepting worsening
$\exp(-\Delta/T)$. As $T \to \infty$: probability $\to 1$ (accept any step, random walk). As $T \to 0$: probability $\to 0$ (accept only improvements, standard local search).
Key property
at high $T$ the algorithm “explores” the solution space, at low $T$ it “exploits” the good solutions found.
Geman-Geman Theorem (1984)
if $T(k) = C/\log(1+k)$ (logarithmic cooling), SA converges to the global optimum with probability 1.
Practical convergence
SA finds good (but not guaranteed optimal) solutions in reasonable time. For TSP: tours within 1-2% of the optimum in seconds.
Initial temperature $T_0$
chosen so that the initial “acceptance rate” is about 80-90%. For example, you can run 1000 random steps, compute the average worsening $\bar{\Delta}$, and choose $T_0$ so that $\exp(-\bar{\Delta}/T_0) = 0.8$.
Cooling rate $\alpha$
a trade-off between quality and time. $\alpha = 0.99$ means a long run, good quality. $\alpha = 0.9$ means quick, lower quality.
Number of iterations $L_k$ at each temperature
often $L_k = n$ (problem size). More iterations at one temperature → better “equilibrium”.
Stopping criterion
$T < T_{min}$, or no improvements in the last $k \cdot L_k$ iterations.
Task
$n$ components on a chip, minimize the total length of connecting wires. This is called the Placement Problem in VLSI (Very Large Scale Integration).
Historical significance
SA was first applied to VLSI Layout—IBM, 1983 (Kirkpatrick, Gelatt, Vecchi). The Science paper is one of the most cited in computer science. SA reduced wire length by 10-20% compared to deterministic methods.
Modern VLSI tools
SA remains fundamental, but with dozens of improvements: adaptive temperature, parallel runs, “restart” on stagnation.
Conclusion
SA is suitable for problems with a large number of local optima where implementation simplicity is important. Tabu—for structured problems with pronounced “memory”. For TSP, the best is LK heuristic.

Formulas

Geman-Geman Theorem (1984): if $T(k) = C/\log(1+k)$ (logarithmic cooling), SA converges to the global optimum with probability 1.Number of iterations $L_k$ at each temperature: often $L_k = n$ (problem size). More iterations at one temperature → better “equilibrium”.
MethodGuaranteeSpeedSimplicityQuality
Exact B&BOptimumSlowComplexExcellent
GreedyNoneFastSimplePoor
Local SearchNoneFastSimpleAverage
SANone (practical)MediumSimpleGood
TabuNoneMediumComplexGood
GANoneSlowMediumGood
  • ·$T_0$ — initial temperature (high)
  • ·$\alpha \in (0,1)$ — cooling rate (usually 0.9–0.99)
  • ·$L_k$ — number of iterations at temperature $T_k$
  • ·$s' = random\_neighbor(s)$ (random neighbor)
  • ·$\Delta = f(s') - f(s)$ (change in objective)
  • ·If $\Delta < 0$ (improvement): $s = s'$ (always accept)
  • ·Otherwise: $s = s'$ with probability $\exp(-\Delta/T)$
  • ·Solution: coordinates of each component on the grid
  • ·Neighborhood: swap two components or move one component
  • ·Cost function: total length of the Steiner tree for each net
  • ·Initial temperature $T_0$: should be high enough so that nearly all moves are initially accepted (≈ 80% acceptance rate)
  • ·Cooling schedule: classical geometric $T_k = \alpha \cdot T_{k-1}$ with $\alpha \in [0.85, 0.99]$; adaptive schedules (Lundy-Mees) decrease $T$ depending on progress
  • ·Neighborhood: must allow “reachability” of any point. Too small moves mean slow convergence, too large means loss of local structure
  • ·Parallel tempering (replica exchange): several copies of SA with different temperatures exchange states. High-temperature copies explore, low-temperature ones exploit.
  • ·Population SA: multi-agent version with information exchange
  • ·GPU implementations: thousands of parallel SA runs with different starting points
  • ·SA + Local Search: after SA finds a good solution—local optimization for final polishing
  • ·Memetic algorithms: SA inside genetic algorithms as mutation
  • ·Variable Neighborhood Search (VNS): SA with changing neighborhood upon stagnation
  • ·VLSI placement: placing millions of transistors on a chip. SA was standard in the 1990s, still used in TimberWolf, Cadence
  • ·TSP: on problems up to 100,000 cities, SA gives solutions within 2-3% of the optimum
  • ·Aircraft and crew scheduling: Air France, Lufthansa use SA for dynamic rescheduling in disruptions
  • ·Molecular design: protein folding prediction, drug design—SA on the space of conformations
  • ·Financial portfolios: optimization with discrete constraints (number of shares, sectors, risk categories)

In metallurgy, “annealing” means heating a metal to a high temperature and then cooling it slowly. At high temperature, atoms have plenty of energy and can "jump" over energy barriers, finding a better crystalline structure. With slow cooling, they settle in the global energy minimum (the ideal c...

The idea of the metaheuristic Simulated Annealing (SA) is to imitate this process! The algorithm accepts "worsening" steps with decreasing probability—this allows “escaping” from local optima and eventually finding the global one.

Algorithm: 1. $s = s_0$ (initial solution), $T = T_0$, $BestS = s_0$ 2. While $T > T_{min}$: a. Repeat $L_k$ times: b. $T \leftarrow \alpha \cdot T$ 3. Return $BestS$

Probability of accepting worsening: $\exp(-\Delta/T)$. As $T \to \infty$: probability $\to 1$ (accept any step, random walk). As $T \to 0$: probability $\to 0$ (accept only improvements, standard local search).

Genetic Algorithms and Evolutionary Optimization

Evolution as an Optimization Algorithm → Structure of a Genetic Algorithm → Operators for TSP → Theoretical Foundations: Schema Theorem → Memetic Algorithms (MA) → NSGA-II: Multi-Criteria Optimization

Formulas

Problem: chromosome = permutation of cities π = (π₁, π₂, ..., πₙ). Crossover must produce valid permutations (each city appears exactly once).Example: P1 = (1,2,3,4,5), P2 = (3,4,1,5,2), segment [2,4].
  • ·*Roulette wheel selection:* P(select s) = fitness(s) / Σ fitness. Analogue of “spinning a roulette wheel”
  • ·*Tournament selection:* randomly select k individuals, the best wins. Parameter k reflects “selection pressure”
  • ·*Swap:* randomly swap two cities
  • ·*Insertion:* extract one city and insert it into another place
  • ·*Inversion (2-opt):* reverse a random subroute
  • ·Pure GA: searches space globally, but solutions are not fully “refined”
  • ·Pure LS: gets stuck in local optima
  • ·MA: global search + local “polishing”
  • ·Non-domination rank: solutions are ranked by “domination level”: rank 1 = not dominated by anyone, rank 2 = dominated only by rank 1, etc.
  • ·Crowding distance: distance to neighbors on the front. Preference is given to “less crowded” zones—diversity.

Natural evolution has solved an optimization problem of colossal complexity: creating beings capable of surviving in a changing environment. The mechanism: random mutations, gene recombination (crossover), natural selection. Genetic Algorithms (GA) imitate this process for optimization purposes. ...

Chromosome (individual): the encoding of a solution as a vector. For the TSP— a permutation of cities. For the knapsack problem—a binary string.

Fitness: value of the objective function. In GA, we usually work with maximization, so: fitness = −cost for minimization problems.

Problem: chromosome = permutation of cities π = (π₁, π₂, ..., πₙ). Crossover must produce valid permutations (each city appears exactly once).