The previous search algorithms all cares about the path from the initial state to the solution(which include the path), but if the path doesn’t matter, we can consider a different kind of algorithm. Local search algorithms operate using a single current node (rather than multiple paths) and generally move only to neighbors of that node, and the path followed by the search are typically not retained. In addition to finding goals, local search algorithms are useful for solving pure optimization problems, in which the aim is to find the best state according to an objective function.

Hill-Climbing Search

The hill-climbing search algorithm is simply a loop that continually moves in the direction of increasing value—that is, uphill. It terminates when it reaches a “peak” where no neighbor has a higher value.

function Hill_Climbing(problem):
	let curr = MAKE_NODE(problem.INITIAL_STATE)
	while true:
		let neighbor = highest-value successor of curr
		if neighbor.value <= curr.val:
			return curr.STATE
		curr = neighbor

Hill climbing is sometimes called greedy local search because it grabs a good neighbor state without thinking ahead about where to go next. While it’s efficient to improve a bad state, it has problem of getting stuck when facing the following situations:

Many variants of hill climbing have been invented to prevent those problems:

Simulated Annealing

Idea: to escape local maxima by allowing some of the “bad” moves and the probability of the “bad” moves that we allow will decrease over time

Screen Shot 2022-01-20 at 8.18.06 PM.png

Local Beam Search