Presentation is loading. Please wait.

Presentation is loading. Please wait.

Problem-solving agents

Similar presentations


Presentation on theme: "Problem-solving agents"— Presentation transcript:

1 Problem-solving agents
Formalizing problems: Goals, states and actions The search tree Uninformed search Breadth first Depth first

2 The 8-puzzle Initial state Goal state
State: the location of each tiles in one of the nine squares Actions: move the blank up or down or left or rigth Path-cost: every action costs 1, so the path cost is the number of actions performed

3 The eight queens Goal: 8 queens on the checkboard, none attacked
Problem: put 8 queens on the checkboard so that no queen attacks any other The eight queens Goal: 8 queens on the checkboard, none attacked Path-cost: 0 1 States: any arrangement of 0 to 8 queens on board Operators: add a queen 2 States: arrangements of 0 to 8 queens with none attacked Operators: place a queen in the left-most empty column such that it is not attacked by any other queen 3 States: arrangements of 0 to 8 queens, one in each column Operators: move any attached queen to another square in the same column

4 Example: a driving problem
Problem: Your agent is in A and you have program it to drive to E Example: a driving problem A B D E C F What do we need to formalize the problem? We call state the description of the world from the point of view of the agent The set of possible actions that the agent can perform to change the state The goal is the state that has to be reached by the agent The initial state that the agent knows itself to be in at the beginning The path-cost is how much the solution costs

5 Level of abstraction Example of formalization of the driving problem:
State: the town in which the agent is Only one possible action: drive to a neighbor town Initial state: “A” Goal: “E” Path-cost: the distance covered to reach “E” from “A”

6 More complex conditions
State: the town in which the agent is, the weather, the fuel Action: Wait the weather gets better, drive to a neighbor town, stop at a petrol station Initial state: “A”, “cloudy”, “no fuel” Goal: “E”,”Sunny” Path-cost: the distance covered to reach “E” from “A” plus the amount of rain fallen on the car plus fuel consumed

7 The search tree The search tree is a description of the search process
The root node corresponds to the initial state The leaf are states without successors They cannot be expanded: no action can be performed in the corresponding state They correspond to (one of) the goal(s) The nodes of the state space can be repeated in the search tree: Loc=A = Initial Loc= B Loc= C Loc= D Loc= F Loc= E = Goal Loc= B

8 How to explore the state space, i.e. How to build the search tree?
Search Strategies How to explore the state space, i.e. How to build the search tree? Strategies are evaluated on: Completeness: it is guaranteed to find a solution (if there is one)? Time Complexity: How long does it take? Space complexity: How much memory does it need? Optimality: does it find the best solutions when there are more than one?

9 Informed and Uninformed search
Uninformed search (blind search): no information about the “distance” from the current state to the goal is available. Every action is equally good Informed search (heuristic search): there are ways to estimate the “distance” from the current node to the goal, and they are used to drive the search

10 Breadth First Search 1 2 3 Time complexity:
1 2 3 Time complexity: If the goal has depth d, i.e. the goal has a path length of d, the number of steps is: Where b is the branching factor, i.e. the max number of “sons” of a node in the search tree Space complexity (size of the list nodes): Only the leaf nodes are stored in memory

11 Depth First Search 1 2 3 Time complexity:
1 2 3 Time complexity: Space complexity (size of the list nodes):

12 BFS vs DFS Completeness Space and Time Complexity:
BFS is always complete DFS can fail to reach the goal when the search tree has infinite depth Space and Time Complexity: For problems that have many solutions, DFS can be faster than BFS For problems with high branching factor, BFS runs out memory

13 DFS: Depth Limited Search
If the state-space contains cycles DFS can fail to found a solution (infinite depth tree) If we know a bound, say l, to the longest path from the initial state to a goal, we can explore only the paths shorter than l Example: how long can be the longest path in the driving problem?

14 Informed Search: Best-First Search
An evaluation function applies to each node and returns a number representing the “desirability” of exapanding that node Best-First Search: always expand the node with the best evaluation The best first search strategies differ on the definitions of the evaluation function


Download ppt "Problem-solving agents"

Similar presentations


Ads by Google