Presentation is loading. Please wait.

Presentation is loading. Please wait.

AND/OR Graphs Ivan Bratko Faculty of Information and Computer Sc. University of Ljubljana Useful for solving problems by problem decomposition Searching.

Similar presentations


Presentation on theme: "AND/OR Graphs Ivan Bratko Faculty of Information and Computer Sc. University of Ljubljana Useful for solving problems by problem decomposition Searching."— Presentation transcript:

1 AND/OR Graphs Ivan Bratko Faculty of Information and Computer Sc. University of Ljubljana Useful for solving problems by problem decomposition Searching AND/OR graphs: depth-first, breadth-first AO*, a generalisation of A*

2 Example: map with river, bridges at f,g Bridges at f, g

3 Problem: Find path from a to z Decomposition into subproblems

4 Relations among subproblems To solve P, solve P1 or P2 or... To solve Q, solve Q1 and Q2 and...

5 Solutions are trees cost = 9 cost = 8

6 AND/OR Graphs AND nodes, OR nodes Problem = start node + goal condition Solution = solution graph (tree) Cost of tree = sum of costs of tree’s arcs AND-related nodes independent Independence requirement relaxed: ordering w.r.t. solutions

7 Example of ordered subproblems: Tower of Hanoi disks a, b, c on peg 3 a on 3 b on 3 c on 3 Order of subprobl.: first c on 3, then b on 3,... abcabc

8 Other examples of AND/OR representations Two person, perfect information games (chess, checkers) Expert-system problem solving Design from “first principles”

9 AND/OR graphs for games

10 Design from “first principles” Design robot to transfer objects Function Transfer Subfunctions Grasp Lift... Components Grip1 Grip2... Motor1 Motor2...

11 Direct representation in Prolog: Prolog does AND/OR search a :- b; c. % OR-related successors b :- d, e. % AND-related successors d. g. e. % Goal nodes... ?- a. yes Shortcomings: no solution tree no costs susceptible to loops

12 Alternative representation of AND/OR graph :- op( 600, xfx, --->). :- op( 500, xfx, :). a ---> or : [b,c]. b ---> and : [d,e]. goal( d). goal( g). goal( h).

13 Form of solution tree % solve( Node, SolutionTree) SolutionTree = Node if goal( Node) Node ---> SubTree if Node has OR-succ. Node ---> and: SubTrees if Node has AND-succ. For example: SolutionTree = a ---> b ---> and : [ d, e ---> h]

14 % solve( Node, SolutionTree): depth-first AND/OR search solve( Node, Node) :- % Solution tree of goal node is Node itself goal(Node). solve( Node, Node ---> Tree) :- Node ---> or:Nodes, % Node is an OR-node member( Node1, Nodes), % Select a successor Node1 of Node solve( Node1, Tree). solve( Node, Node ---> and:Trees) :- Node ---> and:Nodes, % Node is an AND-node solveall( Nodes, Trees). % Solve all Node's successors % solveall( [Node1,Node2,...], [SolutionTree1,SolutionTree2,...]) solveall( [], []). solveall( [Node|Nodes], [Tree|Trees]) :- solve( Node, Tree), solveall( Nodes, Trees).

15 Simple refinements of depth-first AND/OR search Limit search depth (prevent infinite loops) Emulate breadth-first search by iterative deepening AND/OR search

16 Best-first AND/OR search Algorithm AO*, a generalisation of A* to AND/OR search Define: Cost of solution tree = Sum of tree’s arc costs Cost of node = cost of node’s optimal solution tree h(N) = heuristic estimate of cost of node N

17 Updated heuristic estimates of nodes Heuristic estimates of nodes are updated when new information becomes available during search (when search tree expands) H(N) = updated heuristic estimate of cost of (any) node in search tree H(N) = h(N) if N is a leaf in search tree H(N) = min i ( cost(N,N i ) + H(N i ) ) N N 1 N 2... H(N) = SUM i ( cost(N,N i ) + H(N i ) ) N N 1 N 2...

18 Example of AO* search AND/OR graph to be searched

19 Trace of AO* search

20 Best-first AND/OR search AO* program in Prolog: in Bratko 2001, Prolog Programming for AI, pages 311-214 For simpler implementation, this program uses node evaluation function F defined as: F(N) = H(N) + cost(M,N), M predecessor of N Admissibility of AO*: AO* is admissible if h(N) =< h*(N) for all N (similar to admissibility of A*)


Download ppt "AND/OR Graphs Ivan Bratko Faculty of Information and Computer Sc. University of Ljubljana Useful for solving problems by problem decomposition Searching."

Similar presentations


Ads by Google