Problem Graphs Matching Hill Climbing
Problem Graphs Matching Hill Climbing
• A problem graph, containing the start node S and the goal node G.
• A strategy, describing the manner in which the graph will be
traversed from S to G.
• A fringe, a data structure used to store all the possible states.
Matching
• Matching is the process of comparing two or more structures to discover their
likenesses or differences.
• The match fails if the patterns differ in any aspect.
• For example,
• Match between the two character strings acdebfba and acdebeba fails on an
exact match since the strings differ in the sixth character positions
Uses
• Controls the sequence of operations
• Identification or classification of objects
• To determine the best of a number of different alternatives
• Retrieve items from a database
• Solution: The solution for the plateau is to take big steps or very little
steps while searching, to solve the problem.
• Useful for solving pure optimization problems, which aims to find the best state
according to an objective function.
Hill Climbing on 8 puzzle problem 1
Hill climbing using a heuristic measurement
(Number of misplaced tiles) 2
3
4
Goal state Start state 5
Hill Climbing on 8 puzzle problem 1
Hill climbing using a heuristic measurement
(Number of misplaced tiles) 2
3
Goal state Start state 4
Possible actions
Local Maxima
Goal state
Hill Climbing is NOT complete.
Hill Climbing is NOT optimal.
• Why use local search?
• Low memory requirements – Usually constant
• Effective – Can often find good solutions in extremely large state spaces
• Randomized variants of hill climbing can solve many of the drawbacks in practice.
Types of Hill Climbing Algorithm
• Simple hill Climbing
• Steepest-Ascent hill-climbing
• Stochastic hill Climbing
Simple Hill Climbing
It only evaluates the neighbor node state at a time and selects the first one which
optimizes current cost and set it as a current state.
• Less time consuming
Algorithm for Simple Hill Climbing:
Step 1: Evaluate the initial state, if it is goal state then return success and Stop.
Step 2: Loop Until a solution is found or there is no new operator left to apply.
Step 3: Select and apply an operator to the current state.
Step 4: Check new state:
• If it is goal state, then return success and quit.
• Else if it is better than the current state then assign new state as a current state.
• Else if not better than the current state, then return to step2.
Step 5: Exit
Steepest-Ascent hill climbing
This algorithm examines all the neighboring nodes of the current state and selects one neighbor node
which is closest to the goal state.
This algorithm consumes more time as it searches for multiple neighbors Algorithm for Steepest-Ascent
hill climbing:
Step 1: Evaluate the initial state, if it is goal state then return success and stop, else make current state as initial state.
Step 2: Loop until a solution is found or the current state does not change.
Let SUCC be a state such that any successor of the current state will be better than it.
• For each operator that applies to the current state: Apply the new operator and generate a new state.
• Evaluate the new state.
• If it is goal state, then return it and quit, else compare it to the SUCC.
• If it is better than SUCC, then set new state as SUCC.
• If the SUCC is better than the current state, then set current state to SUCC.
Step 5: Exit.
Example: Travelling salesman problem
Stochastic hill climbing
Stochastic hill climbing does not examine for all its neighbor before moving.
Rather, this search algorithm selects one neighbor node at random and decides
whether to choose it as a current state or examine another state.
1 2