CFC: A CYCLIC AND/OR GRAPH SEARCH PACKAGE


elemental.jpg

Cyclic AND/OR Graphs


Introduction

A common problem solving strategy consists in decomposing a problem into subproblems, so that either all or just one of these subproblems need to be solved in order to obtain a solution for the original problem. Representing each problem as a node in a directed graph, where arcs express the decomposition relationship between problems and subproblems, two kinds of nodes arise related to both types of decomposition, AND nodes and OR nodes, and the obtained structure is an AND/OR graph. Certain subproblems, depicted in the graph as terminal nodes, can be solved directly, and a solution for the original problem (corresponding to the root node in the graph) can be found by applying graph searching techniques. The solution consists of a subgraph that relates the root node to one or several terminal nodes. Terminal nodes are leaf nodes, i.e., nodes without successors. Another kind of leaf nodes are the non-terminal leaf nodes which represent elementary subproblems that have no solution. Obviously such nodes cannot appear in a solution subgraph.

cfig10.jpg

The cyclic nature of many AND/OR graphs corresponding to different problem types becomes evident in the following example, which can be viewed as a special kind of disassembly problem (AND/OR graphs are frequently used representations in the assembly/disassembly and grasping contexts). A given workpiece laying among other different workpieces has to be picked up, and this can only be done if at least one of the gripping points of that workpiece is free, i.e. no other workpieces obstructing the access to such point (Figure (a)). Obstructing workpieces have to be removed, but their gripping points may in turn be obstructed by other workpieces. For example, point I1 of piece "I" is obstructed by pieces "L" and "S", thus these pieces have to be taken away first, but their gripping points are also obstructed by other pieces. This problem has clearly an AND/OR structure: every workpiece corresponds to an OR node, for it can be picked up by either of its gripping points (the successors of this OR node), which are represented by AND nodes, as far as all workpieces obstructing this point have to be taken away (Figure (b)). The costs of the arcs have been set arbitrarily in this example, but they could reflect physical facts. Now, consider the situation where an obstructing workpiece in its turn is obstructed by the obstructed workpiece or one of its ancestors. This clearly corresponds to a cycle in the graph. Observe that points S1 and C1 are obstructing each other, and, indeed, a cycle exists that contains the corresponding nodes.



Previous work

General graph searching

These books appear in (almost) every bibliography:

  • N. J. Nilsson "Principles of Artificial Intelligence " Tioga, 1980.
  • J. Pearl "Heuristics: Intelligent Search Strategies for Computer Problem Solving " Addison-Wesley, 1984.

  • Acyclic AND/OR graph search algorithms

    A straightforward but highly inefficient way to solve cyclic AND/OR graphs consists in "unfolding" the cycles, while applying an algorithm for acyclic graphs. This can lead to a large waste of computer effort if the arcs of the cycle have comparatively small cost with respect to the solution (if one exists), or to an infinite loop, if there are no alternatives to the cycles. Nonetheless, before tackling cyclic AND/OR graphs, it is advisable to learn something about the easier problem of solving acyclic graphs. These references describe some efficient algorithms for solving implicit AND/OR graphs. In particular, Mahanti and Bagchi's CF algorithm has inspired the top-down search strategy of our CFCREV* algorithm for cyclic graphs, as well as the use of arc markings for restricting the cost revision process to a subset of the whole explicit graph.

  • A. Bagchi and A. Mahanti, "Admissible heuristic search in AND/OR graphs" Theoret. Comput. Sci., 24, 1983, pp. 207--219.
  • P.P. Chakrabarti and S. Ghose and S.C. DeSarkar, "Admissibility of AO* when heuristics overestimate" Artificial Intelligence, 34, 1988, pp. 97--113.
  • C. L. Chang and J. R. Slagle, "An admissible and optimal algorithm for searching AND/OR graphs" Artificial Intelligence, 2, 1971, pp. 117--128.
  • A. Mahanti and A. Bagchi "AND/OR graph heuristic search methods" J. Assoc. Comput. Mach., 32 (1), 1985, pp. 28--51.
  • A. Martelli and U. Montanari "Optimizing decision trees through heuristically guided search" Comm. ACM, 21(12), 1978, pp. 1025--1039.

  • Cyclic AND/OR graph search algorithms

    Solving cyclic graphs is a qualitatively much harder problem. Hvalica's work constitute a very clear and formal approach to the behaviour of the "classical" AO* algorithm in cyclic graphs, its key contribution being a neat modification of the cost revision process that permits handling cycles. Efficiency, however, is not an issue addressed in this work and, thus, the revision process --which extends to all ancestors of the expanded node-- turns out to be more expensive than necessary. Kumar's algorithm works bottom-up on explicit graphs with cycles. It is very efficient, but bottom-up strategies have a drawback that can be important in particular settings: the need of generating all terminal nodes, although most of them will not intervene in the solution. Moreover, they cannot be applied if the search for a solution and the graph construction are simultaneously performed. Up to date, the best performance is obtained with Chakrabarti's algorithms, which have been originally developed for explicit graphs, but can be adapted to work on implicit graphs, as suggested by the author. However, some drawbacks appear to be attached these procedures when applied to implicit graphs, which are overcome in our CFCREV*. The cost revision strategy of our algorithm is based on Chakrabarti's REV*.

  • P. P. Chakrabarti, "Algorithms for searching explicit AND/OR graphs and their applications to problem reduction search" Artificial Intelligence, 65 (2), 1994, pp. 329--345.
  • D. Hvalica, "On the cost of potential solution subgraphs" Proc. of the 3rd Symp. on Operations Research in Slovenia ´95, Portoro\v{z} (Slovenia), 1995, pp. 81--88.
  • D. Hvalica "Best first search algorithm in AND/OR graphs with cycles" Journal of Algorithms, 21, 1996, pp. 102--110.
  • V. Kumar "A general heuristic bottom-up procedure for searching AND/OR graphs" Inform. Sci., 56, 1991, pp. 39--57.

  • CFC: The algorithm

    Consider the explicit graph at a given instant (initially it will consist only of the start node. At each iteration of the search process, the explicit graph is expanded in a top-down fashion. Like AO*, this algorithm has the property that at every moment, below each node "n" exactly one of the potential solution graphs (psg) is marked; we call this the marked psg below "n". Exactly one of the outgoing arcs of every OR node that belongs to this psg is marked, whereas, in the case of AND nodes, all arcs pointing to their successors are marked. By the marked psg we mean the marked psg below the start node. Cost estimates "F" are revised bottom-up, but only along marked arcs. During the cost revision process, arc-marking changes may occur at OR nodes along the currently marked psg, leading to an alternative, more promising, marked psg. The search for the minimum-cost solution graph is performed in four main steps, which are repeated until the solution is found or it is determined that no solution exists:

    1. Node expansion. Select for expansion one of the non-terminal tip nodes of the marked psg, and generate all its successors.
    2. Initialization of revisable nodes. Build the set Z of revisable nodes (i.e., ancestors of the expanded node along marked arcs, including the expanded node itself).
    3. Local cost revision to initialize open nodes. Revisable nodes having a psg below them disjoint with Z are assigned the minimum cost estimate coming from their children and placed in O. This process starts at the expanded node and propagates upwards along Z (which can be thought of as an acyclic graph rooted at the expanded node), stopping propagation in all those branches where no cost changes occur. The nodes traversed that are not placed in O are assigned an infinite new cost estimate.
    4. Definitive cost assignment and arc marking. Revise the F values of the marked ancestors of the expanded node, performing arc-marking changes whenever appropriate. Update the cost estimate F of these revised nodes, using the revised cost values computed during the previous step. Revisable nodes whose cost estimates cannot change are pruned.
    In step (i), every successor of the expanded node that is a terminal node is labelled SOLVED. The expanded node itself is labelled SOLVED in step (iv) if it is an AND node and every one of its successors is labelled SOLVED; or if it is an OR node and at least one of its successors is labelled SOLVED. This status is propagated in the same step to the marked ancestors of the node, following the same rules. Therefore, if a solution exists, the algorithm will finish as soon as the root node is labelled SOLVED. The algorithm may also exit reporting that no solution exists, i.e., with an infinite F value at the root node. The cost-updating procedure in step (iii) prevents from the creation of cycles in the marked psg when the corresponding arc-marking changes are performed in step (iv).

    More details about the algorithm, a pseudocode description, as well as formal proofs of its validity and efficiency will soon be available.

    If you want to test the algorithm, just press the SHIFT key and click here for downloading the executable (the source has been written in ANSI C).


    Users' manual

    How to execute

    CFC is an efficient algorithm that solves graphs containing cycles. In order to test how it works, an implicit graph has to be provided. The algorithm then determines at each execution of its main loop the explicit graph expanded so far, as well as the current solution. Each one of these executions correspond to the expansion of a tip node, and the algorithm finishes as soon as all the tip nodes of the solution subgraph (all the arcs that belong to the current solution subgraph are "marked") are solved terminal nodes. If no solution actually exists, e.g. if all possible alternatives lead to unsolvable cycles, then the algorithm finishes reporting that the root node is unsolved and its cost estimate is equal to infinite.

    The algorithm has been compiled on a Sun Solaris and can be executed with the command


    cfc


    This command can be executed with the -i option, which allows to follow the evolution of the marked psg along the iterations of the main loop.

    Templates for the input file are provided with the examples.


    Input format

    The nodes of the graph have to contain some information, concerning their AND/OR nature, whether they are terminal nodes or not, and the value of their heuristic estimators. As for the topology of the graph, the cost and directions of each arc, toghether with the nodes it connects, must also be known. We have decided to provide all these data in a straightforward, obviously improvable way. The example given below corresponds to the input file "example", and the graph is also depicted. Adjacency and incidency matrices are the most common ways of describing the topological relationships graphs. It should not be very difficult to derive an interface for translating these formats into the naïf form of the corresponding part in our input files.

    The input format is self-explanatory (it corresponds to the graph in the figure above):


    Number_of_nodes 11
    h(0) 1
    AND(0)/OR(1) 1
    SOLVED(0)/NON_TERMINAL(1) 1
    h(1) 1
    AND(0)/OR(1) 0
    SOLVED(0)/NON_TERMINAL(1) 1
    h(2) 1
    AND(0)/OR(1) 1
    SOLVED(0)/NON_TERMINAL(1) 1
    h(3) 0
    AND(0)/OR(1) 1
    SOLVED(0)/NON_TERMINAL(1) 1
    h(4) 1
    AND(0)/OR(1) 0
    SOLVED(0)/NON_TERMINAL(1) 1
    h(5) 1
    AND(0)/OR(1) 0
    SOLVED(0)/NON_TERMINAL(1) 1
    h(6) 0
    AND(0)/OR(1) 0
    SOLVED(0)/NON_TERMINAL(1) 1
    h(7) 2
    AND(0)/OR(1) 1
    SOLVED(0)/NON_TERMINAL(1) 1
    h(8) 0
    AND(0)/OR(1) 1
    SOLVED(0)/NON_TERMINAL(1) 1
    h(9) 1
    AND(0)/OR(1) 0
    SOLVED(0)/NON_TERMINAL(1) 1
    h(10) 0
    AND(0)/OR(1) 0
    SOLVED(0)/NON_TERMINAL(1) 0
    arcsarcsarcsarcsarcsarcsarcsarcsarcsarcsarcsarcs
    vtx1 0
    vtx2 1
    weigth 1
    another? 1
    vtx1 1
    vtx2 2
    weigth 1
    another? 1
    vtx1 1
    vtx2 3
    weigth 1
    another? 1
    vtx1 2
    vtx2 4
    weigth 1
    another? 1
    vtx1 2
    vtx2 5
    weigth 1
    another? 1
    vtx1 3
    vtx2 6
    weigth 1
    another? 1
    vtx1 4
    vtx2 7
    weigth 1
    another? 1
    vtx1 5
    vtx2 8
    weigth 5
    another? 1
    vtx1 6
    vtx2 7
    weigth 1
    another? 1
    vtx1 7
    vtx2 9
    weigth 1
    another? 1
    vtx1 8
    vtx2 10
    weigth 10
    another? 1
    vtx1 9
    vtx2 2
    weigth 1
    another? 0


    First the total number of nodes is introduced. For each node "n", the value of the heuristic estimator h(n) is given, as well as its AND/OR and SOLVED/NON_TERMINAL nature (non-solvable leaf nodes are not considered). Then the data concerning the arcs are entered: the parent and the child node connected by the arc (vtx1 and vtx2 respectively, thus the direction is implicitly provided), as well as the weight or cost of the arc. Finally, it is asked whether another arc has to be entered (1) or not (0). In the latter case, the input finishes.


    Output

    The output of the algorithm consists in a description of the solution graph as a sequence of nodes (following a depth-first order in the graph) and, for each node, the following information is given:


    visiting AND vertex 0
    whose status is SOLVED
    costs are H 1.000000 and F 3.000000
    which has following outgoing arcs:
    a marked arc whose cost is 1.000000
    connected to successor 1
    a marked arc whose cost is 1.000000
    connected to successor 2
    visiting OR vertex 1
    whose status is SOLVED
    costs are H 0.000000 and F 2.000000
    which has following outgoing arcs:
    a marked arc whose cost is 1.000000
    connected to successor 2
    etc.


    i.e., the type and identification number of the node, its SOLVED/UNSOLVED/UNEXPANDED status, the values of its heuristic estimator and of its cost estimator F, and a list of marked arcs pointing to its successors (with their weights). The final status of the root node, the cost of the solution and the total number of iterations of the main loop are also given. If the algorithm is executed with the -i option, then the same information is given for the nodes in the marked psg at each iteration. Furthermore, previously to the description of each psg, the identification number is given of the node which is going to be expanded.


    Examples

    smex1.jpg smex2.jpg smex3.jpg

    Last Modified on friday, May 12, 1998