Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial.

Similar presentations


Presentation on theme: "1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial."— Presentation transcript:

1 1 Using Search in Problem Solving Part II

2 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial to the target state Operators/rules to get from one state to another All states - search space We search for a path / sequence of operators to go from the initial state to the goal state

3 3 Search methods Basic (uninformed): Basic (uninformed): breadth-first breadth-first depth-first depth-first Heuristic (informed): Heuristic (informed): hill climbing, hill climbing, best-first, best-first, A* A*

4 4 Heuristic Search Heuristic search is used to reduce the search space. Basic idea: explore only promising states/paths. We need an evaluation function to estimate each state/path.

5 5 Hill climbing Basic idea: always head towards a state which is better than the current one. There is no exhaustive search, so no node list is maintained. If a solution is found, it is found for a very short time and with minimum memory requirements. However it is not guaranteed that a solution will be found - the local maxima problem.

6 6 Hill Climbing - Algorithm Start with current-state = initial-state. Until current-state = goal-state OR there is no change in current-state do: Get the successors of the current state and use the evaluation function to assign a score to each successor. If one of the successors has a better score than the current-state then set the new current-state to be the successor with the best score.

7 7 Hill Climbing Node list is not maintained Node list is not maintained No problems with loops as we move to a better node No problems with loops as we move to a better node If a solution is found, it is found for a very short time with minimal memory requirements If a solution is found, it is found for a very short time with minimal memory requirements Finding a solution is not guaranteed – the local maxima problem Finding a solution is not guaranteed – the local maxima problem

8 8 Best First Search The node with the best score is chosen to be expanded. Works in breadth-first manner, keeps a data structure (called agenda, based on priority queues) of all successors and their scores. If a node that has been chosen does not lead to a solution, the next "best" node is chosen, so eventually the solution is found Always finds a solution, not guaranteed to be the optimal one.

9 9 Best First Search Algorithm 1.Start with agenda = [initial-state]. 2.While agenda is not empty do A. Pick the best node on agenda. B. If it is the goal node then return with success. Otherwise find its successors. C. Assign the successor nodes a score using the evaluation function and add the scored nodes to the agenda

10 10 Comparison with hill-climbing Similarities: best-first always chooses the best node Difference: best-first search keeps an agenda as in breadth-first search, and in case of a dead end it will backtrack, choosing the next- best node.

11 11 Beam Search Best-first method Best-first method Expands the best few paths at each level Expands the best few paths at each level Has the memory advantages of the depth- first search Has the memory advantages of the depth- first search Not exhaustive and may not find the best solution. Finding a solution is not guaranteed Not exhaustive and may not find the best solution. Finding a solution is not guaranteed

12 12 The A* Algorithm An evaluation function that accounts for - the cost of the paths - the score of the nodes F(Node) = g(Node) + h(Node) g(Node) - the costs from the initial state to the current node h(Node) - future costs, i.e. node score Disadvantage of A* is the memory requirement - the algorithm keeps records for the entire tree.

13 13 The A* Algorithm A* always finds the best solution, provided that h(Node) does not overestimate the future costs.

14 14 Example 10 7 8 8 4 4 6 9 2 4 A B: 9 D : 10 F : 6 H : 5 C: 8 E: 7 K: 5 2 G: 0 J: 4 Start: A Goal: G

15 15 Search and Problem-solving Generate and Test Generate and Test Means-end analysis in planning Means-end analysis in planning work out the path backwards work out the path backwards use rules with preconditions and effects use rules with preconditions and effects the target goal is the effect of some operator/rule the target goal is the effect of some operator/rule set the conditions as subgoals to be achieved set the conditions as subgoals to be achieved Minimax algorithm in games, Minimax algorithm in games, Alpha-Beta pruning Alpha-Beta pruning Constraint satisfaction Constraint satisfaction

16 16 Planning Techniques Means-Ends analysis Initial state, Goal state, intermediate states. Operators to change the states. Each operator: Preconditions Effects Go backwards : from the goal to the initial state.

17 17 Basic Algorithm Put the goal state in a list of subgoals While the list is not empty, do Take a subgoal. Is there an operation that has as an effect this goal state? If no - the problem is not solvable. If yes, put the operation in the plan. Are the preconditions fulfilled? If yes - we have constructed the plan If no - Put the preconditions in the list of subgoals

18 18 More complex problems Goal state - a set of sub-states Each sub-state is a goal. To achieve the target state we have to achieve each goal in the Target state.

19 19 Extensions of the basic method Planning with goal protection Planning with goal protection Nonlinear planning Nonlinear planning Hierarchical planning Hierarchical planning Reactive planning Reactive planning

20 20 Game Playing Systems Special feature of games: there is an opponent that tries to destroy our plans. The search tree (game tree) has to reflect the possible moves of both players

21 21 Player1 Player2 Player1

22 22 Minimax procedure Minimax procedure Scoring the final nodes: Winning : 10 Draw : 0 Loosing : -10 Each player is trying to maximize their score and minimize the score of the other player. The levels in the tree for player P1 are maximizing if it is P1's move, and minimizing if it is P2's move.

23 23 Minimax algorithm Minimax algorithm Build the search tree. Assign scores to the leaves Assign scores to intermediate nodes: If node is a leaf of the search tree - return score of that node Else: If it is a maximizing node return maximum of scores of the successor nodes Else if it is a minimizing node - return minimum of scores of the successor nodes After that, choose nodes with highest score

24 24 Alpha-Beta Pruning At maximizing level the score is at least the score of any successor. At minimizing level the score is at most the score of any successor.

25 25 A:10 B:10C: 0 E:10F:10G: 0H:10 I:10J: 0K:10L:-10M:-10N:0O:10P:-10 Maximizing score Minimizing score P1's move P2's move P1's minimax tree

26 26 Constraint satisfaction search State description: a set of variables. A set of constraints on the assigned values of variables. Each variable may be assigned a value within its domain, and the value must not violate the constraints. Initial state - the variables do not have values Goal state: Variables have values and the constraints are obeyed.

27 27 Constraint satisfaction search Different types of constraints: Different types of constraints: unary - on one variable only unary - on one variable only binary - on two variables, etc. binary - on two variables, etc.

28 28 Example WEEK LOAN WEEK + LOAN + WEEK LOAN WEEK ----------------- ----------------- DEBT MONTH

29 29 Example - continued The problem is to assign a digit to each letter, with different letters being different digits, so that when the letters are replaced by the digits, the addition is done correctly. Initially no letters have values. The goal state would be an assignment of values so that the addition is correct. Operators: assign a digit to a letter, so that no two different digits have same values, and the addition rules are not violated.


Download ppt "1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial."

Similar presentations


Ads by Google