artificial intelligence lecture : heuristic search-i ghulam irtaza sheikh– dept cs-bzu adapted...

30
Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & other

Upload: andrew-doyle

Post on 26-Mar-2015

225 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

Artificial Intelligence

Lecture : Heuristic Search-I

Ghulam Irtaza Sheikh– Dept CS-BZU

Adapted from original course material & others

Page 2: 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

Page 3: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

“A commonsense rule (or set of rules) intended to increase the probability of solving some problem”

Heuristic

Page 4: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

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

Page 5: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

First three levels of the tic-tac-toe state space reduced by symmetry

Page 6: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

The “most wins” heuristic applied to the first children in tic-tac-toe

Page 7: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

Heuristically reduced state space for tic-tac-toe

Page 8: 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

Page 9: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

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

Page 10: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

The local maximum problem for hill-climbing with 3-level look ahead

Page 11: 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

Page 12: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

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

Page 13: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

Best-First Search

Page 14: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

Best-First / Greedy Search

Expand the node that seems closest…

What can go wrong?

Page 15: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

Best-First / Greedy Search 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

…b

Page 16: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

Best First Search

Algorithm Complete Optimal Time SpaceGreedy Best-First Search

What do we need to do to make it complete? Can we make it optimal?

Y* N O(bm) O(bm)

…b

m

Page 17: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

The best-first search algorithm

Page 18: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

Heuristic search of a hypothetical state space

Page 19: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

A trace of the execution of best-first-search

Page 20: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

Heuristic search of a hypothetical state space with open and closed states highlighted

Page 21: 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

Page 22: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

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)

Page 23: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

The start state, first moves, and goal state for an example-8 puzzle

Page 24: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

Three heuristics applied to states in the 8-puzzle

Page 25: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

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 nh(n) – from the current state n to the goal state

Page 26: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

The heuristic f applied to states in the 8-puzzle

Page 27: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

State space generated in heuristic search of the 8-puzzle graph

Page 28: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

The successive stages of open and closed that generate the graph are:

Page 29: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

Open and closed as they appear after the 3rd iteration of heuristic search

Page 30: Artificial Intelligence Lecture : Heuristic Search-I Ghulam Irtaza Sheikh– Dept CS-BZU Adapted from original course material & others

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