Presentation on theme: "Solving problems by searching"— Presentation transcript:
1Solving problems by searching Chapter 3Image source: Wikipedia
2Types of agents Reflex agent Planning agent Consider how the world IS Choose action based on current percept (and maybe memory or a model of the world’s current state)Do not consider the future consequences of their actionsConsider how the world WOULD BEDecisions based on (hypothesized) consequences of actionsMust have a model of how the world evolves in response to actionsMust formulate a goal (test)Can a reflex agent be rational?Source: D. Klein, P. Abbeel
3SearchWe will consider the problem of designing goal-based agents in fully observable, deterministic, discrete, known environmentsStart stateGoal state
4SearchWe will consider the problem of designing goal-based agents in fully observable, deterministic, discrete, known environmentsThe agent must find a sequence of actions that reaches the goalThe performance measure is defined by (a) reaching the goal and (b) how “expensive” the path to the goal isWe are focused on the process of finding the solution; while executing the solution, we assume that the agent can safely ignore its percepts (open-loop system)
5Search problem components Initial stateActionsTransition modelWhat state results from performing a given action in a given state?Goal statePath costAssume that it is a sum of nonnegative step costsThe optimal solution is the sequence of actions that gives the lowest path cost for reaching the goalInitialstateGoal state
6Example: Romania On vacation in Romania; currently in Arad Flight leaves tomorrow from BucharestInitial stateAradActionsGo from one city to anotherTransition modelIf you go from city A to city B, you end up in city BGoal stateBucharestPath costSum of edge costs (total distance traveled)
7State spaceThe initial state, actions, and transition model define the state space of the problemThe set of all states reachable from initial state by any sequence of actionsCan be represented as a directed graph where the nodes are states and links between nodes are actionsWhat is the state space for the Romania problem?
8Example: Vacuum world States Agent location and dirt location How many possible states?What if there are n possible locations?The size of the state space grows exponentially with the “size” of the world!ActionsLeft, right, suckTransition model
10Example: The 8-puzzleStatesLocations of tiles8-puzzle: 181,440 states15-puzzle: ~10 trillion states24-puzzle: ~1025 statesActionsMove blank left, right, up, downPath cost1 per moveFinding the optimal solution of n-Puzzle is NP-hard
11Example: Robot motion planning StatesReal-valued joint parameters (angles, displacements)ActionsContinuous motions of robot jointsGoal stateConfiguration in which object is graspedPath costTime to execute, smoothness of path, etc.
12Search Given: How do we find the optimal solution? Initial stateActionsTransition modelGoal statePath costHow do we find the optimal solution?How about building the state space and then using Dijkstra’s shortest path algorithm?Complexity of Dijkstra’s is O(E + V log V), where V is the size of the state spaceThe state space may be huge!
13Search: Basic ideaLet’s begin at the start state and expand it by making a list of all possible successor statesMaintain a frontier or a list of unexpanded statesAt each step, pick a state from the frontier to expandKeep going until you reach a goal stateTry to expand as few states as possible
14… Search tree “What if” tree of sequences of actions and outcomes The root node corresponds to the starting stateThe children of a node correspond to the successor states of that node’s stateA path through the tree corresponds to a sequence of actionsA solution is a path ending in the goal stateNodes vs. statesA state is a representation of the world, while a node is a data structure that is part of the search treeNode has to keep pointer to parent, path cost, possibly other info…Starting stateSuccessor stateActionGoal state
15Tree Search Algorithm Outline Initialize the frontier using the starting stateWhile the frontier is not emptyChoose a frontier node to expand according to search strategy and take it off the frontierIf the node contains the goal state, return solutionElse expand the node and add its children to the frontier
23Handling repeated states Initialize the frontier using the starting stateWhile the frontier is not emptyChoose a frontier node to expand according to search strategy and take it off the frontierIf the node contains the goal state, return solutionElse expand the node and add its children to the frontierTo handle repeated states:Keep an explored set; add each node to the explored set every time you expand itEvery time you add a node to the frontier, check whether it already exists in the frontier with a higher path cost, and if yes, replace that node with the new one
24Search without repeated states Start: AradGoal: Bucharest
25Search without repeated states Start: AradGoal: Bucharest
26Search without repeated states Start: AradGoal: Bucharest
27Search without repeated states Start: AradGoal: Bucharest
28Search without repeated states Start: AradGoal: Bucharest
29Search without repeated states Start: AradGoal: Bucharest
30Search without repeated states Start: AradGoal: Bucharest