abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cuddSolve.c File Reference
#include "misc/util/util_hack.h"
#include "cuddInt.h"

Go to the source code of this file.

Functions

DdNodeCudd_SolveEqn (DdManager *bdd, DdNode *F, DdNode *Y, DdNode **G, int **yIndex, int n)
 
DdNodeCudd_VerifySol (DdManager *bdd, DdNode *F, DdNode **G, int *yIndex, int n)
 
DdNodecuddSolveEqnRecur (DdManager *bdd, DdNode *F, DdNode *Y, DdNode **G, int n, int *yIndex, int i)
 
DdNodecuddVerifySol (DdManager *bdd, DdNode *F, DdNode **G, int *yIndex, int n)
 

Variables

static
ABC_NAMESPACE_IMPL_START char
rcsid[] 
DD_UNUSED = "$Id: cuddSolve.c,v 1.12 2004/08/13 18:04:51 fabio Exp $"
 

Function Documentation

DdNode* Cudd_SolveEqn ( DdManager bdd,
DdNode F,
DdNode Y,
DdNode **  G,
int **  yIndex,
int  n 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Implements the solution of F(x,y) = 0.]

Description [Implements the solution for F(x,y) = 0. The return value is the consistency condition. The y variables are the unknowns and the remaining variables are the parameters. Returns the consistency condition if successful; NULL otherwise. Cudd_SolveEqn allocates an array and fills it with the indices of the unknowns. This array is used by Cudd_VerifySol.]

SideEffects [The solution is returned in G; the indices of the y variables are returned in yIndex.]

SeeAlso [Cudd_VerifySol]

Definition at line 126 of file cuddSolve.c.

133 {
134  DdNode *res;
135  int *temp;
136 
137  *yIndex = temp = ABC_ALLOC(int, n);
138  if (temp == NULL) {
139  bdd->errorCode = CUDD_MEMORY_OUT;
140  (void) fprintf(bdd->out,
141  "Cudd_SolveEqn: Out of memory for yIndex\n");
142  return(NULL);
143  }
144 
145  do {
146  bdd->reordered = 0;
147  res = cuddSolveEqnRecur(bdd, F, Y, G, n, temp, 0);
148  } while (bdd->reordered == 1);
149 
150  return(res);
151 
152 } /* end of Cudd_SolveEqn */
Definition: cudd.h:278
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int reordered
Definition: cuddInt.h:409
FILE * out
Definition: cuddInt.h:441
DdNode * cuddSolveEqnRecur(DdManager *bdd, DdNode *F, DdNode *Y, DdNode **G, int n, int *yIndex, int i)
Definition: cuddSolve.c:210
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_VerifySol ( DdManager bdd,
DdNode F,
DdNode **  G,
int *  yIndex,
int  n 
)

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

Synopsis [Checks the solution of F(x,y) = 0.]

Description [Checks the solution of F(x,y) = 0. This procedure substitutes the solution components for the unknowns of F and returns the resulting BDD for F.]

SideEffects [Frees the memory pointed by yIndex.]

SeeAlso [Cudd_SolveEqn]

Definition at line 169 of file cuddSolve.c.

175 {
176  DdNode *res;
177 
178  do {
179  bdd->reordered = 0;
180  res = cuddVerifySol(bdd, F, G, yIndex, n);
181  } while (bdd->reordered == 1);
182 
183  ABC_FREE(yIndex);
184 
185  return(res);
186 
187 } /* end of Cudd_VerifySol */
DdNode * cuddVerifySol(DdManager *bdd, DdNode *F, DdNode **G, int *yIndex, int n)
Definition: cuddSolve.c:336
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode* cuddSolveEqnRecur ( DdManager bdd,
DdNode F,
DdNode Y,
DdNode **  G,
int  n,
int *  yIndex,
int  i 
)

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

Synopsis [Implements the recursive step of Cudd_SolveEqn.]

Description [Implements the recursive step of Cudd_SolveEqn. Returns NULL if the intermediate solution blows up or reordering occurs. The parametric solutions are stored in the array G.]

SideEffects [none]

SeeAlso [Cudd_SolveEqn, Cudd_VerifySol]

Definition at line 210 of file cuddSolve.c.

218 {
219  DdNode *Fn, *Fm1, *Fv, *Fvbar, *T, *w, *nextY, *one;
220  DdNodePtr *variables;
221 
222  int j;
223 
224  statLine(bdd);
225  variables = bdd->vars;
226  one = DD_ONE(bdd);
227 
228  /* Base condition. */
229  if (Y == one) {
230  return F;
231  }
232 
233  /* Cofactor of Y. */
234  yIndex[i] = Y->index;
235  nextY = Cudd_T(Y);
236 
237  /* Universal abstraction of F with respect to the top variable index. */
238  Fm1 = cuddBddExistAbstractRecur(bdd, Cudd_Not(F), variables[yIndex[i]]);
239  if (Fm1) {
240  Fm1 = Cudd_Not(Fm1);
241  cuddRef(Fm1);
242  } else {
243  return(NULL);
244  }
245 
246  Fn = cuddSolveEqnRecur(bdd, Fm1, nextY, G, n, yIndex, i+1);
247  if (Fn) {
248  cuddRef(Fn);
249  } else {
250  Cudd_RecursiveDeref(bdd, Fm1);
251  return(NULL);
252  }
253 
254  Fv = cuddCofactorRecur(bdd, F, variables[yIndex[i]]);
255  if (Fv) {
256  cuddRef(Fv);
257  } else {
258  Cudd_RecursiveDeref(bdd, Fm1);
259  Cudd_RecursiveDeref(bdd, Fn);
260  return(NULL);
261  }
262 
263  Fvbar = cuddCofactorRecur(bdd, F, Cudd_Not(variables[yIndex[i]]));
264  if (Fvbar) {
265  cuddRef(Fvbar);
266  } else {
267  Cudd_RecursiveDeref(bdd, Fm1);
268  Cudd_RecursiveDeref(bdd, Fn);
269  Cudd_RecursiveDeref(bdd, Fv);
270  return(NULL);
271  }
272 
273  /* Build i-th component of the solution. */
274  w = cuddBddIteRecur(bdd, variables[yIndex[i]], Cudd_Not(Fv), Fvbar);
275  if (w) {
276  cuddRef(w);
277  } else {
278  Cudd_RecursiveDeref(bdd, Fm1);
279  Cudd_RecursiveDeref(bdd, Fn);
280  Cudd_RecursiveDeref(bdd, Fv);
281  Cudd_RecursiveDeref(bdd, Fvbar);
282  return(NULL);
283  }
284 
285  T = cuddBddRestrictRecur(bdd, w, Cudd_Not(Fm1));
286  if(T) {
287  cuddRef(T);
288  } else {
289  Cudd_RecursiveDeref(bdd, Fm1);
290  Cudd_RecursiveDeref(bdd, Fn);
291  Cudd_RecursiveDeref(bdd, Fv);
292  Cudd_RecursiveDeref(bdd, Fvbar);
293  Cudd_RecursiveDeref(bdd, w);
294  return(NULL);
295  }
296 
297  Cudd_RecursiveDeref(bdd,Fm1);
298  Cudd_RecursiveDeref(bdd,w);
299  Cudd_RecursiveDeref(bdd,Fv);
300  Cudd_RecursiveDeref(bdd,Fvbar);
301 
302  /* Substitute components of solution already found into solution. */
303  for (j = n-1; j > i; j--) {
304  w = cuddBddComposeRecur(bdd,T, G[j], variables[yIndex[j]]);
305  if(w) {
306  cuddRef(w);
307  } else {
308  Cudd_RecursiveDeref(bdd, Fn);
309  Cudd_RecursiveDeref(bdd, T);
310  return(NULL);
311  }
312  Cudd_RecursiveDeref(bdd,T);
313  T = w;
314  }
315  G[i] = T;
316 
317  Cudd_Deref(Fn);
318 
319  return(Fn);
320 
321 } /* end of cuddSolveEqnRecur */
DdNode * cuddBddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube)
Definition: cuddBddAbs.c:352
#define cuddRef(n)
Definition: cuddInt.h:584
#define Cudd_T(node)
Definition: cudd.h:440
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * cuddBddComposeRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *proj)
Definition: cuddCompose.c:850
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
#define statLine(dd)
Definition: cuddInt.h:1037
static DdNode * one
Definition: cuddDecomp.c:112
DdNode * cuddCofactorRecur(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddCof.c:230
DdNode * cuddSolveEqnRecur(DdManager *bdd, DdNode *F, DdNode *Y, DdNode **G, int n, int *yIndex, int i)
Definition: cuddSolve.c:210
DdHalfWord index
Definition: cudd.h:279
DdNode ** vars
Definition: cuddInt.h:390
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddBddRestrictRecur(DdManager *dd, DdNode *f, DdNode *c)
Definition: cuddGenCof.c:912
DdNode * cuddBddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:633
DdNode* cuddVerifySol ( DdManager bdd,
DdNode F,
DdNode **  G,
int *  yIndex,
int  n 
)

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

Synopsis [Implements the recursive step of Cudd_VerifySol. ]

Description []

SideEffects [none]

SeeAlso [Cudd_VerifySol]

Definition at line 336 of file cuddSolve.c.

342 {
343  DdNode *w, *R;
344 
345  int j;
346 
347  R = F;
348  cuddRef(R);
349  for(j = n - 1; j >= 0; j--) {
350  w = Cudd_bddCompose(bdd, R, G[j], yIndex[j]);
351  if (w) {
352  cuddRef(w);
353  } else {
354  return(NULL);
355  }
356  Cudd_RecursiveDeref(bdd,R);
357  R = w;
358  }
359 
360  cuddDeref(R);
361 
362  return(R);
363 
364 } /* end of cuddVerifySol */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * Cudd_bddCompose(DdManager *dd, DdNode *f, DdNode *g, int v)
Definition: cuddCompose.c:167

Variable Documentation

ABC_NAMESPACE_IMPL_START char rcsid [] DD_UNUSED = "$Id: cuddSolve.c,v 1.12 2004/08/13 18:04:51 fabio Exp $"
static

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

FileName [cuddSolve.c]

PackageName [cudd]

Synopsis [Boolean equation solver and related functions.]

Description [External functions included in this modoule:

Internal functions included in this module:

]

SeeAlso []

Author [Balakrishna Kumthekar]

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 85 of file cuddSolve.c.