SlideShare a Scribd company logo
1 of 41
Download to read offline
Artificial Intelligence
3. Heuristic Search
Prof. Bojana Dalbelo Bašić
Assoc. Prof. Jan Šnajder
University of Zagreb
Faculty of Electrical Engineering and Computing
Academic Year 2019/2020
Creative Commons Attribution–NonCommercial–NoDerivs 3.0 v3.10
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 1 / 41
Motivation
Blind search strategies rely only on
exact information (initial state,
operators, goal predicate)
They don’t make use of additional
information about the nature of
the problem that might make the
search more efficient
If we have a (vague) idea in which
direction to look for the solution, why
not use this information to improve
the search?
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 2 / 41
Outline
1 Heuristics
2 Greedy best-first search and hill-climbing search
3 A* algorithm
4 Heuristics revisited
5 Example: Path-finding on a terrain map
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 3 / 41
Outline
1 Heuristics
2 Greedy best-first search and hill-climbing search
3 A* algorithm
4 Heuristics revisited
5 Example: Path-finding on a terrain map
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 4 / 41
Heuristics
Heuristics – rules about the nature of the problem, which are
grounded in experience and whose purpose is to direct the search
towards the goal so that it becomes more efficient
Heuristic function
Heuristic function h : S → R+ assigns to each state s ∈ S an estimate
of the distance between that state and the goal state
The smaller the value h(s), the closer is s to the goal state. If s is the
goal state, then h(s) = 0
Search strategies that use heuristics to narrow down the search are
called heuristic (informed, directed) search strategies
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 5 / 41
An example: A journey through Istria
Air distances
to Buzet:
Baderna 25
Barban 35
Buje 21
Grožnjan 17
Kanfanar 30
Labin 35
Lupoglav 13
Medulin 61
Motovun 12
Opatija 26
Pazin 17
Poreč 32
Pula 57
Rovinj 40
Umag 31
Višnjan 20
Vodnjan 47
Žminj 27
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 6 / 41
Another example: 8-puzzle
initial state:
goal state:
What to use as heuristic function?
Number of displaced squares:
h1( ) = 7
Sum of city-block (L1) distances
between all squares and their final
positions:
h2( ) = 21
Notice that h2(s) ≥ h1(s)
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 7 / 41
Heuristic search
We’ll take a look at:
1 Greedy best-first search
2 Hill-climbing search
3 A* algorithm
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 8 / 41
A reminder: General search algorithm
General search algorithm
function search(s0, succ, goal)
open ← [ initial(s0) ]
while open 6= [ ] do
n ← removeHead(open)
if goal(state(n)) then return n
for m ∈ expand(n, succ) do
insert(m, open)
return fail
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 9 / 41
Outline
1 Heuristics
2 Greedy best-first search and hill-climbing search
3 A* algorithm
4 Heuristics revisited
5 Example: Path-finding on a terrain map
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 10 / 41
Greedy best-first search
Always expands the node with the best (lowest) heuristic value
Best-first search
function greedyBestFirstSearch(s0, succ, goal, h)
open ← [ initial(s0) ]
while open 6= [ ] do
n ← removeHead(open)
if goal(state(n)) then return n
for m ∈ expand(n, succ) do
insertSortedBy(f, m, open)
return fail
where f(n) = h(state(n))
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 11 / 41
Greedy search
This is greedy best-first search
Greedy search: the algorithm chooses the node that appears to be
the closest to the goal, disregarding the total path cost accumulated
so far
The chosen path may not be optimal, but the algorithm doesn’t
backtrack to correct this. Hence, a greedy algorithm is not optimal
Q: An example?
The algorithm is incomplete (unless we use visited states list)
Time and space complexity: O(bm)
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 12 / 41
Hill-climbing search
Similar to greedy best-first algorithm, but doesn’t bother to keep the
generated nodes in the memory
Hill-climbing search
function hillClimbingSearch(s0, succ, h)
n ← initial(s0)
loop do
M ← expand(n, succ)
if M = ∅ then return n
m ← minimumBy(f, M)
if f(n) < f(m) then return n
n ← m
where f(n) = h(state(n))
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 13 / 41
Hill-climbing search – properties
Not complete and not optimal
Easily trapped in so-called local optima
Efficiency crucially depends on the choice of the heuristic function
One typically employs the random restart technique
Time complexity: O(m)
Space complexity: O(1)
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 14 / 41
Outline
1 Heuristics
2 Greedy best-first search and hill-climbing search
3 A* algorithm
4 Heuristics revisited
5 Example: Path-finding on a terrain map
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 15 / 41
A* algorithm
Similar to best-first algorithm, but takes into account both the
heuristics and the path cost, i.e., the algorithm combines best-first
and uniform cost search
Path costs are updated when nodes are expanded (similarly as with
uniform cost search):
function expand(n, succ)
return { (s, g(n) + c) | (s, c) ∈ succ(state(n)) }
The total costs is computed as:
g(n) – true path cost from the initial node to node n
h(s) – path cost estimate from state s to the goal
f(n) = g(n) + h(state(n))
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 16 / 41
A* search – implementation
A* search
function aStarSearch(s0, succ, goal, h)
open ← [ initial(s0) ]
closed ← ∅
while open 6= [ ] do
n ← removeHead(open)
if goal(state(n)) then return n
closed ← closed ∪ { n }
for m ∈ expand(n) do
if ∃m0 ∈ closed ∪ open such that state(m0) = state(m) then
if g(m0) < g(m) then continue
else remove(m0, closed ∪ open)
insertSortedBy(f, m, open)
return fail
where f(n) = g(n) + h(state(n))
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 17 / 41
A* search – example of execution
0 open = [ (Pula, 0) ]
closed = ∅
1 expand(Pula, 0) = {(Vodnjan, 12), (Barban, 28), (Medulin, 9)}
open = [ (Vodnjan, 12)59
, (Barban, 28)63
, (Medulin, 9)70
]
closed = {(Pula, 0)}
2 expand(Vodnjan, 12) = {(Kanfanar, 41), (Pula, 24)}
open = [ (Barban, 28)63
, (Medulin, 9)70
, (Kanfanar, 41)71
]
closed = {(Pula, 0), (Vodnjan, 12)}
3 expand(Barban, 28) = {(Labin, 43), (Pula, 56)}
open = [ (Medulin, 9)70
, (Kanfanar, 41)71
, (Labin, 43)78
]
closed = {(Barban, 28), (Pula, 0), (Vodnjan, 12)}
4 expand(Medulin, 9) = {(Pula, 18)}
open = [ (Kanfanar, 41)71
, (Labin, 43)78
]
closed = {(Barban, 28), (Medulin, 9), (Pula, 0), (Vodnjan, 12)}
.
.
.
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 18 / 41
A* algorithm – properties
Time and space complexity: O(min(bd+1, b|S|))
(especially space complexity is problematic in practice)
Completeness: yes, because it accounts for path costs
Optimality: yes, but provided the heuristic h is optimistic:
Optimistic heuristic
Heuristic function h is optimistic or admissible iff it never overestimates,
i.e., its value is never greater than the true cost needed to reach the goal:
∀s ∈ S. h(s) ≤ h∗(s),
where h∗(s) is the true path cost of reaching the goal state from state s
If the heuristics is not optimistic, the search might bypass the optimal
path because it seems more expensive than it really is
Q: Are the heuristics from the previous examples optimistic?
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 19 / 41
An example: 8-puzzle
initial state:
goal state:
Which heuristics are optimistic?
h1(s) = number of displaced squares
h2(s) = sum of city-block distances
h3(s) = 0
h4(s) = 1
h5(s) = h∗(s)
h6(s) = min(2, h∗(s))
h7(s) = max(2, h∗(s))
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 20 / 41
Quiz: Non-greedyness of A∗
The A∗ is not greedy because it. . .
A uses a list of closed nodes
B uses a list of open nodes
C uses a heuristic function
D considers the cost from the initial node
E does not repeat the states already visited
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 21 / 41
Putting search algorithms in perspective
A* dominates uniform cost search and breadth-first search
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 22 / 41
Outline
1 Heuristics
2 Greedy best-first search and hill-climbing search
3 A* algorithm
4 Heuristics revisited
5 Example: Path-finding on a terrain map
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 23 / 41
Consistent heuristics (1)
Assuming optimistic heuristic, it holds
f(n) = g(n) + h(state(n)) ≤ C∗
(the cost function has an upper bound)
Along a path in the search tree, f(n) may generally increase and
decrease, but in the goal state it holds f(n) = g(n) = C∗
It is desirable that f(n) monotonically increases:
∀n2 ∈ expand(n1) =⇒ f(n2) ≥ f(n1)
For perfect (oracle) heuristic h∗, we have f(n1) = f(n2) = C∗
If f(n) monotonically increases, then every node we test (and close)
for the first time for some state will be the node with the least
path cost to that particular state
Thus, in case of repeated states, we don’t need to check the path
cost for already closed nodes (their cost is certainly less or equal)
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 24 / 41
Consistent heuristics (2)
If f(n) monotonically increases, then ∀n2 ∈ expand(n1):
f(n1) ≤ f(n2)
g(n1) + h( state(n1)
| {z }
s1
) ≤ g(n2) + h( state(n2)
| {z }
s2
)
g(n1) + h(s1) ≤ g(n1) + c
| {z }
g(n2)
+h(s2)
h(s1) ≤ h(s2) + c
Consistent heuristics
Heuristic h is consistent or monotone iff:
∀(s2, c) ∈ succ(s1). h(s1) ≤ h(s2) + c
NB: A consistent heuristics is necessarily optimistic. On the other
hand, in practice most optimistic heuristics are consistent
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 25 / 41
Quiz: Consistent heuristics
Is the following heuristics optimistic? Is it consistent?
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 26 / 41
A* algorithm – variants
The following variants of the A* algorithm are also optimal:
1 Without the use of a closed list (but space and time inefficient
because of repeated states)
2 With closed list, but without re-opening of closed nodes, provided the
heuristics is consistent
3 With closed list and without re-opening, but using the pathmax
correction:
f(n) = max(f(parent(n)), g(n) + h(state(n)))
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 27 / 41
Domination property
Domination
Let A∗
1 and A∗
2 be optimal algorithms with optimistic heuristic functions
h1 and h2. Algorithm A∗
1 dominates algorithm A∗
2 iff:
∀s ∈ S. h1(s) ≥ h2(s)
We also say that A∗
1 is a more informed algorithm than A∗
2
A more informed algorithm will generally search through a smaller
state space than a less informed algorithm
E.g., for 8-puzzle: h∗(s) ≥ h2(s) ≥ h1(s),
i.e., using city-block distance gives a more informed algorithm than
when using the number of displaced squares
The cost of computing the heuristics should also be taken into
account!
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 28 / 41
Quiz: Heuristics
Let the current state s of the 8-puzzle be [[1, 5, 2], [4, , 3], [7, 8, 6]], and
the goal state be [[1, 2, 3], [4, 5, 6], [7, 8, ]]. Assume h is an optimistic
heuristics. Which of the following can be the most informed value of h(s)?
A 0
B 1
C 3
D 5
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 29 / 41
Good heuristic
A good heuristic is:
1 optimistic
2 well informed
3 simple to compute
Pessimistic heuristics?
If we don’t need an optimal solution, we can search for a “good
enough” solution using a non-optimistic heuristic (one that for some
states overestimates the true cost)
Such a heuristic will additionally reduce the number of generated
nodes
Here we are trading off solution quality for computational efficiency
How can one invent a good heuristics for a given problem?
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 30 / 41
Inventing heuristics
1 Problem relaxation
I true cost of a relaxed problem gives an optimistic heuristic for the
original problem
I e.g. relaxing the 8-puzzle problem:
the squares can move through other squares ⇒ city-block distance
I this yields a heuristic that is both optimistic and consistent (why?)
2 Combining several optimistic heuristics
I If h1, h2, . . . , hn are optimistic, we can combine them into a single
dominant heuristic that will also be optimistic:
h(s) = max h1(s), h2(s), . . . , hn(s)

3 Using sub-problem costs
I pattern database containing precomputed true costs for a number of
sub-problems
4 Learning heuristics
I use of machine learning. E.g., learning of coefficients w1 and w2:
h(s) = w1x1(s) + w2x2(s), where x1 are x2 state describing features
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 31 / 41
Outline
1 Heuristics
2 Greedy best-first search and hill-climbing search
3 A* algorithm
4 Heuristics revisited
5 Example: Path-finding on a terrain map
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 32 / 41
Lab assignment: Path-finding on a terrain map
Write a program that uses the A* algorithm to find the optimal path
between two points on a given terrain map.
Let ∆a = a(x2, y2) − a(x1, y1) be the altitude difference. You can move
from (x1, y1) to (x2, y2) if |x1 − x2| ≤ 1, |y1 − y2| ≤ 1 and ∆a ≤ m.
The cost of moving from position (x1, y1) to position (x2, y2) is
p
(x2 − x1)2 + (y2 − y1)2 +
1
2
sgn(∆a) + 1

· |∆a|
The program should read the map and the parameters from a specified
file. It should generate an image of the height map with clearly indicated
closed nodes, open nodes and the path found. The program should also
print out the length of the path found and the number of iterations of the
algorithm. You should propose at least three different heuristics and try
them out on the map.
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 33 / 41
Path-finding on a terrain map (1)
Terrain map
(brighter pixels correspond to positions at higher altitudes)
red: initial state; green: goal state
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 34 / 41
Path-finding on a terrain map (2)
Uniform cost search
(red: path found; yellow: states visited)
number of closed nodes: 140580; path length: 740.58
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 35 / 41
Path-finding on a terrain map (3)
A* algorithm
(heuristics: air distance)
number of closed nodes: 64507; path length: 740.58
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 36 / 41
Path-finding on a terrain map (4)
A* algorithm
(heuristics: air distance + 1
2 ∆a)
number of closed nodes: 56403; path length: 740.58
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 37 / 41
Path-finding on a terrain map (5)
A* algorithm
(heuristics: air distance + |∆a|)
number of closed nodes: 52099; path length: 755.16
This heuristic is not optimistic!
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 38 / 41
Path-finding on a terrain map (6)
Greedy best-first search
(heuristics: air distance; with visited states list)
number of closed nodes: 822; path length: 1428.54
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 39 / 41
Outline
1 Heuristics
2 Greedy best-first search and hill-climbing search
3 A* algorithm
4 Heuristics revisited
5 Example: Path-finding on a terrain map
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 40 / 41
Wrap-up
Heuristic function guides the search, making it more efficient
Heuristic function estimates the distance between the given state
and the goal state. The smaller the distance, the closer we are to the
goal state
Heuristic should be optimistic, it may be consistent, and it should
be informed as much as possible in order to make the search even
more efficient
Best-first and hill-climbing algorithms are greedy and therefore not
optimal
A* search is both complete and optimal
Next topic: Game playing
Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 41 / 41

More Related Content

Similar to AI-3-HeuristicSearch.pdf

AstarAlgorithm_v5_TeamFlash
AstarAlgorithm_v5_TeamFlashAstarAlgorithm_v5_TeamFlash
AstarAlgorithm_v5_TeamFlash
Shuqing Zhang
 
Iaetsd vlsi implementation of gabor filter based image edge detection
Iaetsd vlsi implementation of gabor filter based image edge detectionIaetsd vlsi implementation of gabor filter based image edge detection
Iaetsd vlsi implementation of gabor filter based image edge detection
Iaetsd Iaetsd
 
Searchadditional2
Searchadditional2Searchadditional2
Searchadditional2
chandsek666
 
Algorithm Design and Complexity - Course 7
Algorithm Design and Complexity - Course 7Algorithm Design and Complexity - Course 7
Algorithm Design and Complexity - Course 7
Traian Rebedea
 

Similar to AI-3-HeuristicSearch.pdf (18)

Jarrar: Informed Search
Jarrar: Informed Search  Jarrar: Informed Search
Jarrar: Informed Search
 
CS767_Lecture_03.pptx
CS767_Lecture_03.pptxCS767_Lecture_03.pptx
CS767_Lecture_03.pptx
 
Unit 3 Informed Search Strategies.pptx
Unit  3 Informed Search Strategies.pptxUnit  3 Informed Search Strategies.pptx
Unit 3 Informed Search Strategies.pptx
 
Astar algorithm
Astar algorithmAstar algorithm
Astar algorithm
 
AstarAlgorithm_v5_TeamFlash
AstarAlgorithm_v5_TeamFlashAstarAlgorithm_v5_TeamFlash
AstarAlgorithm_v5_TeamFlash
 
Final slide (bsc csit) chapter 5
Final slide (bsc csit) chapter 5Final slide (bsc csit) chapter 5
Final slide (bsc csit) chapter 5
 
4 informed-search
4 informed-search4 informed-search
4 informed-search
 
Pathfinding - Part 1: Α* heuristic search
Pathfinding - Part 1: Α* heuristic searchPathfinding - Part 1: Α* heuristic search
Pathfinding - Part 1: Α* heuristic search
 
A Star Search
A Star SearchA Star Search
A Star Search
 
A Star Search
A Star SearchA Star Search
A Star Search
 
AIw06.pptx
AIw06.pptxAIw06.pptx
AIw06.pptx
 
Heuristic search
Heuristic searchHeuristic search
Heuristic search
 
Searching
SearchingSearching
Searching
 
2-Heuristic Search.ppt
2-Heuristic Search.ppt2-Heuristic Search.ppt
2-Heuristic Search.ppt
 
I. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMI. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHM
 
Iaetsd vlsi implementation of gabor filter based image edge detection
Iaetsd vlsi implementation of gabor filter based image edge detectionIaetsd vlsi implementation of gabor filter based image edge detection
Iaetsd vlsi implementation of gabor filter based image edge detection
 
Searchadditional2
Searchadditional2Searchadditional2
Searchadditional2
 
Algorithm Design and Complexity - Course 7
Algorithm Design and Complexity - Course 7Algorithm Design and Complexity - Course 7
Algorithm Design and Complexity - Course 7
 

Recently uploaded

一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书
F
 
一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理
F
 
100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...
100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...
100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...
musaddumba454
 
一比一原版(毕业证书)新西兰怀特克利夫艺术设计学院毕业证原件一模一样
一比一原版(毕业证书)新西兰怀特克利夫艺术设计学院毕业证原件一模一样一比一原版(毕业证书)新西兰怀特克利夫艺术设计学院毕业证原件一模一样
一比一原版(毕业证书)新西兰怀特克利夫艺术设计学院毕业证原件一模一样
AS
 
一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理
F
 
一比一定制加州大学欧文分校毕业证学位证书
一比一定制加州大学欧文分校毕业证学位证书一比一定制加州大学欧文分校毕业证学位证书
一比一定制加州大学欧文分校毕业证学位证书
A
 
原版定制美国加州大学河滨分校毕业证原件一模一样
原版定制美国加州大学河滨分校毕业证原件一模一样原版定制美国加州大学河滨分校毕业证原件一模一样
原版定制美国加州大学河滨分校毕业证原件一模一样
A
 
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
Fi
 
一比一原版美国北卡罗莱纳大学毕业证如何办理
一比一原版美国北卡罗莱纳大学毕业证如何办理一比一原版美国北卡罗莱纳大学毕业证如何办理
一比一原版美国北卡罗莱纳大学毕业证如何办理
A
 
一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理
F
 
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
AS
 
原版定制英国赫瑞瓦特大学毕业证原件一模一样
原版定制英国赫瑞瓦特大学毕业证原件一模一样原版定制英国赫瑞瓦特大学毕业证原件一模一样
原版定制英国赫瑞瓦特大学毕业证原件一模一样
AS
 
一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书
一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书
一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书
AS
 

Recently uploaded (20)

一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书
 
The Rise of Subscription-Based Digital Services.pdf
The Rise of Subscription-Based Digital Services.pdfThe Rise of Subscription-Based Digital Services.pdf
The Rise of Subscription-Based Digital Services.pdf
 
一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理
 
100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...
100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...
100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...
 
Washington Football Commanders Redskins Feathers Shirt
Washington Football Commanders Redskins Feathers ShirtWashington Football Commanders Redskins Feathers Shirt
Washington Football Commanders Redskins Feathers Shirt
 
一比一原版(毕业证书)新西兰怀特克利夫艺术设计学院毕业证原件一模一样
一比一原版(毕业证书)新西兰怀特克利夫艺术设计学院毕业证原件一模一样一比一原版(毕业证书)新西兰怀特克利夫艺术设计学院毕业证原件一模一样
一比一原版(毕业证书)新西兰怀特克利夫艺术设计学院毕业证原件一模一样
 
一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理
 
一比一定制加州大学欧文分校毕业证学位证书
一比一定制加州大学欧文分校毕业证学位证书一比一定制加州大学欧文分校毕业证学位证书
一比一定制加州大学欧文分校毕业证学位证书
 
原版定制美国加州大学河滨分校毕业证原件一模一样
原版定制美国加州大学河滨分校毕业证原件一模一样原版定制美国加州大学河滨分校毕业证原件一模一样
原版定制美国加州大学河滨分校毕业证原件一模一样
 
Abortion Pills In Jeddah+966572737505 & Get cytotec Jeddah
Abortion Pills In Jeddah+966572737505 & Get cytotec JeddahAbortion Pills In Jeddah+966572737505 & Get cytotec Jeddah
Abortion Pills In Jeddah+966572737505 & Get cytotec Jeddah
 
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
 
一比一原版美国北卡罗莱纳大学毕业证如何办理
一比一原版美国北卡罗莱纳大学毕业证如何办理一比一原版美国北卡罗莱纳大学毕业证如何办理
一比一原版美国北卡罗莱纳大学毕业证如何办理
 
一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理
 
Lowongan Kerja LC Yogyakarta Terbaru 085746015303
Lowongan Kerja LC Yogyakarta Terbaru 085746015303Lowongan Kerja LC Yogyakarta Terbaru 085746015303
Lowongan Kerja LC Yogyakarta Terbaru 085746015303
 
Loker Pemandu Lagu LC Semarang 085746015303
Loker Pemandu Lagu LC Semarang 085746015303Loker Pemandu Lagu LC Semarang 085746015303
Loker Pemandu Lagu LC Semarang 085746015303
 
Free on Wednesdays T Shirts Free on Wednesdays Sweatshirts
Free on Wednesdays T Shirts Free on Wednesdays SweatshirtsFree on Wednesdays T Shirts Free on Wednesdays Sweatshirts
Free on Wednesdays T Shirts Free on Wednesdays Sweatshirts
 
Beyond Inbound: Unlocking the Secrets of API Egress Traffic Management
Beyond Inbound: Unlocking the Secrets of API Egress Traffic ManagementBeyond Inbound: Unlocking the Secrets of API Egress Traffic Management
Beyond Inbound: Unlocking the Secrets of API Egress Traffic Management
 
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
 
原版定制英国赫瑞瓦特大学毕业证原件一模一样
原版定制英国赫瑞瓦特大学毕业证原件一模一样原版定制英国赫瑞瓦特大学毕业证原件一模一样
原版定制英国赫瑞瓦特大学毕业证原件一模一样
 
一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书
一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书
一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证学位证书
 

AI-3-HeuristicSearch.pdf

  • 1. Artificial Intelligence 3. Heuristic Search Prof. Bojana Dalbelo Bašić Assoc. Prof. Jan Šnajder University of Zagreb Faculty of Electrical Engineering and Computing Academic Year 2019/2020 Creative Commons Attribution–NonCommercial–NoDerivs 3.0 v3.10 Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 1 / 41
  • 2. Motivation Blind search strategies rely only on exact information (initial state, operators, goal predicate) They don’t make use of additional information about the nature of the problem that might make the search more efficient If we have a (vague) idea in which direction to look for the solution, why not use this information to improve the search? Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 2 / 41
  • 3. Outline 1 Heuristics 2 Greedy best-first search and hill-climbing search 3 A* algorithm 4 Heuristics revisited 5 Example: Path-finding on a terrain map Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 3 / 41
  • 4. Outline 1 Heuristics 2 Greedy best-first search and hill-climbing search 3 A* algorithm 4 Heuristics revisited 5 Example: Path-finding on a terrain map Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 4 / 41
  • 5. Heuristics Heuristics – rules about the nature of the problem, which are grounded in experience and whose purpose is to direct the search towards the goal so that it becomes more efficient Heuristic function Heuristic function h : S → R+ assigns to each state s ∈ S an estimate of the distance between that state and the goal state The smaller the value h(s), the closer is s to the goal state. If s is the goal state, then h(s) = 0 Search strategies that use heuristics to narrow down the search are called heuristic (informed, directed) search strategies Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 5 / 41
  • 6. An example: A journey through Istria Air distances to Buzet: Baderna 25 Barban 35 Buje 21 Grožnjan 17 Kanfanar 30 Labin 35 Lupoglav 13 Medulin 61 Motovun 12 Opatija 26 Pazin 17 Poreč 32 Pula 57 Rovinj 40 Umag 31 Višnjan 20 Vodnjan 47 Žminj 27 Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 6 / 41
  • 7. Another example: 8-puzzle initial state: goal state: What to use as heuristic function? Number of displaced squares: h1( ) = 7 Sum of city-block (L1) distances between all squares and their final positions: h2( ) = 21 Notice that h2(s) ≥ h1(s) Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 7 / 41
  • 8. Heuristic search We’ll take a look at: 1 Greedy best-first search 2 Hill-climbing search 3 A* algorithm Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 8 / 41
  • 9. A reminder: General search algorithm General search algorithm function search(s0, succ, goal) open ← [ initial(s0) ] while open 6= [ ] do n ← removeHead(open) if goal(state(n)) then return n for m ∈ expand(n, succ) do insert(m, open) return fail Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 9 / 41
  • 10. Outline 1 Heuristics 2 Greedy best-first search and hill-climbing search 3 A* algorithm 4 Heuristics revisited 5 Example: Path-finding on a terrain map Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 10 / 41
  • 11. Greedy best-first search Always expands the node with the best (lowest) heuristic value Best-first search function greedyBestFirstSearch(s0, succ, goal, h) open ← [ initial(s0) ] while open 6= [ ] do n ← removeHead(open) if goal(state(n)) then return n for m ∈ expand(n, succ) do insertSortedBy(f, m, open) return fail where f(n) = h(state(n)) Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 11 / 41
  • 12. Greedy search This is greedy best-first search Greedy search: the algorithm chooses the node that appears to be the closest to the goal, disregarding the total path cost accumulated so far The chosen path may not be optimal, but the algorithm doesn’t backtrack to correct this. Hence, a greedy algorithm is not optimal Q: An example? The algorithm is incomplete (unless we use visited states list) Time and space complexity: O(bm) Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 12 / 41
  • 13. Hill-climbing search Similar to greedy best-first algorithm, but doesn’t bother to keep the generated nodes in the memory Hill-climbing search function hillClimbingSearch(s0, succ, h) n ← initial(s0) loop do M ← expand(n, succ) if M = ∅ then return n m ← minimumBy(f, M) if f(n) < f(m) then return n n ← m where f(n) = h(state(n)) Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 13 / 41
  • 14. Hill-climbing search – properties Not complete and not optimal Easily trapped in so-called local optima Efficiency crucially depends on the choice of the heuristic function One typically employs the random restart technique Time complexity: O(m) Space complexity: O(1) Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 14 / 41
  • 15. Outline 1 Heuristics 2 Greedy best-first search and hill-climbing search 3 A* algorithm 4 Heuristics revisited 5 Example: Path-finding on a terrain map Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 15 / 41
  • 16. A* algorithm Similar to best-first algorithm, but takes into account both the heuristics and the path cost, i.e., the algorithm combines best-first and uniform cost search Path costs are updated when nodes are expanded (similarly as with uniform cost search): function expand(n, succ) return { (s, g(n) + c) | (s, c) ∈ succ(state(n)) } The total costs is computed as: g(n) – true path cost from the initial node to node n h(s) – path cost estimate from state s to the goal f(n) = g(n) + h(state(n)) Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 16 / 41
  • 17. A* search – implementation A* search function aStarSearch(s0, succ, goal, h) open ← [ initial(s0) ] closed ← ∅ while open 6= [ ] do n ← removeHead(open) if goal(state(n)) then return n closed ← closed ∪ { n } for m ∈ expand(n) do if ∃m0 ∈ closed ∪ open such that state(m0) = state(m) then if g(m0) < g(m) then continue else remove(m0, closed ∪ open) insertSortedBy(f, m, open) return fail where f(n) = g(n) + h(state(n)) Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 17 / 41
  • 18. A* search – example of execution 0 open = [ (Pula, 0) ] closed = ∅ 1 expand(Pula, 0) = {(Vodnjan, 12), (Barban, 28), (Medulin, 9)} open = [ (Vodnjan, 12)59 , (Barban, 28)63 , (Medulin, 9)70 ] closed = {(Pula, 0)} 2 expand(Vodnjan, 12) = {(Kanfanar, 41), (Pula, 24)} open = [ (Barban, 28)63 , (Medulin, 9)70 , (Kanfanar, 41)71 ] closed = {(Pula, 0), (Vodnjan, 12)} 3 expand(Barban, 28) = {(Labin, 43), (Pula, 56)} open = [ (Medulin, 9)70 , (Kanfanar, 41)71 , (Labin, 43)78 ] closed = {(Barban, 28), (Pula, 0), (Vodnjan, 12)} 4 expand(Medulin, 9) = {(Pula, 18)} open = [ (Kanfanar, 41)71 , (Labin, 43)78 ] closed = {(Barban, 28), (Medulin, 9), (Pula, 0), (Vodnjan, 12)} . . . Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 18 / 41
  • 19. A* algorithm – properties Time and space complexity: O(min(bd+1, b|S|)) (especially space complexity is problematic in practice) Completeness: yes, because it accounts for path costs Optimality: yes, but provided the heuristic h is optimistic: Optimistic heuristic Heuristic function h is optimistic or admissible iff it never overestimates, i.e., its value is never greater than the true cost needed to reach the goal: ∀s ∈ S. h(s) ≤ h∗(s), where h∗(s) is the true path cost of reaching the goal state from state s If the heuristics is not optimistic, the search might bypass the optimal path because it seems more expensive than it really is Q: Are the heuristics from the previous examples optimistic? Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 19 / 41
  • 20. An example: 8-puzzle initial state: goal state: Which heuristics are optimistic? h1(s) = number of displaced squares h2(s) = sum of city-block distances h3(s) = 0 h4(s) = 1 h5(s) = h∗(s) h6(s) = min(2, h∗(s)) h7(s) = max(2, h∗(s)) Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 20 / 41
  • 21. Quiz: Non-greedyness of A∗ The A∗ is not greedy because it. . . A uses a list of closed nodes B uses a list of open nodes C uses a heuristic function D considers the cost from the initial node E does not repeat the states already visited Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 21 / 41
  • 22. Putting search algorithms in perspective A* dominates uniform cost search and breadth-first search Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 22 / 41
  • 23. Outline 1 Heuristics 2 Greedy best-first search and hill-climbing search 3 A* algorithm 4 Heuristics revisited 5 Example: Path-finding on a terrain map Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 23 / 41
  • 24. Consistent heuristics (1) Assuming optimistic heuristic, it holds f(n) = g(n) + h(state(n)) ≤ C∗ (the cost function has an upper bound) Along a path in the search tree, f(n) may generally increase and decrease, but in the goal state it holds f(n) = g(n) = C∗ It is desirable that f(n) monotonically increases: ∀n2 ∈ expand(n1) =⇒ f(n2) ≥ f(n1) For perfect (oracle) heuristic h∗, we have f(n1) = f(n2) = C∗ If f(n) monotonically increases, then every node we test (and close) for the first time for some state will be the node with the least path cost to that particular state Thus, in case of repeated states, we don’t need to check the path cost for already closed nodes (their cost is certainly less or equal) Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 24 / 41
  • 25. Consistent heuristics (2) If f(n) monotonically increases, then ∀n2 ∈ expand(n1): f(n1) ≤ f(n2) g(n1) + h( state(n1) | {z } s1 ) ≤ g(n2) + h( state(n2) | {z } s2 ) g(n1) + h(s1) ≤ g(n1) + c | {z } g(n2) +h(s2) h(s1) ≤ h(s2) + c Consistent heuristics Heuristic h is consistent or monotone iff: ∀(s2, c) ∈ succ(s1). h(s1) ≤ h(s2) + c NB: A consistent heuristics is necessarily optimistic. On the other hand, in practice most optimistic heuristics are consistent Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 25 / 41
  • 26. Quiz: Consistent heuristics Is the following heuristics optimistic? Is it consistent? Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 26 / 41
  • 27. A* algorithm – variants The following variants of the A* algorithm are also optimal: 1 Without the use of a closed list (but space and time inefficient because of repeated states) 2 With closed list, but without re-opening of closed nodes, provided the heuristics is consistent 3 With closed list and without re-opening, but using the pathmax correction: f(n) = max(f(parent(n)), g(n) + h(state(n))) Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 27 / 41
  • 28. Domination property Domination Let A∗ 1 and A∗ 2 be optimal algorithms with optimistic heuristic functions h1 and h2. Algorithm A∗ 1 dominates algorithm A∗ 2 iff: ∀s ∈ S. h1(s) ≥ h2(s) We also say that A∗ 1 is a more informed algorithm than A∗ 2 A more informed algorithm will generally search through a smaller state space than a less informed algorithm E.g., for 8-puzzle: h∗(s) ≥ h2(s) ≥ h1(s), i.e., using city-block distance gives a more informed algorithm than when using the number of displaced squares The cost of computing the heuristics should also be taken into account! Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 28 / 41
  • 29. Quiz: Heuristics Let the current state s of the 8-puzzle be [[1, 5, 2], [4, , 3], [7, 8, 6]], and the goal state be [[1, 2, 3], [4, 5, 6], [7, 8, ]]. Assume h is an optimistic heuristics. Which of the following can be the most informed value of h(s)? A 0 B 1 C 3 D 5 Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 29 / 41
  • 30. Good heuristic A good heuristic is: 1 optimistic 2 well informed 3 simple to compute Pessimistic heuristics? If we don’t need an optimal solution, we can search for a “good enough” solution using a non-optimistic heuristic (one that for some states overestimates the true cost) Such a heuristic will additionally reduce the number of generated nodes Here we are trading off solution quality for computational efficiency How can one invent a good heuristics for a given problem? Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 30 / 41
  • 31. Inventing heuristics 1 Problem relaxation I true cost of a relaxed problem gives an optimistic heuristic for the original problem I e.g. relaxing the 8-puzzle problem: the squares can move through other squares ⇒ city-block distance I this yields a heuristic that is both optimistic and consistent (why?) 2 Combining several optimistic heuristics I If h1, h2, . . . , hn are optimistic, we can combine them into a single dominant heuristic that will also be optimistic: h(s) = max h1(s), h2(s), . . . , hn(s) 3 Using sub-problem costs I pattern database containing precomputed true costs for a number of sub-problems 4 Learning heuristics I use of machine learning. E.g., learning of coefficients w1 and w2: h(s) = w1x1(s) + w2x2(s), where x1 are x2 state describing features Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 31 / 41
  • 32. Outline 1 Heuristics 2 Greedy best-first search and hill-climbing search 3 A* algorithm 4 Heuristics revisited 5 Example: Path-finding on a terrain map Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 32 / 41
  • 33. Lab assignment: Path-finding on a terrain map Write a program that uses the A* algorithm to find the optimal path between two points on a given terrain map. Let ∆a = a(x2, y2) − a(x1, y1) be the altitude difference. You can move from (x1, y1) to (x2, y2) if |x1 − x2| ≤ 1, |y1 − y2| ≤ 1 and ∆a ≤ m. The cost of moving from position (x1, y1) to position (x2, y2) is p (x2 − x1)2 + (y2 − y1)2 + 1 2 sgn(∆a) + 1 · |∆a| The program should read the map and the parameters from a specified file. It should generate an image of the height map with clearly indicated closed nodes, open nodes and the path found. The program should also print out the length of the path found and the number of iterations of the algorithm. You should propose at least three different heuristics and try them out on the map. Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 33 / 41
  • 34. Path-finding on a terrain map (1) Terrain map (brighter pixels correspond to positions at higher altitudes) red: initial state; green: goal state Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 34 / 41
  • 35. Path-finding on a terrain map (2) Uniform cost search (red: path found; yellow: states visited) number of closed nodes: 140580; path length: 740.58 Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 35 / 41
  • 36. Path-finding on a terrain map (3) A* algorithm (heuristics: air distance) number of closed nodes: 64507; path length: 740.58 Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 36 / 41
  • 37. Path-finding on a terrain map (4) A* algorithm (heuristics: air distance + 1 2 ∆a) number of closed nodes: 56403; path length: 740.58 Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 37 / 41
  • 38. Path-finding on a terrain map (5) A* algorithm (heuristics: air distance + |∆a|) number of closed nodes: 52099; path length: 755.16 This heuristic is not optimistic! Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 38 / 41
  • 39. Path-finding on a terrain map (6) Greedy best-first search (heuristics: air distance; with visited states list) number of closed nodes: 822; path length: 1428.54 Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 39 / 41
  • 40. Outline 1 Heuristics 2 Greedy best-first search and hill-climbing search 3 A* algorithm 4 Heuristics revisited 5 Example: Path-finding on a terrain map Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 40 / 41
  • 41. Wrap-up Heuristic function guides the search, making it more efficient Heuristic function estimates the distance between the given state and the goal state. The smaller the distance, the closer we are to the goal state Heuristic should be optimistic, it may be consistent, and it should be informed as much as possible in order to make the search even more efficient Best-first and hill-climbing algorithms are greedy and therefore not optimal A* search is both complete and optimal Next topic: Game playing Dalbelo Bašić, Šnajder (UNIZG FER) AI – Heuristic search AY 2019/2020 41 / 41