BITS Pilani
CS F364: Design and Analysis of Algorithms

Coping with NP-Hardness: LP Relaxation & Rounding

Lecture 28 |2026-07-11

Coping with NP-Hardness: LP Relaxation & Rounding

  • Coping with NP-Hardness: LP Relaxation & Rounding

Lec 27 Recap

Yesterday (Lec 27): We proved CLIQUE and Vertex Cover are NP-complete via reductions from 3-SAT.

  • 3-SAT \le_P CLIQUE — clauses → groups of 3 vertices, edges across groups except conflicting literals
  • CLIQUE \le_P Vertex Cover — complement graph duality: k-clique in G \iff (|V|-k)-vertex cover in \bar{G}

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?

Coping with NP-Hardness

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.

Approximation Ratio

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}

What is Linear Programming?

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).

Geometric Intuition

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.

LP Example: Product Mix

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}

Integer Programming

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.

LP Relaxation

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 LP relaxation is polynomial-time solvable
  • Its optimal value is a lower bound on the IP optimal (for minimization)
  • We can round the fractional solution to get a feasible integer solution

LP Rounding Framework

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.

Example: Vertex Cover

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.

Vertex Cover: LP Relaxation

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.

Vertex Cover: Rounding

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. ✓

Visualizing the Rounding

Edges with fractional cover values:

  • Edge 1: x_u = 0.6, x_v = 0.4 → round u to 1
  • Edge 2: x_u = 0.3, x_w = 0.7 → round w to 1
  • Edge 3: x_v = 0.4, x_w = 0.7 → round w to 1

Each edge has at least one endpoint rounded to 1. Total covering cost ≤ 2 × fractional OPT.

When LP Rounding Works Best

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.

Summary

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.