Download State Space Representations and Search Algorithms in Artificial Intelligence and more Slides Artificial Intelligence in PDF only on Docsity!
State Space Representa,ons
and Search Algorithms
CS171, Fall 2016
Introduc,on to Ar,ficial Intelligence
Prof. Alexander Ihler
Reading: R&N 3.1-3.
Architectures for Intelligence
- Search?
- Determine how to achieve some goal; “what to do”
- Logic & inference?
- Reason about what to do
- Encode knowledge / “expert” systems
- Know what to do
- Learning?
- Modern view: complex & mul,-faceted
Why search?
- Engaged in bigger, important problem
- Hit a search subproblem we need to solve
- Search, solve it, get back to original problem
- Predict the results of our ac,ons in the future
- Many sequences of ac,ons, each with some u,lity
- Maximize performance measure
- Want to achieve some goal by some (any?) means
- Or, find the best (op,mal) way to achieve it
Example: Romania
- On holiday in Romania
- Currently in Arad
- Flight leaves tomorrow from Bucharest
- Formulate goal:
- Formulate problem:
- States: various ci,es
- Ac,ons: drive between ci,es / choose next city
- Find a solu,on:
- Sequence of ci,es, e.g.: Arad, Sibiu, Fagaras, Bucharest
Problem types
Classifying the environment:
- Sta,c / Dynamic Previous problem was sta,c: no aaen,on to changes in environment
- Determinis,c / Stochas,c Previous problem was determinis,c: no new percepts were necessary, we can predict the future perfectly
- Observable / Par,ally Observable / Unobservable Previous problem was observable: it knew the ini,al state, &c
- Discrete / Con,nuous Previous problem was discrete: we can enumerate all possibili,es
Why not Dijkstra’s Algorithm?
- D’s algorithm inputs the en,re graph
- Want to search in unknown spaces
- Combine search with “explora,on”
- Ex: autonomous rover on Mars must search an unknown space
- D’s algorithm takes connec,ons as given
- Want to search based on agent’s ac,ons, w/ unknown connec,ons
- Ex: web crawler may not know what connec,ons are available on a URL before visi,ng it
- Ex: agent may not know the result of an ac,on before trying it
- D’s algorithm won’t work on infinite spaces
- Many ac,ons spaces are infinite or effec,vely infinite
- Ex: logical reasoning space is infinite
- Ex: real world is essen,ally infinite to a human-size agent
Vacuum world state space graph R R L L R R L L R L R L R L L R S S S S S S S S
Ex: Vacuum World
- Unobservable, start in {1,2,3,4,5,6,7,8}
- Solu,on? [Right, Suck, Le[, Suck]
State-Space Problem Formula,on A problem is defined by four items: ini5al state e.g., "at Arad“ ac5ons Ac#ons(s) = set of ac,ons avail. in state s transi5on model Results(s,a) = state that results from ac,on a in states Alt: successor func,on S(x) = set of ac,on–state pairs
- e.g., S(Arad) = { , … } goal test , (or goal state) e.g., x = "at Bucharest”, Checkmate(x) path cost (addi,ve)
- e.g., sum of distances, number of ac,ons executed, etc.
- c(x,a,y) is the step cost, assumed to be ≥ 0 A solu5on is a sequence of ac,ons leading from the ini,al state to a goal state 86 98 142 92 87 90 85 101 211 138 146 97 (^75120) 70 111 118 140 151 71 75 Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Sibiu (^) Fagaras Rimnicu Vilcea Pitesti Cralova Bucharest Giurgiu Urziceni Neamt Iasi Vaslui Hirsova Eforie 99 80
Selec,ng a state space
- Real world is absurdly complex à state space must be abstracted for problem solving
- (Abstract) state ß set of real states
- (Abstract) ac,on ß complex combina,on of real ac,ons
- e.g., "Arad à Zerind" represents a complex set of possible routes, detours, rest stops, etc.
- For guaranteed realizability, any real state "in Arad” must get to some real state "in Zerind”
- (Abstract) solu,on ß set of real paths that are solu,ons in the real world
- Each abstract ac,on should be "easier" than the original problem
Ex: 8-Queens
Place as many queens as possible on the chess board without capture
- states? - any arrangement of n<=8 queens
- or arrangements of n<=8 queens in le[most n columns, 1 per column, such that no queen aaacks any other.
- ini,al state? no queens on the board
- ac,ons? - add queen to any empty square
- or add queen to le[most empty square such that it is not aaacked by other queens.
- goal test? 8 queens on the board, none aaacked.
- path cost? 1 per move
Ex: 8-Queens
Place as many queens as possible on the chess board without capture
- states? - any arrangement of n<=8 queens
- or arrangements of n<=8 queens in le[most n columns, 1 per column, such that no queen aaacks any other.
- ini,al state? no queens on the board
- ac,ons? - add queen to any empty square
- or add queen to le[most empty square such that it is not aaacked by other queens.
- goal test? 8 queens on the board, none aaacked.
- path cost? 1 per move (not relevant…)
Ex: Sliding ,le puzzle
- states?
- ini,al state?
- ac,ons?
- goal test?
- path cost? 2 8 3 1 5 4 7 6 1 2 3 4 8 6 7 5 Start State Goal State Try it yourselves…
Ex: Sliding ,le puzzle
- states? Loca,ons of ,les
- ini,al state? Given
- ac,ons? Move blank square up / down / le[ / right
- goal test? Goal state (given)
- path cost? 1 per move 2 8 3 1 5 4 7 6 1 2 3 4 8 6 7 5 Start State Goal State
of states: n+1! / 2
8-puzzle: 181,440 states 15-puzzle: 1.3 trillion 24-puzzle: 10^ Optimal solution of n-Puzzle family is NP-hard