src/bdd/cudd/cuddInteract.c File Reference

#include "util_hack.h"
#include "cuddInt.h"
Include dependency graph for cuddInteract.c:

Go to the source code of this file.

Defines

#define BPL   32
#define LOGBPL   5

Functions

static void ddSuppInteract ARGS ((DdNode *f, int *support))
static void ddClearLocal ARGS ((DdNode *f))
static void ddUpdateInteract ARGS ((DdManager *table, int *support))
static void ddClearGlobal ARGS ((DdManager *table))
void cuddSetInteract (DdManager *table, int x, int y)
int cuddTestInteract (DdManager *table, int x, int y)
int cuddInitInteract (DdManager *table)
static void ddSuppInteract (DdNode *f, int *support)
static void ddClearLocal (DdNode *f)
static void ddUpdateInteract (DdManager *table, int *support)
static void ddClearGlobal (DdManager *table)

Variables

static char rcsid[] DD_UNUSED = "$Id: cuddInteract.c,v 1.1.1.1 2003/02/24 22:23:52 wjiang Exp $"

Define Documentation

#define BPL   32

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

FileName [cuddInteract.c]

PackageName [cudd]

Synopsis [Functions to manipulate the variable interaction matrix.]

Description [Internal procedures included in this file:

Static procedures included in this file:

The interaction matrix tells whether two variables are both in the support of some function of the DD. The main use of the interaction matrix is in the in-place swapping. Indeed, if two variables do not interact, there is no arc connecting the two layers; therefore, the swap can be performed in constant time, without scanning the subtables. Another use of the interaction matrix is in the computation of the lower bounds for sifting. Finally, the interaction matrix can be used to speed up aggregation checks in symmetric and group sifting.

The computation of the interaction matrix is done with a series of depth-first searches. The searches start from those nodes that have only external references. The matrix is stored as a packed array of bits; since it is symmetric, only the upper triangle is kept in memory. As a final remark, we note that there may be variables that do intercat, but that for a given variable order have no arc connecting their layers when they are adjacent.]

SeeAlso []

Author [Fabio Somenzi]

Copyright [ This file was created at the University of Colorado at Boulder. The University of Colorado at Boulder makes no warranty about the suitability of this software for any purpose. It is presented on an AS IS basis.]

Definition at line 61 of file cuddInteract.c.

#define LOGBPL   5

Definition at line 62 of file cuddInteract.c.


Function Documentation

static void ddClearGlobal ARGS ( (DdManager *table)   )  [static]
static void ddUpdateInteract ARGS ( (DdManager *table, int *support)   )  [static]
static void ddClearLocal ARGS ( (DdNode *f)   )  [static]
static void ddSuppInteract ARGS ( (DdNode *f, int *support)   )  [static]

AutomaticStart

int cuddInitInteract ( DdManager table  ) 

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

Synopsis [Initializes the interaction matrix.]

Description [Initializes the interaction matrix. The interaction matrix is implemented as a bit vector storing the upper triangle of the symmetric interaction matrix. The bit vector is kept in an array of long integers. The computation is based on a series of depth-first searches, one for each root of the DAG. Two flags are needed: The local visited flag uses the LSB of the then pointer. The global visited flag uses the LSB of the next pointer. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 206 of file cuddInteract.c.

00208 {
00209     int i,j,k;
00210     int words;
00211     long *interact;
00212     int *support;
00213     DdNode *f;
00214     DdNode *sentinel = &(table->sentinel);
00215     DdNodePtr *nodelist;
00216     int slots;
00217     int n = table->size;
00218 
00219     words = ((n * (n-1)) >> (1 + LOGBPL)) + 1;
00220     table->interact = interact = ALLOC(long,words);
00221     if (interact == NULL) {
00222         table->errorCode = CUDD_MEMORY_OUT;
00223         return(0);
00224     }
00225     for (i = 0; i < words; i++) {
00226         interact[i] = 0;
00227     }
00228 
00229     support = ALLOC(int,n);
00230     if (support == NULL) {
00231         table->errorCode = CUDD_MEMORY_OUT;
00232         FREE(interact);
00233         return(0);
00234     }
00235 
00236     for (i = 0; i < n; i++) {
00237         nodelist = table->subtables[i].nodelist;
00238         slots = table->subtables[i].slots;
00239         for (j = 0; j < slots; j++) {
00240             f = nodelist[j];
00241             while (f != sentinel) {
00242                 /* A node is a root of the DAG if it cannot be
00243                 ** reached by nodes above it. If a node was never
00244                 ** reached during the previous depth-first searches,
00245                 ** then it is a root, and we start a new depth-first
00246                 ** search from it.
00247                 */
00248                 if (!Cudd_IsComplement(f->next)) {
00249                     for (k = 0; k < n; k++) {
00250                         support[k] = 0;
00251                     }
00252                     ddSuppInteract(f,support);
00253                     ddClearLocal(f);
00254                     ddUpdateInteract(table,support);
00255                 }
00256                 f = Cudd_Regular(f->next);
00257             }
00258         }
00259     }
00260     ddClearGlobal(table);
00261 
00262     FREE(support);
00263     return(1);
00264 
00265 } /* end of cuddInitInteract */

void cuddSetInteract ( DdManager table,
int  x,
int  y 
)

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

Synopsis [Set interaction matrix entries.]

Description [Given a pair of variables 0 <= x < y < table->size, sets the corresponding bit of the interaction matrix to 1.]

SideEffects [None]

SeeAlso []

Definition at line 125 of file cuddInteract.c.

00129 {
00130     int posn, word, bit;
00131 
00132 #ifdef DD_DEBUG
00133     assert(x < y);
00134     assert(y < table->size);
00135     assert(x >= 0);
00136 #endif
00137 
00138     posn = ((((table->size << 1) - x - 3) * x) >> 1) + y - 1;
00139     word = posn >> LOGBPL;
00140     bit = posn & (BPL-1);
00141     table->interact[word] |= 1L << bit;
00142 
00143 } /* end of cuddSetInteract */

int cuddTestInteract ( DdManager table,
int  x,
int  y 
)

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

Synopsis [Test interaction matrix entries.]

Description [Given a pair of variables 0 <= x < y < table->size, tests whether the corresponding bit of the interaction matrix is 1. Returns the value of the bit.]

SideEffects [None]

SeeAlso []

Definition at line 160 of file cuddInteract.c.

00164 {
00165     int posn, word, bit, result;
00166 
00167     if (x > y) {
00168         int tmp = x;
00169         x = y;
00170         y = tmp;
00171     }
00172 #ifdef DD_DEBUG
00173     assert(x < y);
00174     assert(y < table->size);
00175     assert(x >= 0);
00176 #endif
00177 
00178     posn = ((((table->size << 1) - x - 3) * x) >> 1) + y - 1;
00179     word = posn >> LOGBPL;
00180     bit = posn & (BPL-1);
00181     result = (table->interact[word] >> bit) & 1L;
00182     return(result);
00183 
00184 } /* end of cuddTestInteract */

static void ddClearGlobal ( DdManager table  )  [static]

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

Synopsis [Scans the DD and clears the LSB of the next pointers.]

Description [The LSB of the next pointers are used as markers to tell whether a node was reached by at least one DFS. Once the interaction matrix is built, these flags are reset.]

SideEffects [None]

SeeAlso []

Definition at line 380 of file cuddInteract.c.

00382 {
00383     int i,j;
00384     DdNode *f;
00385     DdNode *sentinel = &(table->sentinel);
00386     DdNodePtr *nodelist;
00387     int slots;
00388 
00389     for (i = 0; i < table->size; i++) {
00390         nodelist = table->subtables[i].nodelist;
00391         slots = table->subtables[i].slots;
00392         for (j = 0; j < slots; j++) {
00393             f = nodelist[j];
00394             while (f != sentinel) {
00395                 f->next = Cudd_Regular(f->next);
00396                 f = f->next;
00397             }
00398         }
00399     }
00400 
00401 } /* end of ddClearGlobal */

static void ddClearLocal ( DdNode f  )  [static]

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

Synopsis [Performs a DFS from f, clearing the LSB of the then pointers.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 317 of file cuddInteract.c.

00319 {
00320     if (cuddIsConstant(f) || !Cudd_IsComplement(cuddT(f))) {
00321         return;
00322     }
00323     /* clear visited flag */
00324     cuddT(f) = Cudd_Regular(cuddT(f));
00325     ddClearLocal(cuddT(f));
00326     ddClearLocal(Cudd_Regular(cuddE(f)));
00327     return;
00328 
00329 } /* end of ddClearLocal */

static void ddSuppInteract ( DdNode f,
int *  support 
) [static]

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

Synopsis [Find the support of f.]

Description [Performs a DFS from f. Uses the LSB of the then pointer as visited flag.]

SideEffects [Accumulates in support the variables on which f depends.]

SeeAlso []

Definition at line 286 of file cuddInteract.c.

00289 {
00290     if (cuddIsConstant(f) || Cudd_IsComplement(cuddT(f))) {
00291         return;
00292     }
00293 
00294     support[f->index] = 1;
00295     ddSuppInteract(cuddT(f),support);
00296     ddSuppInteract(Cudd_Regular(cuddE(f)),support);
00297     /* mark as visited */
00298     cuddT(f) = Cudd_Complement(cuddT(f));
00299     f->next = Cudd_Complement(f->next);
00300     return;
00301 
00302 } /* end of ddSuppInteract */

static void ddUpdateInteract ( DdManager table,
int *  support 
) [static]

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

Synopsis [Marks as interacting all pairs of variables that appear in support.]

Description [If support[i] == support[j] == 1, sets the (i,j) entry of the interaction matrix to 1.]

SideEffects [None]

SeeAlso []

Definition at line 346 of file cuddInteract.c.

00349 {
00350     int i,j;
00351     int n = table->size;
00352 
00353     for (i = 0; i < n-1; i++) {
00354         if (support[i] == 1) {
00355             for (j = i+1; j < n; j++) {
00356                 if (support[j] == 1) {
00357                     cuddSetInteract(table,i,j);
00358                 }
00359             }
00360         }
00361     }
00362 
00363 } /* end of ddUpdateInteract */


Variable Documentation

char rcsid [] DD_UNUSED = "$Id: cuddInteract.c,v 1.1.1.1 2003/02/24 22:23:52 wjiang Exp $" [static]

Definition at line 80 of file cuddInteract.c.


Generated on Tue Jan 5 12:18:55 2010 for abc70930 by  doxygen 1.6.1