search tech
TRANSCRIPT
-
8/3/2019 Search Tech
1/25
Problem Solving Techniques
Contains algorithms:
Uninformed search
Informed search
Local SearchConstraint Satisfaction Problem
Adversarial search
-
8/3/2019 Search Tech
2/25
Basic Search AlgorithmBasic Search AlgorithmLet L be a list containing the initial state (L= the fringe)
Loopif L is empty return failure
Node select (L)
if Node is a goal thenreturn Node
(the path from initial state to Node)
else generate all successors of Node, andmerge the newly generated states into LEnd Loop
-
8/3/2019 Search Tech
3/25
Evaluating Search strategiesEvaluating Search strategies
1. Completeness: Is the strategy guaranteed to find a solution ifone exists?
2. Optimality: Does the solution have low cost or the minimalcost?
3. Search cost associated :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 measuredin terms of the maximum size of fringe
-
8/3/2019 Search Tech
4/25
Different search strategy
1. Blind Search strategies or Uninformed searcha. Depth first search
b. Breadth first searchc. Iterative deepening searchd. Iterative broadening search
2. Informed Search
3. Constraint Satisfaction Search4. Adversary Search
-
8/3/2019 Search Tech
5/25
Uninformed search
or
Blind Search
-
8/3/2019 Search Tech
6/25
Blind Search
Algorithm 1 : Breadth First Search
Let fringe be a list containing the initial stateLoop
if fringe is empty return failure-
if Node is a goalthen return the path from initial state to Node
else generate all successors of Node, and
(merge the newly generated nodes into fringe)add generated nodes to the back of fringeEnd Loop
-
8/3/2019 Search Tech
7/25
Blind Search
Algorithm 2: Depth First Search
Let fringe be a list containing the initial stateLoop
if fringe is empty return failure-
if Node is a goalthen return the path from initial state to Node
else generate all successors of Node, and
(merge the newly generated nodes into fringe)add generated nodes to the front of fringeEnd Loop
-
8/3/2019 Search Tech
8/25
Blind Search
Algorithm 3: Depth Limited Search
Let fringe be a list containing the initial stateLoop
Node remove-first (fringe)if Node is a goal
then return the path from initial state to Node
else if depth of Node = limit return cutoffelse add generated nodes to the front of fringeEnd Loop
-
8/3/2019 Search Tech
9/25
Blind Search
Algorithm 4: Depth First Iterative Deepening
SearchFirst do DFS to depth 0 (i.e., treat start node as having no
, , , , .
until solution found doDFS with depth cutoff c
c = c+1
-
8/3/2019 Search Tech
10/25
Blind Search
Algorithm 5: Uniform Cost Search
1. Similar to Breath-First.2. Pursues the path with less accumulated cost.
The algorithm expands nodes in the order of their costfrom the source.
-
8/3/2019 Search Tech
11/25
Blind SearchAlgorithm 6: Bidirectional Search
Let fringe1 be a list containing the initial state SLet fringe1 be a list containing the initial state G
Loop (while fringe1 and fringe2 are not empty)Node remove-first frin e1
if Node is in fringe2then return the path {SNode concatenated with reverse(GNode)}else generate all successors of Node, andadd generated nodes to the front of fringe1
m remove-first fringe2generate all successors of Node, andadd generated nodes to the front of fringe2
End Loop
-
8/3/2019 Search Tech
12/25
Informed search
or
Heuristic Search
-
8/3/2019 Search Tech
13/25
Heuristic Search
Algorithm 1: Best First Search
Let fringe be a priority queue containing the initial stateLoop
if frin e is em t return failure
Node remove-first (fringe)if Node is a goal
then return the path from initial state to Nodeelse generate all successors of Node, and
put the newly generated nodes into fringeaccording to their f values
End Loop
-
8/3/2019 Search Tech
14/25
Heuristic Search
Algorithm 2: A* Search
1. Put start state onto queue.2. If queue is empty then fail.3. If head of queue is goal then succeed.4. Else remove head of queue, expand it, place in queue,
and sort entire queue with least cost-so-far + estimatedcost remaining nodes in front.5. If multiple paths reach a common goal, keep only lowest
so far path.
6. Recurse to step 2.
-
8/3/2019 Search Tech
15/25
Heuristic Search
Algorithm 3: IDA* Algorithm
Iterative deepening A* or IDA* is similar to iterative-deepeningdepth-first, but with the following modifications:The depth bound modified to be an f-limit
1. Start with limit = h(start)2. Prune any node if f(node) > f-limit3. Next f-limit=minimum cost of any node pruned
The cut-off for nodes expanded in an iteration is decided by the f-value of the nodes.
-
8/3/2019 Search Tech
16/25
Heuristic Search
Algorithm 3: RBFS: Recursive Breadth First Search
RBFS uses only linear space. It mimics best first search.
It keeps track of the f-value of the best alternative pathavailable from any ancestor of the current node.
If the current node exceeds this limit, the alternative path isexplored.RBFS remembers the f-value of the best leaf in the forgottensub-tree.
-
8/3/2019 Search Tech
17/25
Local search
-
8/3/2019 Search Tech
18/25
Local Search
Algorithm 1: Hill climbing Search
1. Put start state onto queue.
2. If queue is empty then fail.3. If head of queue is goal then succeed.4. Else remove head of queue, expand it, place children sorted by
n n ron o e queue.5. Recurse to step 2.
Or , Algorithm:
1. Determine successors of current state2. Choose successor of maximum goodness (break ties randomly)3. If goodness of best successor is less than current state's
goodness, stop
4. Otherwise make best successor the current state and go to step 1
-
8/3/2019 Search Tech
19/25
Local Search
Algorithm 2: Beam Search
1. Put start state onto queue.2. If queue is empty then fail.3. If head of queue is goal then succeed.4. Else remove head of queue, expand it, place children at
t e en o t e queue.5. If finishing a level, keep only w best nodes in the queue.6. Recurse to step 2.
-
8/3/2019 Search Tech
20/25
Local Search
Algorithm 3: Simulated annealing Search
1. From current state, pick a random successor state;2. If it has better value than current state, then accept the
transition, that is, use successor state as current state;3. Otherwise, do not give up, but instead flip a coin and accept
t e trans t on w t a g ven pro a ty t at s ower as t esuccessor is worse).4. So we accept to sometimes un-optimize the value function a
little with a non-zero probability.
-
8/3/2019 Search Tech
21/25
Adversarial search
-
8/3/2019 Search Tech
22/25
Adversarial Search
Algorithm : MINIMAX
MAXIMIN(n, alpha, beta)
If n is at the search depth, RETURN V(n)For each child m of nvalue = MINIMAX(m, alpha, beta)if value > alpha, alpha = value
= ,
RETURN alpha
MANIMAX(n, alpha, beta)If n is at the search depth, RETURN V(n)
For each child m of nvalue = MAXIMIN(m, alpha, beta)if value < beta, beta = valueif alpha
-
8/3/2019 Search Tech
23/25
Adversarial Search
Algorithm : MINIMAX
Minimax(player,board)
if(game over in current board position)return winnerchildren = all legal moves for player from this board
'
return maximal score of calling minimax on all the childrenelse (min's turn)
return minimal score of calling minimax on all the children
-
8/3/2019 Search Tech
24/25
Adversarial Search
Algorithm : Alpha-beta pruningEvaluate (node, alpha, beta)
if node is a leaf return the heuristic value of nodeif node is a minimizing node
for each child of nodebeta = min (beta, evaluate (child, alpha, beta))
if beta
-
8/3/2019 Search Tech
25/25
Syllabus for Mid sem :
Problem solving using Search techniques
Knowledge & reasoning
All the Best