🌿 Branch & Bound
536 words
3 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# 🌿 Branch & Bound ## 1. 🎯 Learning Objectives - Trace Branch & Bound search tree for TSP - Compute lower bounds for partial tours - Apply permanent exclusion rules in TSP-BnB - Explain the B&B node expansion order - Compare B&B with A* and brute force ## 2.

🌿 Branch & Bound
1. 🎯 Learning Objectives
- Trace Branch & Bound search tree for TSP
- Compute lower bounds for partial tours
- Apply permanent exclusion rules in TSP-BnB
- Explain the B&B node expansion order
- Compare B&B with A* and brute force
2. 📖 Core Content
3.1 Intuition: Pruning with Bounds
Branch & Bound (B&B) systematically explores candidates while using lower bounds to prune unpromising branches. If the lower bound of a partial solution exceeds the current best complete solution, that branch cannot yield a better solution — prune it.
B&B for minimization:
- Branch: Generate subproblems (partial solutions)
- Bound: Compute lower bound on solution cost
- Prune: If bound ≥ current best, discard branch
3.2 B&B Algorithm
textBranchAndBound(initial): best_solution = null best_cost = infinity OPEN = [initial_partial_solution] while OPEN is not empty: node = select_node(OPEN) // Usually best-bound-first bound = lower_bound(node) if bound >= best_cost: continue // Prune if node is complete solution: if cost(node) < best_cost: best_cost = cost(node) best_solution = node else: children = branch(node) for child in children: if lower_bound(child) < best_cost: OPEN.add(child) return best_solution
3.3 TSP-BnB: Lower Bounds
For TSP, a lower bound for a partial tour can be computed using reduced cost matrix:
- Row reduction: Subtract minimum value from each row
- Column reduction: Subtract minimum value from each column (after row reduction)
- Lower bound = sum of all reductions + existing tour cost Example: Distance matrix for 5 cities:
pseudo[∞, 20, 30, 10, 11] [15, ∞, 16, 4, 2] [3, 5, ∞, 2, 4] [19, 6, 18, ∞, 3] [16, 4, 7, 16, ∞]
Row minima: row 0=10, row 1=2, row 2=2, row 3=3, row 4=4 After row reduction + column reduction of resulting matrix → total reduction = LB
3.4 Permanent Exclusion Rules
When an edge (i,j) is permanently excluded:
- Row i and column j can be eliminated from consideration
- The excluded edge's cost is set to ∞ in the matrix
- This prevents revisiting cities
3.5 B&B Trace for TSP
Starting from city 0, expanding partial tours:
Level 0: Root (no edges). LB = total reduction of full matrix. Level 1: Branches for each possible first edge (0,1), (0,2), (0,3), (0,4). Compute LB for each. Select node with smallest LB. Level 2: From selected node, branch on next edge from current city. Continue until complete tour found.
4. 📐 Key Formulas
| Concept | Formula |
|---|---|
| Row reduction | minjd(i,j) subtracted from each row |
| Column reduction | minid(i,j) subtracted from each column |
| Lower bound | Sum of all reductions |
| Pruning condition | LB≥bestcost |
5. 📝 Practice Questions
Q1: In B&B for TSP, what happens when lower bound exceeds the current best?Answer: The branch is pruned — it cannot yield a better solution than the one already found. This is the "bound" part of Branch & Bound. Q2: Why might B&B visit exponentially many nodes in worst case?Answer: If the lower bound is weak (much lower than actual cost), few branches are pruned. The worst case is exploring the entire search tree, which has O((n-1)!) nodes for TSP. Join Discord PreviousAnt Colony OptimizationNextAdmissibility & Consistency