Search Problems and Blind Search Techniques
Total Page:16
File Type:pdf, Size:1020Kb
Set 2: State-spaces and Uninformed Search ICS 271 Fall 2016 Kalev Kask 271-fall 2016 You need to know • State-space based problem formulation – State space (graph) • Search space – Nodes vs. states – Tree search vs graph search • Search strategies • Analysis of search algorithms – Completeness, optimality, complexity – b, d, m 271-fall 2016 Goal-based agents Goals provide reason to prefer one action over the other. We need to predict the future: we need to plan & search Problem-Solving Agents • Intelligent agents can solve problems by searching a state-space • State-space Model – 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 • Goal State(s) – a goal is defined as a desirable state for an agent – there may be many states which satisfy the goal • e.g., drive to a town with a ski-resort – or just one state which satisfies the goal • e.g., drive to Mammoth • Operators(actions) – operators are legal actions which the agent can take to move from one state to another 271-fall 2016 Example: Romania 271-fall 2016 Example: Romania • On holiday in Romania; currently in Arad. • Flight leaves tomorrow from Bucharest • Formulate goal: – be in Bucharest • Formulate problem: – states: various cities – actions: drive between cities • Find solution: – sequence of actions (cities), e.g., Arad, Sibiu, Fagaras, Bucharest 271-fall 2016 Problem Types • Static / Dynamic Previous problem was static: no attention to changes in environment • Observable / Partially Observable / Unobservable Previous problem was observable: it knew its initial state. • Deterministic / Stochastic Previous problem was deterministic: no new percepts were necessary, we can predict the future perfectly • Discrete / continuous Previous problem was discrete: we can enumerate all possibilities 271-fall 2016 State-Space Problem Formulation 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 2016 State-Space Problem Formulation • A statement of a Search problem has components – 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 solution consists of – a sequence of operators which transform S into a goal state G • Representing real problems in a State-Space search framework – may be many ways to represent states and operators – key idea: represent only the relevant aspects of the problem (abstraction) 271-fall 2016 Abstraction/Modeling • Definition of Abstraction (states/actions) – Process of removing irrelevant detail to create an abstract representation: ``high-level”, ignores irrelevant details • Navigation Example: how do we define states and operators? – First step is to abstract “the big picture” • i.e., solve a map problem • nodes = cities, links = freeways/roads (a high-level description) • this description is an abstraction of the real problem – Can later worry about details like freeway onramps, refueling, etc • Abstraction is critical for automated problem solving – 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 2016 Robot block world • Given a set of blocks in a certain configuration, • Move the blocks into a goal configuration. • Example : – ((A)(B)(C)) (ACB) A A B C C B 271-fall 2016 Operator Description 271-fall 2016 The State-Space Graph • Problem formulation: State-space: 1. A set of states – Give an abstract description of states, 2. A set of “operators”/transitions operators, initial state and goal state. 3. A start state S • Graphs: 4. A set of possible goal states 5. Cost path – vertices, edges(arcs), directed arcs, paths • State-space graphs: – States are vertices – operators are directed arcs – solution is a path from start to goal • Problem solving activity: – Generate a part of the search space that contains a solution 271-fall 2016 Example: vacuum world • Observable, start in #5. Solution? 15 Example: vacuum world • Observable, start in #5. Solution? [Right, Suck] 16 Vacuum world state space graph 5 17 Example: vacuum world • Unobservable, start in {1,2,3,4,5,6,7,8} e.g., Solution? 18 Example: vacuum world • Unobservable, start in {1,2,3,4,5,6,7,8} e.g., Solution? [Right,Suck,Left,Suck] 19 20 The Traveling Salesperson Problem • Find the shortest tour that visits all cities without visiting any city twice and return to starting point. • State: – sequence of cities visited • S0 = A C B A D F E 271-fall 2016 The Traveling Salesperson Problem • Find the shortest tour that visits all cities without visiting any city twice and return to starting point. • State: sequence of cities visited • S0 = A C • Solution = a complete tour B A D Transition model F {a,c,d} {(a,c,d, x) | X a,c,d} E 271-fall 2016 Example: 8-queen problem 271-fall 2016 Example: 8-Queens • states? -any arrangement of n<=8 queens -or arrangements of n<=8 queens, 1 per column, such that no queen attacks any other (BETTER), -or arrangements of n<=8 queens in leftmost n columns, 1 per column, such that no queen attacks any other (BEST) • initial state? no queens on the board • actions? -add queen to any empty column -or add queen to leftmost empty column such that it is not attacked by other queens. • goal test? 8 queens on the board, none attacked. • path cost? 1 per move 271-fall 2016 The Sliding Tile Problem move(x,loc y,loc z) Up Down Left Right 271-fall 2016 The “8-Puzzle” Problem Start State 1 2 3 4 6 7 5 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 Goal State Example: robotic assembly • states?: real-valued coordinates of robot joint angles parts of the object to be assembled • actions?: continuous motions of robot joints • goal test?: complete assembly • path cost?: time to execute 271-fall 2016 new Formulating Problems; Another Angle • Problem types – Satisfying: 8-queen – Optimizing: Traveling salesperson • For traveling salesperson satisfying easy, optimizing hard • Goal types – board configuration – sequence of moves – A strategy (contingency plan) • Satisfying leads to optimizing since “small is quick” • For traveling salesperson – satisfying easy, optimizing hard • Semi-optimizing: – Find a good solution • In Russel and Norvig: – single-state, multiple states, contingency plans, exploration problems 271-fall 2016 Summary so far • Problem state space formulation – states, initial state, goal state(s)/test – actions, transition function • Abstraction • Search as exploration of the state space graph – tree search (no memory) vs graph search (memory) • States vs nodes; node implementation • Basic search scheme • Q : we transformed original problem to path finding on state-space graph; why not apply shortest path finding algorithms? 271-fall 2016 Searching the State Space • Exploration of the state space – states, operators – by generating successors of already explored states (aka expanding states) • Trial and error : pick on possible extension of some path, leaving others aside for the time being. • Control strategy (how to pick a node to expand) generates a search tree. • Systematic search – Do not leave any stone unturned • Efficiency – Do not turn any stone more than once 271-fall 2016 Tree search example 271-fall 2016 Tree search example 271-fall 2016 Tree search example 271-fall 2016 State-Space Graph of the 8 Puzzle Problem 271-fall 2016 Implementation • States vs Nodes – 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 • The Expand function creates new nodes, filling in the various fields and using the SuccessorFn of the problem to create the corresponding states. • Queue managing frontier : – FIFO – LIFO – priority 271-fall 2016 Tree-Search vs Graph-Search • Tree-search(problem), returns a solution or failure • Frontier initial state • Loop do – 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 – ----------------------------------------------------------------------------------------------- • Graph-search(problem), returns a solution or failure • Frontier initial state, explored empty • Loop do – 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 2016 Basic search scheme • We have 3 kinds of states – explored (past) – only graph search – frontier (current) – unexplored (future) – implicitly given • Initially frontier=start state • Loop until found solution or exhausted state space – pick/remove first node from frontier using search strategy • priority queue – FIFO (BFS), LIFO (DFS), g (UCS), f (A*), etc. – check if goal – add this node to explored, – expand this node, add children to frontier (graph search : only those children whose state is not in explored/frontier list) – Q: what if better path is found to a node already on explored list? 271-fall 2016 Graph-Search 271-fall 2016 Tree-Search vs.