Young Wu July 25, 2019pages.cs.wisc.edu/~yw/CS540/CS540_Lecture_18_P.pdf · 2019. 7. 25. · Young...

Post on 12-May-2021

5 views 0 download

Transcript of Young Wu July 25, 2019pages.cs.wisc.edu/~yw/CS540/CS540_Lecture_18_P.pdf · 2019. 7. 25. · Young...

Informed Search UCS and Greedy A

CS540 Introduction to Artificial IntelligenceLecture 18

Young WuBased on lecture slides by Jerry Zhu, Yingyu Liang, and Charles

Dyer

July 26, 2021

Informed Search UCS and Greedy A

Uniformed vs. Informed SearchMotivation

Uninformed search means only the goal G and the successorfunctions s 1 are given.

Informed search means which non-goal states are better is alsoknown.

Informed Search UCS and Greedy A

HeuristicMotivation

The additional information is usually given as a heuristic costfrom a state s to the goal.

The cost of the path from the start to a vertex s in thefrontier is g psq.

The cost from s to the goal, h� psq, is estimated by h psq.This estimate may not be accurate.

h psq � h� psq

Informed Search UCS and Greedy A

Heuristic DiagramMotivation

Informed Search UCS and Greedy A

Uniform Cost SearchDescription

Expand the vertices with the lowest current path cost g psqfirst.

It is BFS with a priority queue based on g psq.

It is equivalent to BFS if c � 1 is constant on all edges.

It is also called Dijkstra’s Algorithm.

Informed Search UCS and Greedy A

Uniform Cost Search Maze ExampleDefinition

Informed Search UCS and Greedy A

Uniform Cost Search Simple ExampleDefinition

Informed Search UCS and Greedy A

Uniform Cost SearchAlgorithm

Input: a weighted digraph pV ,E , cq, initial states I and goalstates G .

Output: a path from I to G .

EnQueue initial states into a priority queue Q. Here, Q isordered by g psq for s P Q.

Q � I

While Q is not empty and goal is not deQueued, deQueue Qand enQueue its successors.

s � Qp0q � arg minsPQ

g psq

Q � Q � s 1 psq

Informed Search UCS and Greedy A

Uniform Cost Search PerformanceDiscussion

UCS is complete.

UCS is optimal with any c .

Informed Search UCS and Greedy A

Best First Greedy SearchDescription

Expand the vertices with the lowest heuristic cost h psq first.

Use a priority queue based on h psq.

Informed Search UCS and Greedy A

Greedy Search Maze ExampleDefinition

Informed Search UCS and Greedy A

Greedy Search Simple ExampleDefinition

Informed Search UCS and Greedy A

Best First Greedy SearchAlgorithm

Input: a weighted digraph pV ,E , cq, initial states I and goalstates G , and the heuristic function h psq , s P V .

Output: a path from I to G .

EnQueue initial states into a priority queue Q. Here, Q isordered by h psq for s P Q.

Q � I

While Q is not empty and goal is not deQueued, deQueue Qand enQueue its successors.

s � Qp0q � arg minsPQ

h psq

Q � Q � s 1 psq

Informed Search UCS and Greedy A

Best First Greedy Search PerformanceDiscussion

Greedy is incomplete.

Greedy is not optimal.

Informed Search UCS and Greedy A

A SearchDescription

Expand the vertices with the lowest total cost g psq � h psqfirst.

Use a priority queue based on g psq � h psq.

A stands for Always be optimistic?

Informed Search UCS and Greedy A

A Search Maze ExampleDefinition

Informed Search UCS and Greedy A

A Search Simple Example 1Definition

Informed Search UCS and Greedy A

A Search Simple Example 2Definition

Informed Search UCS and Greedy A

A Search Simple Example 3Definition

Informed Search UCS and Greedy A

A SearchAlgorithm

Input: a weighted digraph pV ,E , cq, initial states I and goalstates G , and the heuristic function h psq , s P V .

Output: a path from I to G .

EnQueue initial states into a priority queue Q. Here, Q isordered by g psq � h psq for s P Q.

Q � I

While Q is not empty and goal is not deQueued, deQueue Qand enQueue its successors.

s � Qp0q � arg minsPQ

g psq � h psq

Q � Q � s 1 psq

Informed Search UCS and Greedy A

A Search PerformanceDiscussion

A is complete.

A is not optimal.

Informed Search UCS and Greedy A

A Star SearchDescription

A� search is A search with an admissible heuristic.

Informed Search UCS and Greedy A

Admissible HeuristicDefinition

A heuristic is admissible if it never over estimates the truecost.

0 ¤ h psq ¤ h� psq

Informed Search UCS and Greedy A

Admissible Heuristic 8 Puzzle ExampleDefinition

Informed Search UCS and Greedy A

Dominated HeuristicDefinition

One heuristic, h1, is dominated by another, h2, if:

h1 psq ¤ h2 psq ¤ h� psq , @ s P S

If h2 dominates h1, then h2 is better than h1 since A� using h1expands at least as many states (or more) than A� using h2.

If h2 dominated h1,A� with h2 is better informed than A�

with h1.

Informed Search UCS and Greedy A

Non-Optimal HeuristicDefinition

If optimality is not required and a satisfying solution isacceptable, then the heuristic should be as close as possible,either under or over, to the actual cost.

This results in fewer states being expanded compared to usingpoor but admissible heuristics.

Informed Search UCS and Greedy A

Admissible Heuristic 8 Puzzle ExampleQuiz

Which ones (select multiple) of the following are admissibleheuristic function for the 8 Puzzle?

A: h psq � number of tiles in the wrong position.

B: h psq � 0.

C: h psq � 1.

D: h psq � sum of Manhattan distance between each tile andits goal location.

E: h psq � sum of Euclidean distance between each tile and itsgoal location.

Informed Search UCS and Greedy A

A Star Search with Revisit, Part IAlgorithm

Input: a weighted digraph pV ,E , cq, initial states I and goalstates G , and the heuristic function h psq , s P V .

Output: a path with minimum cost from I to G .

EnQueue initial states into a priority queue Q. Here, Q isordered by g psq � h psq for s P Q.

Q � I

g pI q � 0

g psq � 8, for s R I

Initialize the list of visited vertices, P.

P � H

Informed Search UCS and Greedy A

A Star Search with Revisit, Part IIAlgorithm

While Q is not empty and goal is not deQueued, deQueue Q,put it on P and enQueue its successors to Q, and update thecost functions.

s � Qp0q � arg minsPQ

g psq � h psq

P � P � s

Q � Q � s 1 psq , update g�s 1�� min

g�s 1�, g psq � c

�s, s 1

�(

Informed Search UCS and Greedy A

A Search PerformanceDiscussion

A� is complete.

A� is optimal.

Informed Search UCS and Greedy A

Iterative Deepening A Star SearchDiscussion

A� can use a lot of memory.

Do path checking without expanding any vertex withg psq � h psq ¡ 1.

Do path checking without expanding any vertex withg psq � h psq ¡ 2.

...

Do path checking without expanding any vertex withg psq � h psq ¡ d .

Informed Search UCS and Greedy A

Iterative Deepening A Star Search PerformanceDiscussion

IDA� is complete.

IDA� is optimal.

IDA� is more costly than A�.

Informed Search UCS and Greedy A

Beam SearchDiscussion

Version 1: Keep a priority queue with fixed size k . Only keepthe top k vertices and discard the rest.

Version 2: Only keep the vertices that are at most ε worsethan the best vertex in the queue. ε is called the beam width.

Informed Search UCS and Greedy A

Beam Search PerformanceDiscussion

Beam is incomplete.

Beam is not optimal.