Announcements Survey about recita)on )mes will be posted - - PowerPoint PPT Presentation
Announcements Survey about recita)on )mes will be posted - - PowerPoint PPT Presentation
Introduc)on to Ar)ficial Intelligence Lecture 2 Uninformed Search CS/CNS/EE 154 Andreas Krause TexPoint fonts used in EMF. Announcements Survey
Announcements ¡
Survey ¡about ¡recita)on ¡)mes ¡will ¡be ¡posted ¡today ¡ Please ¡check ¡website ¡for ¡updates ¡
2 ¡
Agents ¡and ¡environments ¡
Agents: ¡Alice, ¡Poker ¡player, ¡Robo ¡recep)onist, ¡… ¡
Agent ¡maps ¡sequence ¡of ¡percepts ¡to ¡ac)on ¡ Implemented ¡as ¡algorithm ¡running ¡on ¡physical ¡architecture ¡
Environment ¡maps ¡sequence ¡of ¡ac)ons ¡to ¡percept ¡
3 ¡
Example: ¡Vacuum ¡cleaning ¡robot ¡
Percepts ¡P ¡= ¡{[A,Clean], ¡[A,Dirty], ¡[B,Clean], ¡[B,Dirty]} ¡ Ac)ons ¡A ¡= ¡{Le], ¡Right, ¡Suck, ¡NoOp} ¡ Agent ¡func)on: ¡ Example: ¡ ¡
4 ¡
Modeling ¡the ¡environment ¡
Set ¡of ¡states ¡S ¡(not ¡necessarily ¡finite) ¡ State ¡transi)ons ¡depend ¡on ¡current ¡state ¡and ¡ac)ons ¡
(can ¡be ¡stochas)c ¡or ¡nondeterminis)c) ¡
5 ¡
Ra)onality: ¡Performance ¡evalua)on ¡
Fixed ¡performance ¡measure ¡
evaluates ¡environment ¡seq. ¡
For ¡example: ¡
One ¡point ¡for ¡each ¡clean ¡square ¡a]er ¡10 ¡rounds? ¡ Time ¡it ¡takes ¡un)l ¡all ¡squares ¡clean? ¡ One ¡point ¡per ¡clean ¡square ¡per ¡round, ¡minus ¡one ¡point ¡per ¡move ¡
Goal: ¡find ¡agent ¡func)on ¡(program) ¡to ¡maximize ¡
performance ¡
6 ¡
Environment ¡types ¡
Sudoku ¡ Poker ¡ Spam ¡Filter ¡ Taxi ¡ Observable? ¡ Determinis>c? ¡ Episodic? ¡ Sta>c? ¡ Discrete? ¡ Single-‑agent? ¡
7 ¡
Simple ¡reflex ¡agent ¡
¡Ac)on ¡only ¡func)on ¡of ¡last ¡percept ¡
8 ¡
Example ¡
9 ¡
Will ¡never ¡stop ¡(noop), ¡since ¡we ¡can’t ¡remember ¡state ¡ This ¡is ¡a ¡fundamental ¡problem ¡of ¡simple ¡reflex ¡agents ¡in ¡
par)ally ¡observable ¡environments! ¡
Percept ¡ Ac>on ¡ [A,dirty] ¡ Suck ¡ [B,dirty] ¡ Suck ¡ [A,clean] ¡ Right ¡ [B,clean] ¡ Le] ¡
Reflex ¡agent ¡with ¡state ¡
¡Ac)on ¡func)on ¡of ¡percept ¡and ¡internal ¡state ¡
10 ¡
Example ¡
State ¡vars: ¡cleanA ¡= ¡cleanB ¡= ¡false ¡
11 ¡
Percept ¡ cleanA ¡ cleanB ¡ Ac>on ¡ State ¡change ¡ [X,dirty] ¡ ? ¡ ? ¡ Suck ¡ cleanX ¡= ¡true ¡ [A,clean] ¡ ? ¡ true ¡ NoOp ¡ [A,clean] ¡ ? ¡ false ¡ Right ¡ cleanA ¡= ¡true ¡ [B,clean] ¡ true ¡ ? ¡ NoOp ¡ [B,clean] ¡ false ¡ ? ¡ Le] ¡ cleanB ¡= ¡true ¡
? ¡means ¡“don’t ¡care” ¡
Goal-‑based ¡agents ¡
12 ¡
Search ¡
“Get ¡from ¡state ¡A ¡to ¡B ¡as ¡quickly ¡as ¡possible” ¡ A ¡fundamental ¡problem ¡in ¡many ¡AI ¡problems ¡
Naviga)on, ¡VLSI ¡layout, ¡resource ¡alloca)on, ¡planning, ¡… ¡
For ¡now ¡assume ¡
Fully ¡observable ¡environment ¡and ¡determinis)c ¡ac)ons ¡
13 ¡
Path ¡planning ¡in ¡Romania ¡
Travel ¡from ¡Arad ¡to ¡Bucharest ¡ Cost: ¡Length ¡of ¡path ¡
14 ¡
Search ¡with ¡goal ¡based ¡agents ¡
Agent ¡has ¡ ¡
model ¡of ¡environment ¡(map, ¡puzzle ¡rules, ¡mechanics,…) ¡
How ¡will ¡the ¡environment ¡change ¡if ¡I ¡do ¡X? ¡
Goal ¡checker: ¡
Declares ¡some ¡environment ¡states ¡as ¡goals ¡
Performance ¡measure: ¡
Sum ¡of ¡ac)on ¡costs ¡ If ¡all ¡ac)ons ¡cost ¡the ¡same ¡this ¡is ¡called ¡unit ¡cost ¡model ¡
Agent ¡func)on: ¡
Find ¡cheapest ¡sequence ¡of ¡ac)ons ¡to ¡get ¡to ¡a ¡goal ¡state ¡
15 ¡
Example: ¡Vacuum ¡
In ¡unit ¡cost ¡model, ¡op)mal ¡solu)on ¡is: ¡
16 ¡
Goals ¡ Start ¡state ¡
State ¡spaces ¡
Vacuum ¡robot: ¡ ¡8 ¡states ¡ Rubik’s ¡cube: ¡
¡10^19 ¡states… ¡
Climbing ¡stairs: ¡ ¡∞ ¡states! ¡ Cannot ¡represent ¡search ¡graph ¡explicitly! ¡ Implicit ¡representa)on: ¡
Successor ¡func)ons ¡maps ¡states ¡to ¡set ¡of ¡(ac)on,state) ¡pairs ¡ Specifies ¡which ¡states ¡can ¡be ¡reached ¡immediately ¡from ¡any ¡
given ¡state ¡
17 ¡
Example: ¡8 ¡Puzzle ¡
Swap ¡)les ¡to ¡
- rder ¡pieces ¡
Cost: ¡#moves ¡ States: ¡config’s ¡ Successor ¡fn: ¡
18 ¡
State ¡space ¡representa)on ¡
Place ¡8 ¡queens ¡that ¡don’t ¡auach ¡
each ¡other. ¡
States: ¡(par)al) ¡board ¡configura)ons ¡ Successor ¡func)ons ¡(ac)ons): ¡
19 ¡
Tree ¡search ¡
Basic ¡algorithm ¡for ¡search ¡problems ¡ Organize ¡possible ¡sequences ¡into ¡a ¡tree ¡ Expand ¡tree ¡one ¡node ¡at ¡a ¡)me ¡
20 ¡
Nodes ¡in ¡tree ¡search ¡
21 ¡
Tree ¡search ¡in ¡Romania ¡
22 ¡
General ¡tree ¡search ¡
¡func>on ¡treeSearch(problem,strategy) ¡ ¡Ini)alize ¡tree ¡with ¡ini)al ¡state ¡of ¡problem ¡ ¡Repeat ¡ ¡If ¡no ¡leaf ¡node ¡available ¡for ¡expansion ¡then ¡Fail ¡ ¡Use ¡strategy ¡to ¡select ¡leaf ¡node ¡for ¡expansion ¡ ¡If ¡node ¡contains ¡a ¡goal ¡state ¡then ¡return ¡corresponding ¡solu)on ¡ ¡Else ¡expand ¡the ¡node ¡and ¡add ¡resul)ng ¡nodes ¡to ¡search ¡tree ¡
23 ¡
Implementa)on ¡of ¡general ¡search ¡
Maintain ¡fringe ¡of ¡unexpanded ¡nodes ¡
Typically ¡implemented ¡as ¡some ¡form ¡of ¡queue ¡(FIFO, ¡LIFO, ¡…) ¡ Expanding ¡a ¡node ¡means ¡inser)ng ¡successor ¡states ¡into ¡fringe ¡
24 ¡
Fringe ¡= ¡[Sibiu, ¡Timisoara, ¡Zerind] ¡
Implementa)on: ¡Tree ¡search ¡
25 ¡
Quality ¡of ¡a ¡search ¡strategy ¡
¡Completeness ¡
Does ¡it ¡always ¡find ¡a ¡solu)on ¡if ¡one ¡exists? ¡
¡Time ¡complexity ¡
Number ¡of ¡nodes ¡expanded ¡
¡Space ¡complexity ¡
Maximum ¡size ¡of ¡the ¡queue ¡(fringe) ¡
¡Op)mality ¡
Does ¡it ¡always ¡find ¡the ¡op)mal ¡solu)on ¡if ¡one ¡exists? ¡
¡Time/space ¡complexity ¡measured ¡as ¡
b: ¡maximum ¡branching ¡factor ¡ d: ¡depth ¡of ¡least-‑cost ¡solu)on ¡ m: ¡maximum ¡depth ¡of ¡tree ¡
26 ¡
Informed ¡vs. ¡uninformed ¡search ¡
Uninformed ¡search ¡
Can ¡only ¡dis)nguish ¡goals ¡from ¡non-‑goal ¡states ¡ Topic ¡of ¡this ¡lecture ¡
Informed ¡search ¡
Have ¡informa)on ¡about ¡progress ¡towards ¡the ¡op)mal ¡solu)on ¡ Can ¡dras)cally ¡improve ¡)me ¡complexity ¡ Next ¡lecture ¡
27 ¡
Breadth-‑first ¡search ¡(BFS) ¡
Strategy: ¡fringe ¡implemented ¡as ¡a ¡FIFO ¡queue ¡ Expands ¡shallowest ¡unexpanded ¡node ¡
28 ¡
Proper)es ¡of ¡Breadth ¡first ¡search ¡
Complete? ¡ Time ¡complexity? ¡ Space ¡complexity? ¡ Op)mal? ¡
¡Memory ¡usage ¡is ¡o]en ¡prohibi)ve! ¡
29 ¡
Uniform ¡cost ¡search ¡
Expand ¡least ¡cost ¡node ¡ Implementa)on: ¡ ¡
Fringe ¡is ¡cost-‑ordered ¡queue ¡(priority ¡queue) ¡
Equivalent ¡to ¡BFS ¡in ¡the ¡unit ¡cost ¡case ¡ Complete? ¡ Time ¡complexity? ¡ Space ¡complexity? ¡ Op)mal? ¡
30 ¡
Depth ¡first ¡search ¡(DFS) ¡
Strategy: ¡fringe ¡implemented ¡as ¡a ¡LIFO ¡queue ¡ Expands ¡deepest ¡unexpanded ¡node ¡
31 ¡
Proper)es ¡of ¡Depth ¡first ¡search ¡
Complete? ¡ Time ¡complexity? ¡ Space ¡complexity? ¡ Op)mal? ¡
¡Not ¡op)mal! ¡Fails ¡in ¡graphs ¡with ¡loops! ¡ ¡
32 ¡
Depth-‑limited ¡search ¡
Try ¡to ¡fix ¡DFS ¡by ¡imposing ¡depth ¡limit ¡ Implementa)on: ¡Do ¡not ¡expand ¡nodes ¡with ¡depth ¡> ¡l ¡ Complete? ¡ Time ¡complexity? ¡ Space ¡complexity? ¡ Op)mal? ¡
33 ¡
Itera)ve ¡deepening ¡
Itera)vely ¡use ¡depth-‑limited ¡search ¡with ¡increasing ¡depth ¡
34 ¡
Itera)ve ¡deepening ¡
Itera)vely ¡use ¡depth-‑limited ¡search ¡with ¡increasing ¡depth ¡
35 ¡
Itera)ve ¡deepening ¡
Itera)vely ¡use ¡depth-‑limited ¡search ¡with ¡increasing ¡depth ¡
36 ¡
Itera)ve ¡deepening ¡
Itera)vely ¡use ¡depth-‑limited ¡search ¡with ¡increasing ¡depth ¡
37 ¡
Proper)es ¡of ¡itera)ve ¡deepening ¡
Complete? ¡ Time ¡complexity? ¡ Space ¡complexity? ¡ Op)mal? ¡
38 ¡
Bidirec)onal ¡search ¡
Idea: ¡start ¡BFS ¡from ¡ ¡
start ¡and ¡end ¡state ¡ ¡ (only ¡possible ¡if ¡ ¡ end ¡state ¡is ¡known!) ¡
39 ¡
Proper)es ¡of ¡bidirec)onal ¡search ¡
Complete? ¡ Time ¡complexity? ¡ Space ¡complexity? ¡ Op)mal? ¡
40 ¡
Comparison ¡with ¡algorithms ¡
41 ¡
Strategy ¡
BFS ¡ Uniform ¡ cost ¡ DFS ¡ Itera>ve ¡ deepening ¡
- Bidirect. ¡
Complete ¡ Yes* ¡ Yes* ¡ No ¡ Yes ¡ Yes ¡ Time ¡ bd+1 ¡ bC/ε ¡ bm ¡ bd ¡ bd/2 ¡ Space ¡ bd+1 ¡ bC/ε ¡ b ¡m ¡ b ¡d ¡ bd/2 ¡ Op>mal ¡ Yes* ¡ Yes ¡ No ¡ Yes* ¡ Yes* ¡
Repeated ¡states ¡
Repeated ¡states ¡can ¡lead ¡to ¡exponen)al ¡increase ¡in ¡
complexity ¡
Remedy: ¡Remember ¡states ¡already ¡visited ¡
42 ¡
Graph ¡Search ¡
43 ¡
Graph ¡search ¡example ¡
Uniform ¡cost ¡search ¡on ¡graphs ¡also ¡known ¡as ¡
Dijkstra’s ¡algorithm ¡
44 ¡
Search ¡in ¡con)nuous ¡domains ¡
45 ¡
Configura)ons ¡
46 ¡
Probabilis)c ¡roadmap ¡
Sample ¡points ¡in ¡free ¡(feasible) ¡space ¡ Form ¡search ¡graph ¡on ¡these ¡sampled ¡points ¡ Can ¡get ¡probabilis)c ¡guarantees ¡for ¡completeness ¡ ¡
47 ¡