![Page 1: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/1.jpg)
1
Using Search in Using Search in Problem SolvingProblem Solving
Part IIPart II
![Page 2: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/2.jpg)
2
Basic ConceptsBasic ConceptsBasic 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
![Page 3: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/3.jpg)
3
Search methodsSearch methods
Basic (uninformed):Basic (uninformed): breadth-firstbreadth-first depth-firstdepth-first
Heuristic (informed): Heuristic (informed): hill climbing, hill climbing, best-first, best-first, A*A*
![Page 4: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/4.jpg)
4
Heuristic SearchHeuristic 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.
![Page 5: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/5.jpg)
5
Hill climbingHill 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.
![Page 6: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/6.jpg)
6
Hill Climbing - AlgorithmHill 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.
![Page 7: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/7.jpg)
7
Hill ClimbingHill Climbing
Node list is not maintainedNode list is not maintained No problems with loops as we move No problems with loops as we move
to a better nodeto a better node If a solution is found, it is found for a If a solution is found, it is found for a
very short time with minimal very short time with minimal memory requirementsmemory requirements
Finding a solution is not guaranteed – Finding a solution is not guaranteed – the the local maxima problemlocal maxima problem
![Page 8: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/8.jpg)
8
Best First SearchBest 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.
![Page 9: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/9.jpg)
9
Best First Search Best First Search AlgorithmAlgorithm
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
![Page 10: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/10.jpg)
10
Comparison with hill-Comparison with hill-climbingclimbing
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.
![Page 11: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/11.jpg)
11
Beam SearchBeam Search
Best-first methodBest-first method
Expands the best few paths at each Expands the best few paths at each levellevel
Has the memory advantages of the Has the memory advantages of the depth-first searchdepth-first search
Not exhaustive and may not find the Not exhaustive and may not find the best solution. Finding a solution is best solution. Finding a solution is not guaranteednot guaranteed
![Page 12: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/12.jpg)
12
The A* AlgorithmThe A* AlgorithmAn 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.
![Page 13: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/13.jpg)
13
The A* AlgorithmThe A* Algorithm
A* always finds the best
solution, provided that
h(Node) does not
overestimate the future
costs.
![Page 14: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/14.jpg)
14
Example
107
8
8
4
4
6
10
92
4
A
B: 9D : 10
F : 6
H : 5
C: 8E: 7
K: 5
2
G: 0
J: 4 Start: A
Goal: G
![Page 15: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/15.jpg)
15
Search and Problem-Search and Problem-solvingsolving
Generate and TestGenerate and Test Means-end analysis in planningMeans-end analysis in planning
work out the path backwardswork out the path backwards use rules with preconditions and effectsuse rules with preconditions and effects the target goal is the effect of some operator/rulethe target goal is the effect of some operator/rule set the conditions as subgoals to be achievedset the conditions as subgoals to be achieved
Minimax algorithm in games,Minimax algorithm in games, Alpha-Beta pruningAlpha-Beta pruning
Constraint satisfactionConstraint satisfaction
![Page 16: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/16.jpg)
16
Planning TechniquesPlanning Techniques
Means-Ends analysisInitial state, Goal state, intermediate states.Operators to change the states.
Each operator:Preconditions
Effects
Go backwards : from the goal to the initial state.
![Page 17: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/17.jpg)
17
Basic AlgorithmBasic AlgorithmPut the goal state in a list of subgoals
While the list is not empty, doTake 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 planIf no - Put the preconditions in the list
of subgoals
![Page 18: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/18.jpg)
18
More complex problemsMore 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.
![Page 19: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/19.jpg)
19
Extensions of the basic Extensions of the basic methodmethod
Planning with goal protectionPlanning with goal protection Nonlinear planningNonlinear planning Hierarchical planningHierarchical planning Reactive planningReactive planning
![Page 20: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/20.jpg)
20
Game Playing SystemsGame 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
![Page 21: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/21.jpg)
21
Player1
Player2
Player1
![Page 22: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/22.jpg)
22
Minimax procedureMinimax procedure
Scoring the final nodes: Winning : 10Draw : 0Loosing : -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.
![Page 23: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/23.jpg)
23
Minimax algorithmMinimax 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 nodeElse:
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
![Page 24: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/24.jpg)
24
Alpha-Beta PruningAlpha-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.
![Page 25: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/25.jpg)
25
A:10
B:10 C: 0
E:10 F:10 G: 0 H:10
I:10 J: 0 K:10 L:-10 M:-10 N:0 O:10 P:-10
Maximizing score
Minimizing score
P1's move
P2's move
P1's minimax tree
![Page 26: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/26.jpg)
26
Constraint satisfaction Constraint satisfaction searchsearch
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 valuesGoal state: Variables have values and the constraints are obeyed.
![Page 27: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/27.jpg)
27
Constraint satisfaction Constraint satisfaction searchsearch
Different types of constraints: Different types of constraints:
unaryunary - on one variable only - on one variable only
binarybinary - on two variables, etc. - on two variables, etc.
![Page 28: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/28.jpg)
28
ExampleExample
WEEK LOAN WEEK + LOAN + WEEK
LOAN WEEK ----------------- -----------------
DEBT MONTH
![Page 29: 1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d385503460f94a112f4/html5/thumbnails/29.jpg)
29
Example - continuedExample - 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.