Upload
ally
View
57
Download
0
Embed Size (px)
DESCRIPTION
Artificial Intelligence & Expert Systems. Heuristic Search. Heuristics. Heuristic means “rule of thumb”. To quote Judea Pearl, - PowerPoint PPT Presentation
Citation preview
Artificial Intelligence &
Expert Systems
Heuristic Search
Heuristics
Heuristic means “rule of thumb”. To quote Judea Pearl,
“Heuristics are criteria, methods or principles for deciding which among several alternative courses of action promises to be the most effective in order to achieve some goal”.
In heuristic search or informed search, heuristics are used to identify the most promising search path.
Heuristics . . .
“The study of the methods and rules of discovery and invention” defined by George Polya
Greek root word is euisco which means “I discover” Archimedes emerged and shouted “Eureka”
meaning “I have found it” In state space search, heuristics are formalized as
rules for choosing those branches in a state space that are most likely to lead to an acceptable solution
AI problem solvers employ heuristics in two basic situation
(1) A problem may not have an exact solution because of inherent ambiguities in the problem statement or available data.
A given set of symptoms may have several possible causes; doctors use heuristics to choose the most likely diagnosis and formulate a plan of treatment
(2) A problem may have an exact solution, but the computational cost of finding it may be prohibitive. In many problems (such as chess),state space growth is combinatorially explosive, with the number of possible states increasing exponentially or factorially with the depth of the search. In these cases, exhausive, bruce-force search techniques such as depth-first or breadth-first search may fail to find a solution within any practical length of time. Heuristics attack this complexity by guiding the search along the most “promising” path through the space. By eliminating unpromising states and their descendants from consideration, a heuristics algorithm can defeat this combinatorial explosion and find an acceptable solution.
Inherent limitation of heuristic search
Heuristic is only an informed guess of the next step to be taken in solving a problem.
Because heuristics use limited information, they are seldom able to predict the exact behavior of the state space farther along in the search.
a heuristic can lead a search algorithm to a sub-optimal solution or fail to find any solution at all.
Importance of heuristics
But heuristics and the design of algorithms to implement heuristic search have long been a core concern of artificial intelligence research
It is not feasible to examine every inference that can be made in a mathematics domain
heuristic search is often the only practical answer more recently, expert systems research has
affirmed the importance of heuristics as an essential component of problem solving
Algorithms for Heuristic Search
Heuristic Search
Hill Climbing Best first search A* Algo
Hill Climbing To implementation of heuristic search is through a
procedure called hill climbing Hill climbing strategies expand the current state in
the search and evaluate its children the best child is selected for further expansion;
neither its siblings nor its parent are retained search halts when it reaches a state that is better
than any of its children go uphill along the steepest possible path until it can
go no farther because it keeps no history, the algorithm cannot
recover from failures of its strategy
Hill Climbing . . .
• If the Node is better, only then you proceed to that Node.Algorithm:1. Start with current-state (cs) = initial state2. Until cs = goal-state or there is no change in the cs do:
(a) Get the successor of cs and use the EVALUATION FUNCTION to assign a score to each successor
(b) If one of the successor has a better score than cs then set the new state to be the successor with the
best score.
Example-1: Tic-Tac-Toe
In tic-tac-toe problem,
the combinatorics for exhaustive search are high but not insurmountable
total number of states that need to be considered in an exhaustive search at 9x8x7x….or 9!
Symmetry reduction decrease the search space Symmetry reductions on the second level further
reduce the number of paths through the space to 12x7!
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.
Which one to choose???
Heuristic: calculate winning lines and move to state with
most winning lines.
Heuristically reduced state space for tic-tac-toe.
Example-2:
Devise any heuristic to reach goal: Start : Library Goal : University
Evaluation Function: Distance between two place Adopt the one with minimum distance from goal
Probable route will be:
Library Hospital Newsagent
University
Suppose S2 < S1
Then what will happen?
The algorithm will always go to park from hospital instead of going to newsagent. The algorithm will get stuck here.
Drawback of Hill Climbing
Ridge = sequence of local maxima difficult for hill climbing to navigate
Plateaux = an area of the state space where the evaluation function is flat.
GETS STUCK 86% OF THE TIME.
Simulated Annealing
A method to get rid of the local minima/maxima problem.
It is an optimization method that employ certain techniques to take small steps in the direction indicated by the gradient, but occasionally large steps in the gradient direction / same other directional taken.
Best-First Search
A major problem of hill climbing strategies is their tendency to become stuck at local maxima
if they reach a state that has a better evaluation than any of its children, the algorithm halts
hill climbing can be used effectively if the evaluation function is sufficiently informative to avoid local maxima and infinite paths
heuristic search requires a more flexible algorithm: this is provided by best-first search, where, with a priority queue, recovery from local maxima is possible
Heuristic search of a hypothetical state space
A trace of the execution of best-first search
Heuristic search of a hypothetical state space with open and closed highlighted
The best-first search algorithm always select the most promising state on open for further expansion
as it is using a heuristic that may prove erroneous, it does not abandon all the other states but maintains then on open
In the event a heuristic leads the search down a path that proves incorrect, the algorithm will eventually retrieve some previously generated, “next best” state from open and shift its focus to another part of the space
In best-first search, as in depth-first and breadth-first search algorithms, the open list allows backtracking from paths that fail to produce a goal
Evaluation Function
1. Count the no. of tiles out of place in each state when compared with the goal.
Out of place tiles
2, 8, 1, 6
In place tiles
3, 4, 5, 7
2 8 3
1 6 4
7 5
1 2 3
8 4
7 6 5
Initial state
Goal
Heuristic Function f(n) = h(n)
Drawback:
The heuristic defined does not take into account the distance each tile has to be moved to bring it to the correct place.
Sum the no. of boxes the tile has to be moved to reach the goal
for example:
41
1
Total places to be moved = ‘2’
21
1
1
No. of places to be moved = ‘3’
2 8 3
1 6 4
7 5
Total tiles out of place = 5
Sum of distances out of place = 6
Tiles Distance
1 1
2 1
8 2
6 1
7 1 total: 6
Another ScenarioThe first picture shows the current state n, and the second picture the goal state. h(n) = 5 because the tiles 2, 8, 1, 6 and 7 are out of place.
Manhattan Distance Heuristic: Another heuristic for 8-puzzle is the Manhattan distance heuristic.
This heuristic sums the distance that the tiles are out of place.
The distance of a tile is measured by the sum of the differences in the x-positions and the y-positions.
For the above example, using the Manhattan distance heuristic,
h(n) = 1 + 1 + 0 + 0 + 0 + 1 + 1 + 2 = 6
3 5 6
1 4
2 8 7
Total tiles out of place = 7
Sum of distances
Tiles Distance
3 2
1 1
2 2
8 2
7 2
6 3
5 3 total: 15
Complete Heuristic function (sum of two functions)
f(n) = g(n) + h(n)
where h(n) = Sum of the distances
g(n) = tiles out of places
Anther Heuristic Could be:
g(n) = level of search
h(n) = number of tiles out of place
In general,
Best-first search is a general algorithm for heuristically search any state space graph (as were in the breadth-and depth-first algorithms)
It is equally appropriate data-and goal-driven searches and supports a variety of heuristic evaluation functions
Because of its generality, best-first search can be used with a variety of heuristics, ranging from subjective estimates of state’s “goodness” to sophisticated measure based on the probability of a state leading to a goal
Drawbacks with BFS
Problems with Best First Search It reduces the costs to the goal but
It is not optimal nor complete Uniform cost
Algorithm A
Consider the evaluation function
f(n) = g(n) + h(n)
wheren is any state encountered during the searchg(n) is the cost of n from the start stateh(n) is the heuristic estimate of the distance n to the goal
If this evaluation algorithm is used with the best_first_search algorithm, the result is called algorithm A.
Algorithm A*
If the heuristic function used with algorithm A is admissible, the result is called algorithm A* (pronounced A-star).
A heuristic is admissible if it never overestimates the cost to the goal.
The A* algorithm always finds the optimal solution path whenever a path from the start to a goal state exists.
Monotonicity
A heuristic function h is monotone if
1. For all states ni and nJ, where nJ is a descendant of ni,
h(ni) - h(nJ) cost (ni, nJ),
where cost (ni, nJ) is the actual cost (in number of moves) of going from state ni to nJ.
2. The heuristic evaluation of the goal state is zero, or h(Goal) = 0.
Informedness
For two A* heuristics h1 and h2, if
h1 (n) h2 (n), for all states n in the search space,
heuristic h2 is said to be more informed than h1.
Condition for Admissible Search
h(n) <= h*(n)
Estimated Heuristic Cost
Actual Heuristic Cost
This Condition Ensures Shortest Path
A* Search
Evaluation function:
f(n) = g(n) +h(n)
Path cost to node n + heuristic cost at n
Constraints:
h(n) <= h*(n) (Admissible)
g(n) >= g*(n) (Coverage)
Coverage: g(n) >= g*(n)
g(n)
g*(n)
Goal will never be reached
Example of A*
Path: (P1): Best First/Hill Climbing
ABDEF: Cost P1 = 14 (not optimal)
For A* algorithm
F(A)=0+10=10,
F(B)=2+8=10, f(C) = 2+9=11, Expand B
F(D)=(2+5)+6=13, f(C)=11, Expand C
F(G)=(2+3)+3=8, f(D)=13, Expand G
F(f)=(2+3+2)+0=7, GOAL achieved
Path ACGF: Cost P2=7 (Optimal)
Path Admissibility
Cost P2 < Cost P1 hence P2 is admissible Path
A:10
2 2
B:8 C:9
5 3
D:6 G:3
3
E:4 2
4
F:0
ExplanationFor A* algorithm Path (P2)
Now lets start from A, should we
move from A to B or A to C.
Lets check the path cost SAME,
So lets see the total cost
(fb=hb+gb=8+2=10)
(fc=hc+gb=9+2=11), hence moving through
B is better
Next move to D, total path cost to D is 2+5 = 7, and heuristic cost is 6, total is 7+6=13.
On the other side If you move through C to G, then the path cost is 2+3=5, and heuristic cost is 3, total = 3+5=8, which is much better than moving through state D. So now we choose to change path and move through G
A:10
2 2
B:8 C:9
5 3
D:6 G:3
3
E:4 2
4
F:0
Explanation
Now from G we move to the Goal node F
Total Path cost via G is 2+3+2=7
And Total Path cost via D is 2+5+3+4=14
Hence moving through G is much better will give the optimal path.
A:10
2 2
B:8 C:9
5 3
D:6 G:3
3
E:4 2
4
F:0
For A*never throw away For A*never throw away unexpanded nodes:unexpanded nodes:
Always compare paths through Always compare paths through expanded and unexpanded nodesexpanded and unexpanded nodes
Avoid expanding paths that are already expensive
A* search
Best-known form of best-first search. Idea: avoid expanding paths that are already
expensive. Evaluation function f(n)=g(n) + h(n)
g(n) the cost (so far) to reach the node. h(n) estimated cost to get from the node to the goal. f(n) estimated total cost of path through n to goal.
A* search
A* search uses an admissible heuristic A heuristic is admissible if it never overestimates
the cost to reach the goal Are optimistic
Formally:
1. h(n) <= h*(n) where h*(n) is the true cost from n
2. h(n) >= 0 so h(G)=0 for any goal G.
e.g. hSLD(n) never overestimates the actual road distance
Romania example
A* search example
Starting at Arad f(Arad) = g(Arad,Arad)+h(Arad)=0+366=366
A* search example
Expand Arad and determine f(n) for each node f(Sibiu)= g(Arad,Sibiu)+h(Sibiu)=140+253=393 f(Timisoara)=g(Arad,Timisoara)+h(Timisoara)=118+329=447 f(Zerind)=g(Arad,Zerind)+h(Zerind)=75+374=449
Best choice is Sibiu
A* search example
Expand Sibiu and determine f(n) for each node f(Arad)= g(Sibiu,Arad)+h(Arad)=280+366= 646 f(Fagaras)=g(Sibiu,Fagaras)+h(Fagaras)=239+179= 415 f(Oradea)=g(Sibiu,Oradea)+h(Oradea)=291+380= 671 f(Rimnicu Vilcea)=g(Sibiu,Rimnicu Vilcea)+
h(Rimnicu Vilcea)=220+192= 413 Best choice is Rimnicu Vilcea
Previous Pathsf(Timisoara)=c(Arad,Timisoara)+h(Timisoara)=118+329=
447f(Zerind)=c(Arad,Zerind)+h(Zerind)=75+374=449
A* search example
f(Timisoara)=g(Arad,Timisoara)+h(Timisoara)=118+329= 447 f(Zerind)=g(Arad,Zerind)+h(Zerind)=75+374= 449 f(Arad)=g(Sibiu,Arad)+h(Arad)=280+366= 646 f(Fagaras)=g(Sibiu,Fagaras)+h(Fagaras)=239+179= 415 f(Oradea)=g(Sibiu,Oradea)+h(Oradea)=291+380= 671
Expand Rimnicu Vilcea and determine f(n) for each node f(Craiova)=g(Rimnicu Vilcea, Craiova)+h(Craiova)=360+160= 526 f(Pitesti)=g(Rimnicu Vilcea, Pitesti)+h(Pitesti)=317+100= 417 f(Sibiu)=g(Rimnicu Vilcea,Sibiu)+h(Sibiu)=300+253= 553
Best choice is Fagaras
A* search example
f(Timisoara)=g(Arad,Timisoara)+h(Timisoara)=118+329= 447
f(Zerind)=g(Arad,Zerind)+h(Zerind)=75+374= 449 f(Arad)=g(Sibiu,Arad)+h(Arad)=280+366= 646 f(Fagaras)=g(Sibiu,Fagaras)+h(Fagaras)=239+179= 415 f(Oradea)=g(Sibiu,Oradea)+h(Oradea)=291+380= 671
Expand Rimnicu Vilcea and determine f(n) for each node f(Craiova)=g(Rimnicu Vilcea, Craiova)+h(Craiova)=360+160= 526 f(Pitesti)=g(Rimnicu Vilcea, Pitesti)+h(Pitesti)=317+100= 417417 f(Sibiu)=g(Rimnicu Vilcea,Sibiu)+h(Sibiu)=300+253= 553
Expand Fagaras and determine f(n) for each node f(Sibiu)=g(Fagaras, Sibiu)+h(Sibiu)=338+253= 591 f(Bucharest)=g(Fagaras,Bucharest)+h(Bucharest)=450+0= 450
Best choice is Pitesti !!!
A* search example
Expand Pitesti and determine f(n) for each node f(Bucharest)=g(Pitesti,Bucharest)+h(Bucharest)=418+0=418
Best choice is Bucharest !!! Optimal solution (only if h(n) is admissable)
Note values along optimal path !!
A* search, evaluation
Completeness: YES Since bands of increasing f are added Unless there are infinitely many nodes with f<f(G)
A* search, evaluation
Completeness: YES Time complexity:
Number of nodes expanded is still exponential in the length of the solution.
A* search, evaluation
Completeness: YES Time complexity: (exponential with path
length) Space complexity:
It keeps all generated nodes in memory Hence space is the major problem not time
Heuristic Search & Expert Systems
Expert Systems:
Human Extract Heuristic Develop Rules
Expert Knowledge
No certainties
are involved Knowledge Base
Manipulates the
knowledge to run
the system
Using Heuristics in Games Games have always been an important application area for
heuristic algorithms Two-person games are more complicated than simple puzzles
because of the existence of a “hostile” and essentially unpredictable opponent
consider games whose state space is small enough to be exhaustively searched; here the problem is systematically searching the space of possible moves and countermoves by the opponent
look at games in which it is either impossible or undesirable to exhaustively search the game graph
Because only a portion of the state space can be generated and searched, the game player must use heuristics to guide play along a path to a winning state