Yesterday (Lec 27): We proved CLIQUE and Vertex Cover are NP-complete via reductions from 3-SAT.
Consequence: Unless P = NP, no polynomial-time algorithm solves any of these optimally.
So what do we do when we need to solve NP-hard problems in practice?
Three strategies when faced with an NP-hard problem:
Exact
Branch-and-bound, ILP solvers
Optimal, but exponential worst-case
Heuristics
Simulated annealing, local search
Fast and empirical, but no provable guarantee
Approximation
Polynomial-time with worst-case guarantee
Suboptimal, but provably close to OPT
Today’s focus: Approximation algorithms — provable bounds in polynomial time.
An algorithm is an \alpha-approximation if for every instance I: \text{cost}(\text{alg}(I)) \le \alpha \cdot \text{OPT}(I) \quad (\alpha \ge 1 \text{ for minimization})
\alpha is the approximation factor — how far from optimal we can be.
Example — Vertex Cover via Matching (Lec 26): Pick any edge, add both endpoints, remove incident edges, repeat.
|\text{Alg}| = 2 \cdot |M| \le 2 \cdot |\text{OPT}| \quad\Rightarrow\quad \text{2-approximation}
A linear program (LP) optimizes a linear objective subject to linear constraints.
Standard form:
\begin{aligned} \text{maximize} \quad & c^T x \\ \text{subject to} \quad & Ax \le b \\ & x \ge 0 \end{aligned}
where x \in \mathbb{R}^n, c \in \mathbb{R}^n, A \in \mathbb{R}^{m \times n}, b \in \mathbb{R}^m.
Key fact: LPs can be solved in polynomial time (ellipsoid method, interior-point methods).
In 2D, constraints are half-planes. The feasible region is a convex polygon.
The optimal solution lies at a vertex (corner) of this polygon.
In higher dimensions: Feasible region is a convex polytope. Optimum at a vertex — always.
Question
Why must the optimum always lie at a vertex, not in the interior?
Answer: The objective is linear — if you move from interior toward any direction that improves it, you keep improving until you hit a constraint. The best point is always at an extreme point.
A factory produces two products P_1, P_2:
| Product | Profit/unit | Machine time | Labor time |
|---|---|---|---|
| P_1 | 40 | 2 hrs | 1 hr |
| P_2 | 30 | 1 hr | 2 hrs |
Available: 100 machine hours, 80 labor hours.
LP Formulation: \begin{aligned} \text{maximize} \quad & 40x_1 + 30x_2 \\ \text{subject to} \quad & 2x_1 + x_2 \le 100 \\ & x_1 + 2x_2 \le 80 \\ & x_1, x_2 \ge 0 \end{aligned}
An Integer Program (IP) is an LP with integrality constraints:
\begin{aligned} \text{minimize} \quad & c^T x \\ \text{subject to} \quad & Ax \le b \\ & x \in \{0,1\}^n \quad (\text{or } \mathbb{Z}^n) \end{aligned}
Critical fact: IP is NP-hard. Adding integrality makes optimization exponentially harder.
Many NP-hard problems are naturally formulated as IPs.
Idea: Take an IP and “relax” the integrality constraints.
\begin{aligned} \text{IP:} \quad & \min c^T x, \; Ax \le b, \; x \in \{0,1\}^n \\ \text{LP Relaxation:} \quad & \min c^T x, \; Ax \le b, \; 0 \le x \le 1 \end{aligned}
Why this helps:
The general approach for LP-based approximation:
Step 1: Formulate the problem as an IP.
Step 2: Relax to an LP by dropping integrality.
Step 3: Solve the LP to get an optimal fractional solution x^*.
Step 4: Round x^* to an integer solution \tilde{x} and prove feasibility + approximation ratio.
Recall Vertex Cover: given graph G=(V,E), pick the minimum set of vertices touching every edge.
IP Formulation: \begin{aligned} \min \quad & \sum_{v \in V} x_v \\ \text{s.t.} \quad & x_u + x_v \ge 1 \quad \forall (u,v) \in E \\ & x_v \in \{0,1\} \end{aligned}
x_v = 1 means “vertex v is in the cover.” Constraint: for each edge, at least one endpoint is chosen.
Drop integrality — allow fractional values:
\begin{aligned} \min \quad & \sum_{v \in V} x_v \\ \text{s.t.} \quad & x_u + x_v \ge 1 \quad \forall (u,v) \in E \\ & 0 \le x_v \le 1 \end{aligned}
This is now a linear program — solvable in polynomial time.
Observation: The optimal LP value is a lower bound on the optimal IP value: OPT_{LP} \le OPT_{IP}
Because we’ve relaxed constraints — the feasible set is larger.
We solve the LP and get fractional values x_v^* \in [0,1].
Rounding rule: Set \tilde{x}_v = 1 if x_v^* \ge \frac{1}{2}, else \tilde{x}_v = 0.
Feasibility: For any edge (u,v), x_u^* + x_v^* \ge 1. So at least one has x^* \ge \frac{1}{2}. Edge is covered. ✓
Approximation guarantee: |\tilde{x}| = \sum_v \tilde{x}_v \le 2 \sum_v x_v^* = 2 \cdot OPT_{LP} \le 2 \cdot OPT_{IP}
Thus we get a 2-approximation. ✓
Edges with fractional cover values:
Each edge has at least one endpoint rounded to 1. Total covering cost ≤ 2 × fractional OPT.
LP rounding is a general recipe that applies to many NP-hard problems:
| Problem | Technique | Ratio |
|---|---|---|
| Vertex Cover | Round x_v \ge 1/2 | 2 |
| Set Cover | Randomized rounding | O(\log n) |
| MAX-SAT | Randomized rounding | 0.75 (best possible? open) |
| Metric TSP | LP subtour elimination | 3/2 |
Key advantage: LP gives a principled lower bound on OPT — the hardest part of approximation analysis.
| Idea | Key Point |
|---|---|
| NP-hardness | Many problems likely have no poly-time optimal algorithm |
| Approximation | Settle for provably near-optimal solutions in polynomial time |
| LP | Linear objective + linear constraints — poly-time solvable |
| IP | LP with integrality — NP-hard |
| LP Relaxation | Drop integrality → fractional solution as lower bound |
| LP Rounding | Round fractional → integer → provable approximation ratio |
| VC Example | IP → LP → round x \ge 1/2 → 2-approximation |
Next: More LP rounding applications — Set Cover, MAX-SAT, and randomized rounding.
CS F364: Design & Analysis of AlgorithmsTulasimohan Molli