Back to SE444

Lecture 4: Local Search Algorithms

Beyond Traditional Pathfinding: Focus on Solutions, Not Paths

Explore Hill Climbing, Simulated Annealing, and optimization techniques

From Path-Finding to Solution-Finding

Traditional search algorithms find optimal paths from start to goal.

Local search algorithms find good solutions efficiently, without caring about the path taken!

About This Lecture

Local search represents a paradigm shift from traditional AI search. Instead of exploring paths through state spaces, local search focuses on iteratively improving solutions by making small, local changes. This approach is ideal for optimization problems where the journey doesn't matter - only the destination.

Duration: 2-3 hours
Topics: 12+ demos + 2 exercises
Level: Intermediate

Interactive Local Search Demos

N-Queens & Utility Functions

Interactive introduction to the N-Queens problem and utility function concepts. Place queens on a 4×4 board and watch how utility values change with conflicts!

Traveling Salesman Problem

Explore the classic TSP optimization problem. Understand tour representations, utility functions, and 2-opt local moves through interactive visualizations!

Hill Climbing: N-Queens

Watch step-by-step hill climbing execution on 4×4 N-Queens. See how neighbor evaluation and utility functions guide the search - or get stuck in local maxima!

Hill Climbing: TSP

Interactive TSP optimization with 2-opt moves. Watch ALL neighbor evaluations and see how hill climbing finds local optima in the tour distance landscape!

TSP Neighbor Types

Compare city swaps vs 2-opt moves! Visual comparison showing why 2-opt eliminates crossings and finds better tour improvements than simple swaps.

2D Search Landscape

Interactive 2D landscape showing local maxima, plateaus, shoulders, and ridges! Place the hill climbing agent anywhere and watch it navigate different terrain challenges.

1D Search Landscape

Classic textbook visualization! Interactive 1D curve showing global maximum, local maximum, shoulder, and flat plateau. Perfect for understanding hill climbing fundamentals.

Simulated Annealing: N-Queens

Step-by-step N-Queens execution with detailed acceptance probability calculations! Watch temperature control bad move acceptance with P = e^(ΔE/T) formula visualization.

Simulated Annealing: TSP

Apply simulated annealing to the Traveling Salesman Problem! Interactive visualization showing tour optimization with temperature-controlled 2-opt moves and acceptance decisions.

Genetic Algorithm: N-Queens

Evolution-based optimization with population, selection, crossover, and mutation! Watch solutions evolve over generations with interactive visualization and parameter control.

GA Selection Methods

Interactive comparison of Roulette Wheel, Tournament, and Rank selection methods! Visual demonstrations showing how each method chooses parents with different probabilities.

Introduction to Local Search

Comprehensive introduction to local search concepts. Compare classical vs local search, understand state spaces, and learn the fundamentals of optimization algorithms!

Exercises & Practice

Local Search Algorithms

Hill Climbing

The simplest local search algorithm. Always moves to the best neighboring state. Fast but can get stuck at local maxima.

Steepest Ascent

Examines all neighbors before choosing the best one. More informed decisions but higher computational cost per step.

Random Restart

Overcomes local optima by running hill climbing multiple times from different starting points. Higher success rate.

Advanced Local Search Techniques

Simulated Annealing

Allows occasional "bad" moves to escape local optima. Probability of bad moves decreases over time like cooling metal.

Tabu Search

Maintains a memory of recent moves to avoid cycling. Explores more systematically than pure local search.

Genetic Algorithms

Population-based approach inspired by evolution. Maintains multiple candidate solutions and combines them.

Real-World Applications

N-Queens Problem

Place N queens on a chessboard so none attack each other. Perfect for local search since only final configuration matters.

Traveling Salesman

Find shortest tour visiting all cities. Huge state space makes traditional search impractical - local search excels here.

Scheduling Problems

Assign courses to time slots and rooms optimally. Complex constraints and large solution space ideal for local search.

VLSI Design

Optimize circuit layout for minimal area and maximum performance. Local search helps fine-tune component placement.

Machine Learning

Train neural networks by adjusting weights to minimize error. Gradient descent is a form of local search.

Production Planning

Optimize manufacturing schedules, resource allocation, and supply chain logistics using local search techniques.

Key Insights: When to Use Local Search

Use Local Search When:
  • Path doesn't matter - only final solution quality
  • State space is huge - traditional search is too slow
  • Good enough solutions are acceptable
  • Memory is limited - need constant space
  • Optimization problems with measurable solution quality
  • Real-time applications need fast responses
Avoid Local Search When:
  • Path is important - need to know how you got there
  • Optimal solution required - can't accept "good enough"
  • Solution space is discrete and neighbors are unclear
  • No clear evaluation function to measure solution quality
  • Problem has many constraints that are hard to satisfy locally
  • State space is small - traditional search is fine