src/cuBdd/cuddClip.c File Reference

#include "util.h"
#include "cuddInt.h"
Include dependency graph for cuddClip.c:

Go to the source code of this file.

Functions

static DdNodecuddBddClippingAndRecur (DdManager *manager, DdNode *f, DdNode *g, int distance, int direction)
static DdNodecuddBddClipAndAbsRecur (DdManager *manager, DdNode *f, DdNode *g, DdNode *cube, int distance, int direction)
DdNodeCudd_bddClippingAnd (DdManager *dd, DdNode *f, DdNode *g, int maxDepth, int direction)
DdNodeCudd_bddClippingAndAbstract (DdManager *dd, DdNode *f, DdNode *g, DdNode *cube, int maxDepth, int direction)
DdNodecuddBddClippingAnd (DdManager *dd, DdNode *f, DdNode *g, int maxDepth, int direction)
DdNodecuddBddClippingAndAbstract (DdManager *dd, DdNode *f, DdNode *g, DdNode *cube, int maxDepth, int direction)

Variables

static char rcsid[] DD_UNUSED = "$Id: cuddClip.c,v 1.8 2004/08/13 18:04:47 fabio Exp $"

Function Documentation

DdNode* Cudd_bddClippingAnd ( DdManager dd,
DdNode f,
DdNode g,
int  maxDepth,
int  direction 
)

AutomaticEnd Function********************************************************************

Synopsis [Approximates the conjunction of two BDDs f and g.]

Description [Approximates the conjunction of two BDDs f and g. Returns a pointer to the resulting BDD if successful; NULL if the intermediate result blows up.]

SideEffects [None]

SeeAlso [Cudd_bddAnd]

Definition at line 125 of file cuddClip.c.

00131 {
00132     DdNode *res;
00133 
00134     do {
00135         dd->reordered = 0;
00136         res = cuddBddClippingAnd(dd,f,g,maxDepth,direction);
00137     } while (dd->reordered == 1);
00138     return(res);
00139 
00140 } /* end of Cudd_bddClippingAnd */

DdNode* Cudd_bddClippingAndAbstract ( DdManager dd,
DdNode f,
DdNode g,
DdNode cube,
int  maxDepth,
int  direction 
)

Function********************************************************************

Synopsis [Approximates the conjunction of two BDDs f and g and simultaneously abstracts the variables in cube.]

Description [Approximates the conjunction of two BDDs f and g and simultaneously abstracts the variables in cube. The variables are existentially abstracted. Returns a pointer to the resulting BDD if successful; NULL if the intermediate result blows up.]

SideEffects [None]

SeeAlso [Cudd_bddAndAbstract Cudd_bddClippingAnd]

Definition at line 159 of file cuddClip.c.

00166 {
00167     DdNode *res;
00168 
00169     do {
00170         dd->reordered = 0;
00171         res = cuddBddClippingAndAbstract(dd,f,g,cube,maxDepth,direction);
00172     } while (dd->reordered == 1);
00173     return(res);
00174 
00175 } /* end of Cudd_bddClippingAndAbstract */

static DdNode * cuddBddClipAndAbsRecur ( DdManager manager,
DdNode f,
DdNode g,
DdNode cube,
int  distance,
int  direction 
) [static]

Function********************************************************************

Synopsis [Approximates the AND of two BDDs and simultaneously abstracts the variables in cube.]

Description [Approximates the AND of two BDDs and simultaneously abstracts the variables in cube. The variables are existentially abstracted. Returns a pointer to the result is successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddClippingAndAbstract]

Definition at line 401 of file cuddClip.c.

00408 {
00409     DdNode *F, *ft, *fe, *G, *gt, *ge;
00410     DdNode *one, *zero, *r, *t, *e, *Cube;
00411     unsigned int topf, topg, topcube, top, index;
00412     ptruint cacheTag;
00413 
00414     statLine(manager);
00415     one = DD_ONE(manager);
00416     zero = Cudd_Not(one);
00417 
00418     /* Terminal cases. */
00419     if (f == zero || g == zero || f == Cudd_Not(g)) return(zero);
00420     if (f == one && g == one)   return(one);
00421     if (cube == one) {
00422         return(cuddBddClippingAndRecur(manager, f, g, distance, direction));
00423     }
00424     if (f == one || f == g) {
00425         return (cuddBddExistAbstractRecur(manager, g, cube));
00426     }
00427     if (g == one) {
00428         return (cuddBddExistAbstractRecur(manager, f, cube));
00429     }
00430     if (distance == 0) return(Cudd_NotCond(one,(direction == 0)));
00431 
00432     /* At this point f, g, and cube are not constant. */
00433     distance--;
00434 
00435     /* Check cache. */
00436     if (f > g) { /* Try to increase cache efficiency. */
00437         DdNode *tmp = f;
00438         f = g; g = tmp;
00439     }
00440     F = Cudd_Regular(f);
00441     G = Cudd_Regular(g);
00442     cacheTag = direction ? DD_BDD_CLIPPING_AND_ABSTRACT_UP_TAG :
00443         DD_BDD_CLIPPING_AND_ABSTRACT_DOWN_TAG;
00444     if (F->ref != 1 || G->ref != 1) {
00445         r = cuddCacheLookup(manager, cacheTag,
00446                             f, g, cube);
00447         if (r != NULL) {
00448             return(r);
00449         }
00450     }
00451 
00452     /* Here we can skip the use of cuddI, because the operands are known
00453     ** to be non-constant.
00454     */
00455     topf = manager->perm[F->index];
00456     topg = manager->perm[G->index];
00457     top = ddMin(topf, topg);
00458     topcube = manager->perm[cube->index];
00459 
00460     if (topcube < top) {
00461         return(cuddBddClipAndAbsRecur(manager, f, g, cuddT(cube),
00462                                       distance, direction));
00463     }
00464     /* Now, topcube >= top. */
00465 
00466     if (topf == top) {
00467         index = F->index;
00468         ft = cuddT(F);
00469         fe = cuddE(F);
00470         if (Cudd_IsComplement(f)) {
00471             ft = Cudd_Not(ft);
00472             fe = Cudd_Not(fe);
00473         }
00474     } else {
00475         index = G->index;
00476         ft = fe = f;
00477     }
00478 
00479     if (topg == top) {
00480         gt = cuddT(G);
00481         ge = cuddE(G);
00482         if (Cudd_IsComplement(g)) {
00483             gt = Cudd_Not(gt);
00484             ge = Cudd_Not(ge);
00485         }
00486     } else {
00487         gt = ge = g;
00488     }
00489 
00490     if (topcube == top) {
00491         Cube = cuddT(cube);
00492     } else {
00493         Cube = cube;
00494     }
00495 
00496     t = cuddBddClipAndAbsRecur(manager, ft, gt, Cube, distance, direction);
00497     if (t == NULL) return(NULL);
00498 
00499     /* Special case: 1 OR anything = 1. Hence, no need to compute
00500     ** the else branch if t is 1.
00501     */
00502     if (t == one && topcube == top) {
00503         if (F->ref != 1 || G->ref != 1)
00504             cuddCacheInsert(manager, cacheTag, f, g, cube, one);
00505         return(one);
00506     }
00507     cuddRef(t);
00508 
00509     e = cuddBddClipAndAbsRecur(manager, fe, ge, Cube, distance, direction);
00510     if (e == NULL) {
00511         Cudd_RecursiveDeref(manager, t);
00512         return(NULL);
00513     }
00514     cuddRef(e);
00515 
00516     if (topcube == top) {       /* abstract */
00517         r = cuddBddClippingAndRecur(manager, Cudd_Not(t), Cudd_Not(e),
00518                                     distance, (direction == 0));
00519         if (r == NULL) {
00520             Cudd_RecursiveDeref(manager, t);
00521             Cudd_RecursiveDeref(manager, e);
00522             return(NULL);
00523         }
00524         r = Cudd_Not(r);
00525         cuddRef(r);
00526         Cudd_RecursiveDeref(manager, t);
00527         Cudd_RecursiveDeref(manager, e);
00528         cuddDeref(r);
00529     } else if (t == e) {
00530         r = t;
00531         cuddDeref(t);
00532         cuddDeref(e);
00533     } else {
00534         if (Cudd_IsComplement(t)) {
00535             r = cuddUniqueInter(manager,(int)index,Cudd_Not(t),Cudd_Not(e));
00536             if (r == NULL) {
00537                 Cudd_RecursiveDeref(manager, t);
00538                 Cudd_RecursiveDeref(manager, e);
00539                 return(NULL);
00540             }
00541             r = Cudd_Not(r);
00542         } else {
00543             r = cuddUniqueInter(manager,(int)index,t,e);
00544             if (r == NULL) {
00545                 Cudd_RecursiveDeref(manager, t);
00546                 Cudd_RecursiveDeref(manager, e);
00547                 return(NULL);
00548             }
00549         }
00550         cuddDeref(e);
00551         cuddDeref(t);
00552     }
00553     if (F->ref != 1 || G->ref != 1)
00554         cuddCacheInsert(manager, cacheTag, f, g, cube, r);
00555     return (r);
00556 
00557 } /* end of cuddBddClipAndAbsRecur */

DdNode* cuddBddClippingAnd ( DdManager dd,
DdNode f,
DdNode g,
int  maxDepth,
int  direction 
)

Function********************************************************************

Synopsis [Approximates the conjunction of two BDDs f and g.]

Description [Approximates the conjunction of two BDDs f and g. Returns a pointer to the resulting BDD if successful; NULL if the intermediate result blows up.]

SideEffects [None]

SeeAlso [Cudd_bddClippingAnd]

Definition at line 197 of file cuddClip.c.

00203 {
00204     DdNode *res;
00205 
00206     res = cuddBddClippingAndRecur(dd,f,g,maxDepth,direction);
00207 
00208     return(res);
00209 
00210 } /* end of cuddBddClippingAnd */

DdNode* cuddBddClippingAndAbstract ( DdManager dd,
DdNode f,
DdNode g,
DdNode cube,
int  maxDepth,
int  direction 
)

Function********************************************************************

Synopsis [Approximates the conjunction of two BDDs f and g and simultaneously abstracts the variables in cube.]

Description [Approximates the conjunction of two BDDs f and g and simultaneously abstracts the variables in cube. Returns a pointer to the resulting BDD if successful; NULL if the intermediate result blows up.]

SideEffects [None]

SeeAlso [Cudd_bddClippingAndAbstract]

Definition at line 229 of file cuddClip.c.

00236 {
00237     DdNode *res;
00238 
00239     res = cuddBddClipAndAbsRecur(dd,f,g,cube,maxDepth,direction);
00240 
00241     return(res);
00242 
00243 } /* end of cuddBddClippingAndAbstract */

static DdNode * cuddBddClippingAndRecur ( DdManager manager,
DdNode f,
DdNode g,
int  distance,
int  direction 
) [static]

AutomaticStart

Function********************************************************************

Synopsis [Implements the recursive step of Cudd_bddClippingAnd.]

Description [Implements the recursive step of Cudd_bddClippingAnd by taking the conjunction of two BDDs. Returns a pointer to the result is successful; NULL otherwise.]

SideEffects [None]

SeeAlso [cuddBddClippingAnd]

Definition at line 265 of file cuddClip.c.

00271 {
00272     DdNode *F, *ft, *fe, *G, *gt, *ge;
00273     DdNode *one, *zero, *r, *t, *e;
00274     unsigned int topf, topg, index;
00275     DD_CTFP cacheOp;
00276 
00277     statLine(manager);
00278     one = DD_ONE(manager);
00279     zero = Cudd_Not(one);
00280 
00281     /* Terminal cases. */
00282     if (f == zero || g == zero || f == Cudd_Not(g)) return(zero);
00283     if (f == g || g == one) return(f);
00284     if (f == one) return(g);
00285     if (distance == 0) {
00286         /* One last attempt at returning the right result. We sort of
00287         ** cheat by calling Cudd_bddLeq. */
00288         if (Cudd_bddLeq(manager,f,g)) return(f);
00289         if (Cudd_bddLeq(manager,g,f)) return(g);
00290         if (direction == 1) {
00291             if (Cudd_bddLeq(manager,f,Cudd_Not(g)) ||
00292                 Cudd_bddLeq(manager,g,Cudd_Not(f))) return(zero);
00293         }
00294         return(Cudd_NotCond(one,(direction == 0)));
00295     }
00296 
00297     /* At this point f and g are not constant. */
00298     distance--;
00299 
00300     /* Check cache. Try to increase cache efficiency by sorting the
00301     ** pointers. */
00302     if (f > g) {
00303         DdNode *tmp = f;
00304         f = g; g = tmp;
00305     }
00306     F = Cudd_Regular(f);
00307     G = Cudd_Regular(g);
00308     cacheOp = (DD_CTFP)
00309         (direction ? Cudd_bddClippingAnd : cuddBddClippingAnd);
00310     if (F->ref != 1 || G->ref != 1) {
00311         r = cuddCacheLookup2(manager, cacheOp, f, g);
00312         if (r != NULL) return(r);
00313     }
00314 
00315     /* Here we can skip the use of cuddI, because the operands are known
00316     ** to be non-constant.
00317     */
00318     topf = manager->perm[F->index];
00319     topg = manager->perm[G->index];
00320 
00321     /* Compute cofactors. */
00322     if (topf <= topg) {
00323         index = F->index;
00324         ft = cuddT(F);
00325         fe = cuddE(F);
00326         if (Cudd_IsComplement(f)) {
00327             ft = Cudd_Not(ft);
00328             fe = Cudd_Not(fe);
00329         }
00330     } else {
00331         index = G->index;
00332         ft = fe = f;
00333     }
00334 
00335     if (topg <= topf) {
00336         gt = cuddT(G);
00337         ge = cuddE(G);
00338         if (Cudd_IsComplement(g)) {
00339             gt = Cudd_Not(gt);
00340             ge = Cudd_Not(ge);
00341         }
00342     } else {
00343         gt = ge = g;
00344     }
00345 
00346     t = cuddBddClippingAndRecur(manager, ft, gt, distance, direction);
00347     if (t == NULL) return(NULL);
00348     cuddRef(t);
00349     e = cuddBddClippingAndRecur(manager, fe, ge, distance, direction);
00350     if (e == NULL) {
00351         Cudd_RecursiveDeref(manager, t);
00352         return(NULL);
00353     }
00354     cuddRef(e);
00355 
00356     if (t == e) {
00357         r = t;
00358     } else {
00359         if (Cudd_IsComplement(t)) {
00360             r = cuddUniqueInter(manager,(int)index,Cudd_Not(t),Cudd_Not(e));
00361             if (r == NULL) {
00362                 Cudd_RecursiveDeref(manager, t);
00363                 Cudd_RecursiveDeref(manager, e);
00364                 return(NULL);
00365             }
00366             r = Cudd_Not(r);
00367         } else {
00368             r = cuddUniqueInter(manager,(int)index,t,e);
00369             if (r == NULL) {
00370                 Cudd_RecursiveDeref(manager, t);
00371                 Cudd_RecursiveDeref(manager, e);
00372                 return(NULL);
00373             }
00374         }
00375     }
00376     cuddDeref(e);
00377     cuddDeref(t);
00378     if (F->ref != 1 || G->ref != 1)
00379         cuddCacheInsert2(manager, cacheOp, f, g, r);
00380     return(r);
00381 
00382 } /* end of cuddBddClippingAndRecur */


Variable Documentation

char rcsid [] DD_UNUSED = "$Id: cuddClip.c,v 1.8 2004/08/13 18:04:47 fabio Exp $" [static]

CFile***********************************************************************

FileName [cuddClip.c]

PackageName [cudd]

Synopsis [Clipping functions.]

Description [External procedures included in this module:

Internal procedures included in this module:

Static procedures included in this module:

SeeAlso []

Author [Fabio Somenzi]

Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of the University of Colorado nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.]

Definition at line 86 of file cuddClip.c.


Generated on Tue Jan 12 13:57:18 2010 for glu-2.2 by  doxygen 1.6.1