Set 2: State-spaces and Uninformed Search
ICS 271 Fall 2018 Kalev Kask
271-fall 2018
Set 2: State-spaces and Uninformed Search ICS 271 Fall 2018 Kalev - - PowerPoint PPT Presentation
Set 2: State-spaces and Uninformed Search ICS 271 Fall 2018 Kalev Kask 271-fall 2018 You need to know State-space based problem formulation State space (graph) Search space Nodes vs. states Tree search vs graph search
271-fall 2018
271-fall 2018
Goals provide reason to prefer one action over the other. We need to predict the future: we need to plan & search
– the agent’s model of the world – usually a set of discrete states – e.g., in driving, the states in the model could be towns/cities
– a goal is defined as a desirable state for an agent – there may be many states which satisfy the goal
– or just one state which satisfies the goal
– operators are legal actions which the agent can take to move from
271-fall 2018
271-fall 2018
– be in Bucharest
– states: various cities – actions: drive between cities
– sequence of actions (cities), e.g., Arad, Sibiu, Fagaras, Bucharest
271-fall 2018
Previous problem was static: no attention to changes in environment
Previous problem was observable: it knew its initial state.
Previous problem was deterministic: no new percepts were necessary, we can predict the future perfectly
Previous problem was discrete: we can enumerate all possibilities
271-fall 2018
A problem is defined by five items: states e.g. cities initial state e.g., "at Arad“ actions or successor function S(x) = set of action–state pairs
– e.g., S(Arad) = {<Arad Zerind, Zerind>, … }
transition function - maps action & state state goal test, (or goal state) e.g., x = "at Bucharest”, Checkmate(x) path cost (additive)
– e.g., sum of distances, number of actions executed, etc. – c(x,a,y) is the step cost, assumed to be ≥ 0
A solution is a sequence of actions leading from the initial state to a goal state
271-fall 2018
– 1. States – 2. A start state S – 3. A set of operators/actions which allow one to get from one state to another – 4. transition function – 5. A set of possible goal states G, or ways to test for goal states – 6. Cost path
– a sequence of operators which transform S into a goal state G
– may be many ways to represent states and operators – key idea: represent only the relevant aspects of the problem (abstraction)
271-fall 2018
– Process of removing irrelevant detail to create an abstract representation: ``high-level”, ignores irrelevant details
– First step is to abstract “the big picture”
– Can later worry about details like freeway onramps, refueling, etc
– must create an approximate, simplified, model of the world for the computer to deal with: real-world is too detailed to model exactly – good abstractions retain all important details – an abstraction should be easier to solve than the original problem
271-fall 2018
– ((A)(B)(C)) (ACB)
A C B
271-fall 2018
A B C
271-fall 2018
– Give an abstract description of states,
– vertices, edges(arcs), directed arcs, paths
– States are vertices – operators are directed arcs – solution is a path from start to goal
– Generate a part of the search space that contains a solution
State-space:
271-fall 2018
15
16
17
5
18
19
20
C D A E F B
271-fall 2018
C D A E F B
Transition model
271-fall 2018
271-fall 2018
such that no queen attacks any other (BETTER),
columns, 1 per column, such that no queen attacks any other (BEST)
it is not attacked by other queens.
271-fall 2018
Up Down Left Right
271-fall 2018
1 2 3 4 8 6 7 5 1 2 3 4 5 6 7 8 Goal State Start State 1 2 3 4 8 6 7 5
new
271-fall 2018
– Satisfying: 8-queen – Optimizing: Traveling salesperson
– board configuration – sequence of moves – A strategy (contingency plan)
– satisfying easy, optimizing hard
– Find a good solution
– single-state, multiple states, contingency plans, exploration problems
271-fall 2018
– states, operators
– by generating successors of already explored states (aka expanding states)
aside for the time being.
– Do not leave any stone unturned
– Do not turn any stone more than once
271-fall 2018
271-fall 2018
271-fall 2018
271-fall 2018
271-fall 2018
– A state is a (representation of) a physical configuration – A node is a data structure constituting part of a search tree contains info such as: state, parent node, action, path cost g(x), depth
using the SuccessorFn of the problem to create the corresponding states.
– FIFO – LIFO – priority
271-fall 2018
– If frontier is empty return failure – Choose a leaf node and remove from frontier – If the node is a goal, return the corresponding solution – Expand the chosen node, adding its children to the frontier –
– If frontier is empty return failure – Choose a leaf node and remove from frontier – If the node is a goal, return the corresponding solution. – Add the node to the explored. – Expand the chosen node, adding its children to the frontier, only if not in frontier or explored set
271-fall 2018
271-fall 2018
271-fall 2018
– number of states 25 = 32 – number of edges (25)∙5∙½ = 80
– number of nodes 5! = 120
– 11010 can be reached a+b+d or a+d+b etc.
– three kinds of nodes : unexplored, frontier, explored – before adding a node, check if a state is in frontier or explored set
271-fall 2018
271-fall 2018
– the size of the tree – the shape of the tree – the depth of the goal states
– say there is a constant branching factor b – and one goal exists at depth d – search tree which includes a goal can have bd different branches in the tree (worst case)
– b = 2, d = 10: bd = 210= 1024 – b = 10, d = 10: bd = 1010= 10,000,000,000
271-fall 2018
– Breadth-first – Uniform-Cost first – Depth-first – Iterative deepening depth-first – Bidirectional – Depth-First Branch and Bound
– Greedy search, hill climbing, Heuristics
– Completeness : does it always find a solution if one exists ? – Time complexity (b, d, m) – Space complexity (b, d, m) – Quality of solution : optimality = does it always find best solution?
271-fall 2018
– completeness: does it always find a solution if one exists? – time complexity: number of nodes generated – space complexity: maximum number of nodes in memory – optimality: does it always find a least-cost solution?
– b: maximum branching factor of the search tree – d: depth of the least-cost solution – m: maximum depth of the state space (may be ∞)
43
Is A a goal state?
271-fall 2018
Expand: frontier = [B,C] Is B a goal state?
Expand: frontier=[C,D,E] Is C a goal state?
271-fall 2018
Expand: frontier=[D,E,F,G] Is D a goal state?
271-fall 2018
271-fall 2018
Actually, in BFS we can check if a node is a goal node when it is generated (rather than expanded)
– If child is not in CLOSED or OPEN, then – If child is not a goal, then put them at the end of OPEN in some order.
from n to s.
* This is graph-search
OPEN = frontier, CLOSED = explored
271-fall 2018
S = start, G = goal, other nodes = intermediate states, links = legal transitions
271-fall 2018
Note: this is the search tree at some particular point in in the search. S G A B D E C F E Not expanded by graph-search
271-fall 2018
– assume (worst case) that there is 1 goal leaf at the RHS – so BFS will expand all nodes = 1 + b + b2+ ......... + bd = O (bd)
– how many nodes can be in the queue (worst-case)? – at depth d there are bd unexpanded nodes in the Q = O (bd) d=0 d=1 d=2 d=0 d=1 d=2 G G
271-fall 2018
Depth of Nodes Solution Expanded Time Memory 1 1 millisecond 100 bytes 2 111 0.1 seconds 11 kbytes 4 11,111 11 seconds 1 megabyte 8 108 31 hours 11 giabytes 12 1012 35 years 111 terabytes Assuming b=10, 1000 nodes/sec, 100 bytes/node
271-fall 2018
1 3 7 15 14 13 12 11 10 9 8 4 5 6 2 271-fall 2018
Requirement g(successor)(n)) g(n)
271-fall 2018
271-fall 2018
tracing back pointers from n to s.
them pointers back to n, and put them in OPEN in order of shortest cost
At step 4: compute the cost of the solution found and update the upper bound U. At step 5: expand n, generating all its successors attach to them
pointers back to n, and put on top of OPEN. Compute cost of partial path to node and prune if larger than U. .
271-fall 2018
Is A a goal state?
271-fall 2018
queue=[B,C] Is B a goal state?
271-fall 2018
queue=[D,E,C] Is D = goal state?
271-fall 2018
queue=[H,I,E,C] Is H = goal state?
271-fall 2018
queue=[I,E,C] Is I = goal state?
271-fall 2018
queue=[E,C] Is E = goal state?
271-fall 2018
queue=[J,K,C] Is J = goal state?
271-fall 2018
queue=[K,C] Is K = goal state?
271-fall 2018
queue=[C] Is C = goal state?
271-fall 2018
queue=[F,G] Is F = goal state?
271-fall 2018
queue=[L,M,G] Is L = goal state?
271-fall 2018
queue=[M,G] Is M = goal state?
271-fall 2018
Here, (if tree-search) then to avoid infinite depth (in case of finite state-space graph) assume we don’t expand any child node which appears already in the path from the root S to the parent. (Again,
S G A B D E C F
271-fall 2018
271-fall 2018
271-fall 2018
and put them at the top of OPEN in some order.
*search the tree search-space (but avoid self-loops) ** the default assumption is that DFS searches the underlying search-tree
271-fall 2018
– assume d is deepest path in the search space – assume (worst case) that there is 1 goal leaf at the RHS – so DFS will expand all nodes =1 + b + b2+ ......... + bd = O (bd)
– how many nodes can be in the queue (worst-case)? – O(bd) if deepest node at depth d
d=0 d=1 d=2 G d=0 d=1 d=2 d=3 d=4
271-fall 2018
271-fall 2018
271-fall 2018
small search space
271-fall 2018
Iterative deepening (ID)
1. i = 1 2. While no solution, do 3. DFS from initial state S0 with cutoff i 4. If found goal, stop and return solution, else, increment cutoff
Comments:
271-fall 2018
Iterative deepening search L=0
271-fall 2018
Iterative deepening search L=1
271-fall 2018
Iterative deepening search L=2
271-fall 2018
Iterative Deepening Search L=3
271-fall 2018
271-fall 2018
) ( 2 ) 1 ( 2 1 1 1 1
) (
n
b O b n b n j b j b
n T
BFS time is O(bn), b is the branching degree IDS is asymptotically like BFS, For b=10 d=5 d=cut-off DFS = 1+10+100,…,=111,111 IDS = 123,456 Ratio is
1 b b
271-fall 2018
271-fall 2018
– simultaneously search forward from S and backwards from G – stop when both “meet in the middle” – need to keep track of the intersection of 2 open sets of nodes
– need a way to specify the predecessors of G
– what if there are multiple goal states? – what if there is only a goal test, no explicit list?
– time complexity is best: O(2 b(d/2)) = O(b (d/2)) – memory complexity is the same
271-fall 2018
271-fall 2018
271-fall 2018
– a search space consists of nodes and operators: it is a tree/graph
– breadth-first – depth-first – iterative deepening – bidirectional search – Uniform cost search – Depth-first branch and bound
– we looked at methods for detecting repeated states
how far away the goal may be: next we will look at informed or heuristic search, which directly tries to minimize the distance to the goal.
271-fall 2018