Download presentation

Presentation is loading. Please wait.

Published byHeather Gordon Modified about 1 year ago

1
CSC 423 ARTIFICIAL INTELLIGENCE Solving Problems by Searching

2
2 Problem Solving as State-Space Search Consider finite problems that can be represented in terms of: an initial state, one or more goal states, and a set of operators to transform the system from one state to another. Solving the problem may correspond to: either reaching a goal state or finding the best (or at least an acceptable) sequence of operations to reach a goal state.

3
3 SOLVING PROBLEMS BY SEARCHING A goal-based agent aims at solving problems by performing actions that lead to desirable states Let us first consider the uninformed situation in which the agent is not given any information about the problem other than its definition In blind search only the structure of the problem to be solved is formulated The agent aims at reaching a goal state The world is static, discrete, and deterministic

4
4 Blind Search Systematic exploration of a search tree, making non use of knowledge about the particular problem. Depth-first search: Search used by the Prolog interpreter. Simple to implement, but may get stuck in an infinite branch and fail to find a goal state inanother branch. May not find shortest route to goal. Breadth-first search: Visit all states at one level before moving on to the next. Will inevitably find a shortest route to a goal state, but requires a large amount of memory.

5
5 Depth-First Search When the nodes of a search tree are expanded in preorder, the tree gets searched in depth-first order The deepest node in the current fringe of the search tree becomes expanded When one branch from the root to a leaf has been explored, the search backs up to the next shallowest node that still has unexplored successors Depth-first search has very modest memory requirements It needs to store only a single path from the root to a leaf node, along with the remaining unexpanded sibling nodes for each node on the path Depth-first search requires storage of only bm+1 nodes

6
6 Depth-First Search (Cont)

7
7 Depth-First Search Algorithm

8
8 Depth-First Search Algorithm (Cont)

9
9 Breadth-First Search When the nodes of the search tree are traversed in level- order, the tree gets searched in breadth-first order All nodes at a given depth are expanded before any nodes at the next level are expanded Suppose that the solution is at depth d In the worst case we expand all but the last node at level d Every node that is generated must remain in memory, because it may belong to the solution path Let b be the branching factor of the search This the worst-case time and space complexities are b + b2 + … + bd + ( bd+1 – b ) = O(bd+1)

10
10 Breadth-First Search (Cont)

11
11 Breadth-First Search Algorithm To search for an answer-path do create a queue containing a single path consisting of the initial state, and apply the breadth-first procedure to expand this queue until an answer-path is found. To expand a queue do if any path in the queue has reached a goal state then return that path as an answer-path else expand the first path of the queue in all possible ways creating a list of the resulting paths, append the list of extended paths to the end of the queue, remove the first path from the queue, and continue to expand the new queue

12
12 Breadth-First Search Algorithm (Cont) To expand a path in all possible ways and create a list of the resulting paths do collect all paths S + path, where S is an extended state of path, into a list

13
13 The Wolf, Goat and Cabbage Problem A farmer and his wolf, goat, and cabbage come to the north side of a river that they wish to cross. There is a boat, but it has only room for two, and the farmer is the only one that can row. If the goat and the cabbage are left alone together, the goat will eat the cabbage. Similarly, if the wolf and the goat are together without the farmer, the goat will be eaten. Devise a series of crossings of the river so that all concerned make it across safely.

14
14 The Wolf, Goat and Cabbage Problem (Cont) Initial State: Wolf, goat, cabbage and farmer are on the north side of the river. Goal State: Wolf, goat, cabbage and farmer are on the south side of the river. Operators: Farmer can move one thing at a time across the river in the boat, or he can cross alone. But the goat cannot be left alone with the cabbage or with the wolf.

15
15 Heuristic Search The use of heuristics, based on knowledge of the problem, improves the efficiency of a search process by providing a control strategy. Its effect is to prune the search tree. Heuristics are ‘rules of thumb’. They often provide a good solution but not necessarily the best: they are approximations and are not guaranteed to be right. They may even lead to a dead end. Heuristics may just be incorporated in operations (e.g. ‘In this state, such-and-such is likely to be a sensible action…’). More usefully we calculate a heuristic evaluation function, which estimates the ‘value’ of a possible next state.

16
16 Informed (Heuristic) Search Strategies We now consider informed search that uses problem-specific knowledge beyond the definition of the problem itself This information helps to find solutions more efficiently than an uninformed strategy The information concerns the regularities of the state space An evaluation function f(n) determines how promising a node n in the search tree appears to be for the task of reaching the goal Best-first search chooses to expand the node that appears by evaluation function to be most promising the among the candidates Traditionally, one aims at minimizing the value of function f

17
17 Informed (Heuristic) Search Strategies (Cont) A key component of an evaluation function is a heuristic function h(n), which estimates the cost of the cheapest path from node n to a goal node In connection of a search problem “heuristics” refers to a certain (but loose) upper or lower bound for the cost of the best solution Goal states are nevertheless identified: in a corresponding node n it is required that h(n) = 0 E.g., a certain lower bound — bringing no information — would be to set h(n) 0 Heuristic functions are the most common form in which additional knowledge is imported to the search algorithm

18
18 Evaluation Functions An evaluation function maps a problem state to a numeric value, which measures the ‘desirability’ of that state relative to the problem to be solved; the smallest the value for a state, the more desirable it is. Which aspects of the problem state are considered, how these are evaluated, and how much weight is given to each one, are chosen in such a way that the value of the function at a given node in the search tree gives as good an estimate as possible of whether that node is on the path to a solution. Examples: Chess: Material advantage of the player. Route-finding: Distance from destination.

19
19 Best-First Search Algorithm To search for an answer-path do start with a list containing just the initial state and its value, and apply the best-first procedure to expand this path-list until an answer-path is found. To expand a path-list with best-first search do if the first path in the list has reached a goal state then return that path as an answer-path else expand the first path in the list in all possible ways, creating a list of the resulting paths ordered in increasing value of the last state in each path, then merge this list with the list of the remaining paths to get a new ordered list, and continue to expand the new list

20
20 Optimality of A* The best-path, or A*, search algorithm uses a combined heuristic function as follows: For each node state n in the search tree, let - g(n) be the cost of reaching that node, i.e. the sum of the costs of each step in the path to the node (exact), and - h'(n) be the value of the evaluation function at node n (estimate). Then A* search minimises the combined function ƒ(n) where, ƒ(n) = g(n) + h'(n). It turns out that if the evaluation function h'(n) satisfies certain conditions, A* search is both complete and optimal.

21
21 Optimality of A* (Cont)

22
22 Developing Search Trees To develop a search tree, start at the initial state and carry out the search algorithm, only adding states to the tree when they are reached by path expansion under the algorithm. Do not include any repeated states on a given path through the tree. (States can of course be duplicated on different paths.) Stop the tree development, on a goal state, only when the algorithm would finish (which is not necessarily the first goal state found).

23
23 Developing Search Trees for Heuristic Algorithms In the case of heuristic search algorithms, the developed tree illustrates how the algorithm in question prunes back the search tree. In order to develop the search tree of a given heuristic algorithm based on breadth-first, you need to create a table showing the path list considered by that algorithm at each point of time, together with the list generated by the expansion of each path. The paths in the resulting lists should also include their value and/or cost

24
24 Problem Characteristics The problem-solving approach may depend on the characteristics of the problem in question: Decomposable? Recovery possible from bad steps? Predictable universe? Obvious which is good solution? Is desired solution a state or a path? Does solving the problem require a large amount of knowledge? Human help needed?

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google