Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
An initial state is the description of the starting configuration of the agent. An action or an operator takes the agent from one state to another state which is called a successor state. A plan is a sequence of actions. The cost of a plan is referred to as the path cost. It is a positive number. Search is the process of considering various possible sequences of operators applied to the initial state, and finding out a sequence which culminates in a goal state.
3
So A search problem consists of the following: S: the full set of states S0 : the initial state A:SS is a set of operators G is the set of final states. (G S). This sequence of actions is called a solution plan. A sequence of states is called a path.
A search problem is represented using a directed graph. The states are represented as nodes. The allowed actions are represented as arcs. 4
Legal moves can be described by a set of rules. State space is a set of legal positions.
Steps for solution :
Starting at the initial state. Using the set of rules to move from one state to
another.
State: (x, y)
x = 0, 1, 2, 3, or 4 y = 0, 1, 2, 3
2.
3. 4. 5. 6. 7. 8. 9.
(x, y)
(x, y) (x, y) (x, y) (x, y) (x, y) (x, y) (x, y)
(x, 3)
(x (x, y (0, y) (x, 0) (4, y (x (x (0, x (2, 0) (0, y) (3 y, 0) y) (4 x)) y), 3) d, y) d)
if y
if x if y if x if y if x if x if x if x
3
0 0 0 0 y y y y 4, y 3, x 4, y 3, x 0 0 0 0
10
11
Explicit vs Implicit state space The state space may be explicitly represented by a graph. But more typically the state space can be implicitly represented and generated when required. To generate the state space implicitly, the agent needs to know: The initial state. The operators and a description of the effects of the operators.
12
Search Strategies
Requirements of a good search strategy:
1. It causes motion: Otherwise, it will never lead to a solution.
13
States generated are nodes. We also maintain a list of nodes called the fringe. The successors of the current expanded node are put in fringe.
14
Evaluating Search strategies: Generally these are evaluated by the following criterias. 1. Completeness: Is the strategy guaranteed to find a solution if one exists?
2. Optimality: Does the solution have low cost or the minimal cost?
3. What is the search cost associated with the time and memory required to find a solution? a. Time complexity: Time taken (number of nodes expanded) (worst or average case) to find a solution. b. Space complexity: Space used by the algorithm measured in terms of the maximum size of 16 fringe.
Having no information about the number of steps from the current state to the goal.
17
Search Tree
Consider the explicit state space graph shown in the figure.
The corresponding search tree is: Start from initial state and list all possible paths.
18
Data structure of a Node: A node contains the following: A state description A pointer to the parent of the node Depth of the node The operator that generated this node Cost of this path (sum of operator costs from the start state) The nodes that the algorithm has generated are kept in 19 the a data structure called OPEN or fringe. Initially only start node is in OPEN.
The search process constructs a search tree, where root is the initial state and leaf nodes are nodes not yet expanded (i.e., in fringe) or having no successors (i.e., dead-ends) Each of these nodes a partial solution path. Search tree may be infinite because of loops even if state space is small. The search problem will return as a solution a path to a goal node or the goal node itself. Like path finding in solving 15-puzzle. Like the N-queens problem for which the path to the solution is not important. In case of large state space, it becomes impractical to represent state space.
So state space makes explicit a sufficient portion of implicit 20 state space graph to find a goal node.
Search problem representation: S: set of states. Initial state S0 S. A:SS`, An action moves from one state to another state S` Search Problem: {S, s0, A,G} A plan is a sequence of actions. P={a0, a1, a2, . . . an}. Leading to traversal of several states {S0,S1,S2. . . .SN+1 G } 21
Note that in breadth first search the newly generated nodes are put at the back of fringe. It expands the shallowest node first.
22
Put by Dijkstra [1959]. The algorithm expands nodes in the order of their cost from the source. The newly generated nodes are put in FRINGE / OPEN according to their path costs. This ensures that when a node is selected for expansion it is the node with cheapest cost . If g(n) = cost of the path from the start node to the current node n, then sort nodes by increasing value of g. Properties of this search algorithm are: Complete Optimal/Admissible Exponential time and space complexity, O(bd)
24
25
75
X 140 118
26
X X
140 118
27
X X
140
229
28
29
The incompleteness of DFS can be taken care if depth is made limited. Here, Nodes are only expanded if they have depth less than the bound.
31
If we fix the depth initially, it might happen that goal may not fall within it, So. First do DFS to depth 0 (i.e., treat start node as having no successors), then, if no solution found, do DFS to depth 1, etc.
32
If branching factor is b and solution is at depth d, then nodes at depth d are generated once and nodes at depth d-1 are generated twice etc. Hence bd+2b(d-1)++db=bd/(1-1/b)2=O(bd) Linear space complexity is O(bd). Has advantage of BFS i.e. complete Has advantage of DFS i.e. limited space and finds longer paths more quickly. Requires linear memory. Generally used in large state space with solution depth unknown.
33
Bi-directional search
Consider that the search problem is such that the arcs are bidirectional. Such that, if there is an operator that maps from state A to state B, there is another operator that maps from state B to state A. Many search problems have reversible arcs, such as 8-puzzle, 15-puzzle, path planning etc. However the water jug problem is a problem that does not have this property. But if the arcs are reversible, we can instead of starting from the start state and searching for the goal, we may start from a goal state and try reaching the start state. If there is a single state that satisfies the goal property, the search problems are identical. 34
35
S A B C 11 D 14 E D E A B B D E F
Forward Backwards
C 17
A 15
C 15
G 13
G 19
C G 19 17
F
G 25
36
d d/2 d/2
37
Problems:
If more than one goal. How do we search backwards from goal? One should be able to generate predecessor states. Predecessors of node n are all the nodes that have n as successor.
Algorithm: Bidirectional search involves alternate searching from the start state toward the goal and from the goal state toward the start. The algorithm stops when the frontiers intersect. For Bi-directional search to work better, there should be an efficient way to check whether a node belongs to another tree. Select an algorithm for each half, can sometime lead to find solution faster. 38
Summary of algorithms
39