Problem Reduction Search: Problem Reduction Search: AND/OR Graphs & Game Trees AND/OR Graphs & Game Trees Course: CS40002 Course: CS40002 Instructor: Dr. Pallab Dasgupta Pallab Dasgupta Instructor: Dr. Department of Computer Science & Engineering Department of Computer Science & Engineering Indian Institute of Technology Kharagpur Kharagpur Indian Institute of Technology
Problem Reduction Search Problem Reduction Search � Planning how best to solve a problem that Planning how best to solve a problem that � can be recursively decomposed into sub- - can be recursively decomposed into sub problems in multiple ways problems in multiple ways � Matrix multiplication problem Matrix multiplication problem � � Tower of Hanoi Tower of Hanoi � � Blocks World problems Blocks World problems � � Theorem proving Theorem proving � CSE, IIT Kharagpur Kharagpur CSE, IIT 2
Formulations Formulations � AND/OR Graphs AND/OR Graphs � � An OR node represents a choice between An OR node represents a choice between � possible decompositions possible decompositions � An AND node represents a given An AND node represents a given � decomposition decomposition � Game Trees Game Trees � � Max nodes represent the choice of my Max nodes represent the choice of my � opponent opponent � Min nodes represent my choice Min nodes represent my choice � CSE, IIT Kharagpur Kharagpur CSE, IIT 3
The AND/OR graph search problem The AND/OR graph search problem • Problem definition: Problem definition: • – Given: Given: [G, s, T] where – [G, s, T] where • G: G: implicitly specified AND/OR graph implicitly specified AND/OR graph • • S: S: start node of the AND/OR graph start node of the AND/OR graph • • T: T: set of terminal nodes • set of terminal nodes • h(n) heuristic function estimating the h(n) heuristic function estimating the • cost of solving the sub- -problem at n problem at n cost of solving the sub – To find: To find: – –A minimum cost solution tree A minimum cost solution tree – CSE, IIT Kharagpur Kharagpur CSE, IIT 4
Algorithm AO* Algorithm AO* 1. Initialize: Initialize: 1. Set G* = {s}, f(s) = h(s) Set G* = {s}, f(s) = h(s) ∈ T, label s as SOLVED If s ∈ T, label s as SOLVED If s 2. Terminate: Terminate: 2. If s is SOLVED, then Terminate If s is SOLVED, then Terminate 3. Select: Select: 3. Select a non- -terminal leaf node n terminal leaf node n Select a non from the marked sub- -tree tree from the marked sub 4. Expand: Expand: 4. Make explicit the successors of n Make explicit the successors of n For each new successor, m: For each new successor, m: Set f(m) = h(m) Set f(m) = h(m) If m is terminal, label m SOLVED If m is terminal, label m SOLVED 5. Cost Revision: Cost Revision: 5. Call cost- -revise(n) revise(n) Call cost 6. Loop: Loop: 6. Go To Step 2. Go To Step 2. CSE, IIT Kharagpur Kharagpur CSE, IIT 5
Cost Revision in AO*: cost Cost Revision in AO*: cost- -revise(n) revise(n) 1. Create Z = {n} Create Z = {n} 1. 2. If Z = { } return If Z = { } return 2. 3. Select a node m from Z such that m has no Select a node m from Z such that m has no 3. descendants in Z descendants in Z 4. If m is an AND node with successors If m is an AND node with successors 4. r 1 , r 2 , … r r k r 1 , r 2 , … : k : Σ f(m) = Σ [ f(r r i ) + c(m, r r i ) ] Set f(m) = [ f( i ) + c(m, i ) ] Set Mark the edge to each successor of m Mark the edge to each successor of m If each successor is labeled SOLVED, If each successor is labeled SOLVED, then label m as SOLVED then label m as SOLVED CSE, IIT Kharagpur Kharagpur CSE, IIT 6
Cost Revision in AO*: cost Cost Revision in AO*: cost- -revise(n) revise(n) 5. If m is an OR node with successors If m is an OR node with successors 5. r 1 , r 2 , … r r k r 1 , r 2 , … : k : f(m) = min { f( { f(r r i ) + c(m, r r i ) } Set f(m) = min i ) + c(m, i ) } Set Mark the edge to the best successor of m Mark the edge to the best successor of m If the marked successor is labeled If the marked successor is labeled SOLVED, label m as SOLVED SOLVED, label m as SOLVED 6. If the cost or label of m has changed, then If the cost or label of m has changed, then 6. insert those parents of m into Z for which m insert those parents of m into Z for which m is a marked successor is a marked successor 7. Go to Step 2. Go to Step 2. 7. CSE, IIT Kharagpur Kharagpur CSE, IIT 7
Searching OR Graphs Searching OR Graphs � How does AO* fare when the graph has only How does AO* fare when the graph has only � OR nodes? OR nodes? CSE, IIT Kharagpur Kharagpur CSE, IIT 8
Searching Game Trees Searching Game Trees � Consider an OR tree with two types of OR Consider an OR tree with two types of OR � nodes, namely Min nodes and Max nodes nodes, namely Min nodes and Max nodes � In Min nodes, select the min cost successor In Min nodes, select the min cost successor � � In Max nodes, select the max cost successor In Max nodes, select the max cost successor � � Terminal nodes are winning or loosing states Terminal nodes are winning or loosing states � � It is often infeasible to search up to the It is often infeasible to search up to the � terminal nodes terminal nodes � We use heuristic costs to compare non We use heuristic costs to compare non- - � terminal nodes terminal nodes CSE, IIT Kharagpur Kharagpur CSE, IIT 9
Shallow and Deep Pruning Shallow and Deep Pruning ROOT ROOT A 10 B 10 F Max node 14 C D G Min node 5 E Shallow Cut-off Deep Cut-off CSE, IIT Kharagpur Kharagpur CSE, IIT 10
Alpha- -Beta Pruning Beta Pruning Alpha � Alpha Bound of J: Alpha Bound of J: � � The max current The max current val val of all MAX ancestors of J of all MAX ancestors of J � � Exploration of a min node, J, is stopped when its value Exploration of a min node, J, is stopped when its value � equals or falls below alpha. equals or falls below alpha. � In a min node, we update beta In a min node, we update beta � � Beta Bound of J: Beta Bound of J: � � The min current The min current val val of all MIN ancestors of J of all MIN ancestors of J � � Exploration of a max node, J, is stopped when its value Exploration of a max node, J, is stopped when its value � equals or exceeds beta equals or exceeds beta � In a max node, we update alpha In a max node, we update alpha � α ≥ ≥ β β In both min and max nodes, we return when α � In both min and max nodes, we return when � CSE, IIT Kharagpur Kharagpur CSE, IIT 11
α , β ) Beta Procedure: V(J; α , β Alpha- -Beta Procedure: V(J; ) Alpha 1. If J is a terminal, return V(J) = h(J). 1. If J is a terminal, return V(J) = h(J). 2. If J is a max node: 2. If J is a max node: For each successor J J k of J in succession: For each successor k of J in succession: α = max { α , V( α , β ) } Set α = max { α ; α , β , V(J J k ) } Set k ; α ≥ ≥ β β then return β , else continue If α then return β , else continue If α Return α Return 3. If J is a min node: 3. If J is a min node: For each successor J J k of J in succession: For each successor k of J in succession: β = min { β , V( α , β ) } Set β = min { β ; α , β , V(J J k ) } Set k ; α ≥ ≥ β β then return α , else continue If α then return α , else continue If β Return β Return CSE, IIT Kharagpur Kharagpur CSE, IIT 12
Recommend
More recommend