320 likes | 608 Views
Artificial Intelligence. Lecture : Heuristic Search-I. Ghulam Irtaza Sheikh– Dept CS-BZU. Adapted from original course material & others. Today. Hill-climbing Heuristic search algorithm Heuristic Evaluation Function. Heuristic.
E N D
Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others
Today • Hill-climbing • Heuristic search algorithm • Heuristic Evaluation Function
Heuristic “A commonsense rule (or set of rules) intended to increase the probability of solving some problem”
Heuristics • Rules for choosing paths in a state space that most likely lead to an acceptable problem solution • Purpose • Reduce the search space • Reasons • May not have exact solutions, need approximations • Computational cost is too high • Fallible
First three levels of the tic-tac-toe state space reduced by symmetry
The “most wins” heuristic applied to the first children in tic-tac-toe
Today • Hill-climbing • Heuristic search algorithm • Heuristic Evaluation Function
Hill-Climbing • Analog • Go uphill along the steepest possible path until no farther up • Principle • Expand the current state of the search and evaluate its children • Select the best child, ignore its siblings and parent • No history for backtracking • Problem • Local maxima – not the best solution
The local maximum problem for hill-climbing with 3-level look ahead
Today • Hill-climbing • Heuristic search algorithm • Heuristic Evaluation Function
The Best-First Search • Also heuristic search – use heuristic (evaluation) function to select the best state to explore • Can be implemented with a priority queue • Breadth-first implemented with a queue • Depth-first implemented with a stack
Best-First / Greedy Search • Expand the node that seems closest… • What can go wrong?
Best-First / Greedy Search b • A common case: • Best-first takes you straight to the goal on a wrong path • Worst-case: like a badly-guided DFS in the worst case • Can explore everything • Can get stuck in loops if no cycle checking • Like DFS in completeness (finite states w/ cycle checking) … b …
Best First Search • What do we need to do to make it complete? • Can we make it optimal? O(bm) O(bm) Y* N b … m
Heuristic search of a hypothetical state space with open and closed states highlighted
Today • Hill-climbing • Heuristic search algorithm • Heuristic Evaluation Function
Heuristic Evaluation Function • Heuristics can be evaluated in different ways • 8-puzzle problem • Heuristic 1: count the tiles out of places compared with the goal state • Heuristic 2: sum all the distances by which the tiles are out of pace, one for each square a tile must be moved to reach its position in the goal state • Heuristic 3: multiply a small number (say, 2) times each direct tile reversal (where two adjacent tiles must be exchanged to be in the order of the goal)
The start state, first moves, and goal state for an example-8 puzzle
Heuristic Design • Use the limited information available in a single state to make intelligent choices • Must be its actual performance on problem instances • The solution path consists of two parts: from the starting state to the current state, and from the current state to the goal state • The first part can be evaluated using the known information • The second part must be estimated using unknown information • The total evaluation can be f(n) = g(n) + h(n) g(n) – from the starting state to the current state n h(n) – from the current state n to the goal state
State space generated in heuristic search of the 8-puzzle graph
The successive stages of open and closed that generate the graph are:
Open and closed as they appear after the 3rd iteration of heuristic search
Heuristic Design Summary • f(n) is computed as the sum of g(n) and h(n) • g(n) is the depth of n in the search space and has the search more of a breadth-first flavor. • h(n) is the heuristic estimate of the distance from n to a goal • The h value guides search toward heuristically promising states • The g value grows to determine h and force search back to a shorter path, and thus prevents search from persisting indefinitely on a fruitless path