You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1256 lines
47 KiB

  1. /**
  2. @file
  3. @ingroup cudd
  4. @brief Internal data structures of the CUDD package.
  5. @author Fabio Somenzi
  6. @copyright@parblock
  7. Copyright (c) 1995-2015, Regents of the University of Colorado
  8. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions
  11. are met:
  12. Redistributions of source code must retain the above copyright
  13. notice, this list of conditions and the following disclaimer.
  14. Redistributions in binary form must reproduce the above copyright
  15. notice, this list of conditions and the following disclaimer in the
  16. documentation and/or other materials provided with the distribution.
  17. Neither the name of the University of Colorado nor the names of its
  18. contributors may be used to endorse or promote products derived from
  19. this software without specific prior written permission.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  23. FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  24. COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  26. BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  28. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  30. ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  31. POSSIBILITY OF SUCH DAMAGE.
  32. @endparblock
  33. */
  34. #ifndef CUDD_INT_H_
  35. #define CUDD_INT_H_
  36. /*---------------------------------------------------------------------------*/
  37. /* Nested includes */
  38. /*---------------------------------------------------------------------------*/
  39. #include <math.h>
  40. #include "config.h"
  41. #include "st.h"
  42. #include "mtr.h"
  43. #include "epd.h"
  44. #include "cudd.h"
  45. /*---------------------------------------------------------------------------*/
  46. /* Constant declarations */
  47. /*---------------------------------------------------------------------------*/
  48. #define CUDD_VERSION PACKAGE_VERSION
  49. #define DD_MAXREF ((DdHalfWord) ~0)
  50. #define DD_DEFAULT_RESIZE 10 /* how many extra variables */
  51. /* should be added when resizing */
  52. #define DD_MEM_CHUNK 1022
  53. /* These definitions work for CUDD_VALUE_TYPE == double */
  54. #define DD_ONE_VAL (1.0)
  55. #define DD_ZERO_VAL (0.0)
  56. #define DD_EPSILON (1.0e-12)
  57. /* The definitions of +/- infinity in terms of HUGE_VAL work on
  58. ** the DECstations and on many other combinations of OS/compiler.
  59. */
  60. #ifdef HAVE_IEEE_754
  61. # define DD_PLUS_INF_VAL (HUGE_VAL)
  62. #else
  63. # define DD_PLUS_INF_VAL (10e301)
  64. # define DD_CRI_HI_MARK (10e150)
  65. # define DD_CRI_LO_MARK (-(DD_CRI_HI_MARK))
  66. #endif
  67. #define DD_MINUS_INF_VAL (-(DD_PLUS_INF_VAL))
  68. #define DD_NON_CONSTANT ((DdNode *) 1) /* for Cudd_bddIteConstant */
  69. /* Unique table and cache management constants. */
  70. #define DD_MAX_SUBTABLE_DENSITY 4 /* tells when to resize a subtable */
  71. /* gc when this percent are dead (measured w.r.t. slots, not keys)
  72. ** The first limit (LO) applies normally. The second limit applies when
  73. ** the package believes more space for the unique table (i.e., more dead
  74. ** nodes) would improve performance, and the unique table is not already
  75. ** too large. The third limit applies when memory is low.
  76. */
  77. #define DD_GC_FRAC_LO DD_MAX_SUBTABLE_DENSITY * 0.25
  78. #define DD_GC_FRAC_HI DD_MAX_SUBTABLE_DENSITY * 1.0
  79. #define DD_GC_FRAC_MIN 0.2
  80. #define DD_MIN_HIT 30 /* resize cache when hit ratio
  81. above this percentage (default) */
  82. #define DD_MAX_LOOSE_FRACTION 5 /* 1 / (max fraction of memory used for
  83. unique table in fast growth mode) */
  84. #define DD_MAX_CACHE_FRACTION 3 /* 1 / (max fraction of memory used for
  85. computed table if resizing enabled) */
  86. #define DD_STASH_FRACTION 64 /* 1 / (fraction of memory set
  87. aside for emergencies) */
  88. #define DD_MAX_CACHE_TO_SLOTS_RATIO 4 /* used to limit the cache size */
  89. /* Variable ordering default parameter values. */
  90. #define DD_SIFT_MAX_VAR 1000
  91. #define DD_SIFT_MAX_SWAPS 2000000
  92. #define DD_DEFAULT_RECOMB 0
  93. #define DD_MAX_REORDER_GROWTH 1.2
  94. #define DD_FIRST_REORDER 4004 /* 4 for the constants */
  95. #define DD_DYN_RATIO 2 /* when to dynamically reorder */
  96. /* Primes for cache hash functions. */
  97. #define DD_P1 12582917
  98. #define DD_P2 4256249
  99. #define DD_P3 741457
  100. #define DD_P4 1618033999
  101. /* Cache tags for 3-operand operators. These tags are stored in the
  102. ** least significant bits of the cache operand pointers according to
  103. ** the following scheme. The tag consists of two hex digits. Both digits
  104. ** must be even, so that they do not interfere with complementation bits.
  105. ** The least significant one is stored in Bits 3:1 of the f operand in the
  106. ** cache entry. Bit 1 is always 1, so that we can differentiate
  107. ** three-operand operations from one- and two-operand operations.
  108. ** Therefore, the least significant digit is one of {2,6,a,e}. The most
  109. ** significant digit occupies Bits 3:1 of the g operand in the cache
  110. ** entry. It can by any even digit between 0 and e. This gives a total
  111. ** of 5 bits for the tag proper, which means a maximum of 32 three-operand
  112. ** operations. */
  113. #define DD_ADD_ITE_TAG 0x02
  114. #define DD_BDD_AND_ABSTRACT_TAG 0x06
  115. #define DD_BDD_XOR_EXIST_ABSTRACT_TAG 0x0a
  116. #define DD_BDD_ITE_TAG 0x0e
  117. #define DD_ADD_BDD_DO_INTERVAL_TAG 0x22
  118. #define DD_BDD_CLIPPING_AND_ABSTRACT_UP_TAG 0x26
  119. #define DD_BDD_CLIPPING_AND_ABSTRACT_DOWN_TAG 0x2a
  120. #define DD_BDD_COMPOSE_RECUR_TAG 0x2e
  121. #define DD_ADD_COMPOSE_RECUR_TAG 0x42
  122. #define DD_ADD_NON_SIM_COMPOSE_TAG 0x46
  123. #define DD_EQUIV_DC_TAG 0x4a
  124. #define DD_ZDD_ITE_TAG 0x4e
  125. #define DD_ADD_ITE_CONSTANT_TAG 0x62
  126. #define DD_ADD_EVAL_CONST_TAG 0x66
  127. #define DD_BDD_ITE_CONSTANT_TAG 0x6a
  128. #define DD_ADD_OUT_SUM_TAG 0x6e
  129. #define DD_BDD_LEQ_UNLESS_TAG 0x82
  130. #define DD_ADD_TRIANGLE_TAG 0x86
  131. #define DD_BDD_MAX_EXP_TAG 0x8a
  132. #define DD_VARS_SYMM_BEFORE_TAG 0x8e
  133. #define DD_VARS_SYMM_BETWEEN_TAG 0xa2
  134. /* Generator constants. */
  135. #define CUDD_GEN_CUBES 0
  136. #define CUDD_GEN_PRIMES 1
  137. #define CUDD_GEN_NODES 2
  138. #define CUDD_GEN_ZDD_PATHS 3
  139. #define CUDD_GEN_EMPTY 0
  140. #define CUDD_GEN_NONEMPTY 1
  141. /**
  142. ** @brief Maximum variable index.
  143. **
  144. ** @details CUDD_MAXINDEX is defined in such a way that on 32-bit and
  145. ** 64-bit machines one can cast an index to (int) without generating
  146. ** a negative number.
  147. */
  148. #if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
  149. #define CUDD_MAXINDEX (((DdHalfWord) ~0) >> 1)
  150. #else
  151. #define CUDD_MAXINDEX ((DdHalfWord) ~0)
  152. #endif
  153. /**
  154. ** @brief The index of constant nodes.
  155. **
  156. ** @details This is a synonim for CUDD_MAXINDEX.
  157. */
  158. #define CUDD_CONST_INDEX CUDD_MAXINDEX
  159. /**
  160. ** @brief Size of the random number generator shuffle table.
  161. */
  162. #define STAB_SIZE 64
  163. /**
  164. ** @brief Mask for periodic check of termination and timeout.
  165. **
  166. ** @see checkWhetherToGiveUp
  167. */
  168. #define CUDD_CHECK_MASK 0x7ff
  169. /*---------------------------------------------------------------------------*/
  170. /* Type declarations */
  171. /*---------------------------------------------------------------------------*/
  172. /**
  173. @brief Type that is half the size of a pointer.
  174. */
  175. #if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
  176. typedef uint32_t DdHalfWord;
  177. #else
  178. typedef uint16_t DdHalfWord;
  179. #endif
  180. /**
  181. * @brief Signed integer that is the size of a pointer.
  182. *
  183. * @details The only platforms on which CUDD has been tested define
  184. * intptr_t and uintptr_t in inttypes.h and satisfy the condition
  185. *
  186. * sizeof(intptr_t) == sizeof(uintptr_t) == sizeof(void *)
  187. *
  188. * Neither of these is guaranteed by the C standard.
  189. */
  190. typedef intptr_t ptrint;
  191. /**
  192. * @brief Unsigned integer that is the size of a pointer.
  193. *
  194. * @see ptrint
  195. */
  196. typedef uintptr_t ptruint;
  197. typedef struct DdChildren DdChildren;
  198. typedef struct DdHook DdHook;
  199. typedef struct DdSubtable DdSubtable;
  200. typedef struct DdCache DdCache;
  201. typedef struct DdLocalCacheItem DdLocalCacheItem;
  202. typedef struct DdLocalCache DdLocalCache;
  203. typedef struct DdHashItem DdHashItem;
  204. typedef struct DdHashTable DdHashTable;
  205. typedef struct Move Move;
  206. typedef struct IndexKey IndexKey;
  207. typedef struct DdQueueItem DdQueueItem;
  208. typedef struct DdLevelQueue DdLevelQueue;
  209. /*---------------------------------------------------------------------------*/
  210. /* Stucture declarations */
  211. /*---------------------------------------------------------------------------*/
  212. /**
  213. * @brief The two children of a non-terminal node.
  214. */
  215. struct DdChildren {
  216. struct DdNode *T; /**< then (true) child */
  217. struct DdNode *E; /**< else (false) child */
  218. };
  219. /**
  220. * @brief Decision diagram node.
  221. */
  222. struct DdNode {
  223. DdHalfWord index; /**< variable index */
  224. DdHalfWord ref; /**< reference count */
  225. DdNode *next; /**< next pointer for unique table */
  226. union {
  227. CUDD_VALUE_TYPE value; /**< for constant (terminal) nodes */
  228. DdChildren kids; /**< for internal nodes */
  229. } type; /**< terminal or internal */
  230. };
  231. /**
  232. * @brief CUDD generator.
  233. */
  234. struct DdGen {
  235. DdManager *manager;
  236. int type;
  237. int status;
  238. union {
  239. struct {
  240. int *cube;
  241. CUDD_VALUE_TYPE value;
  242. } cubes;
  243. struct {
  244. int *cube;
  245. DdNode *ub;
  246. } primes;
  247. struct {
  248. int size;
  249. } nodes;
  250. } gen;
  251. struct {
  252. int sp;
  253. DdNode **stack;
  254. } stack;
  255. DdNode *node;
  256. };
  257. /**
  258. ** @brief CUDD hook
  259. **
  260. ** Hooks in CUDD are functions that the application registers with the
  261. ** manager so that they are called at appropriate times. The functions
  262. ** are passed the manager as argument; they should return 1 if
  263. ** successful and 0 otherwise.
  264. */
  265. struct DdHook {
  266. DD_HFP f; /**< function to be called */
  267. struct DdHook *next; /**< next element in the list */
  268. };
  269. /**
  270. * @brief Generic local cache item.
  271. */
  272. struct DdLocalCacheItem {
  273. DdNode *value;
  274. #ifdef DD_CACHE_PROFILE
  275. ptrint count;
  276. #endif
  277. DdNode *key[1];
  278. };
  279. /**
  280. * @brief Local cache.
  281. */
  282. struct DdLocalCache {
  283. DdLocalCacheItem *item;
  284. unsigned int itemsize;
  285. unsigned int keysize;
  286. unsigned int slots;
  287. int shift;
  288. double lookUps;
  289. double minHit;
  290. double hits;
  291. unsigned int maxslots;
  292. DdManager *manager;
  293. struct DdLocalCache *next;
  294. };
  295. /**
  296. * @brief Local hash table item.
  297. */
  298. struct DdHashItem {
  299. struct DdHashItem *next; /**< collision list link */
  300. ptrint count; /**< reference count of item */
  301. DdNode *value; /**< value %DD */
  302. DdNode *key[1]; /**< key pointers */
  303. };
  304. /**
  305. * @brief Local hash table.
  306. */
  307. struct DdHashTable {
  308. unsigned int keysize; /**< number of pointers in the key */
  309. unsigned int itemsize; /**< size of hash table item in bytes */
  310. DdHashItem **bucket; /**< array of buckets */
  311. DdHashItem *nextFree; /**< item free list */
  312. DdHashItem **memoryList; /**< list of memory blocks for items */
  313. unsigned int numBuckets; /**< number of buckets in array */
  314. int shift; /**< shift used in hash function */
  315. unsigned int size; /**< number of items stored in table */
  316. unsigned int maxsize; /**< threshold for table resizing */
  317. DdManager *manager; /**< %DD manager */
  318. };
  319. /**
  320. * @brief Computed table.
  321. */
  322. struct DdCache {
  323. DdNode *f,*g; /**< DDs */
  324. ptruint h; /**< either operator or %DD */
  325. DdNode *data; /**< already constructed %DD */
  326. #ifdef DD_CACHE_PROFILE
  327. ptrint count; /**< statistical counter */
  328. #endif
  329. };
  330. /**
  331. * @brief Subtable for one index.
  332. */
  333. struct DdSubtable {
  334. DdNode **nodelist; /**< hash table */
  335. int shift; /**< shift for hash function */
  336. unsigned int slots; /**< size of the hash table */
  337. unsigned int keys; /**< number of nodes stored in this table */
  338. unsigned int maxKeys; /**< slots * DD_MAX_SUBTABLE_DENSITY */
  339. unsigned int dead; /**< number of dead nodes in this table */
  340. unsigned int next; /**< index of next variable in group */
  341. int bindVar; /**< flag to bind this variable to its level */
  342. /* Fields for lazy sifting. */
  343. Cudd_VariableType varType; /**< variable type (ps, ns, pi) */
  344. int pairIndex; /**< corresponding variable index (ps <-> ns) */
  345. int varHandled; /**< flag: 1 means variable is already handled */
  346. Cudd_LazyGroupType varToBeGrouped; /**< tells what grouping to apply */
  347. };
  348. /**
  349. * @brief Specialized %DD symbol table.
  350. */
  351. struct DdManager {
  352. /* Constants */
  353. DdNode sentinel; /**< for collision lists */
  354. DdNode *one; /**< constant 1 */
  355. DdNode *zero; /**< constant 0 */
  356. DdNode *plusinfinity; /**< plus infinity */
  357. DdNode *minusinfinity; /**< minus infinity */
  358. DdNode *background; /**< background value */
  359. /* Computed Table */
  360. DdCache *acache; /**< address of allocated memory for cache */
  361. DdCache *cache; /**< the cache-based computed table */
  362. unsigned int cacheSlots; /**< total number of cache entries */
  363. int cacheShift; /**< shift value for cache hash function */
  364. double cacheMisses; /**< number of cache misses (since resizing) */
  365. double cacheHits; /**< number of cache hits (since resizing) */
  366. double minHit; /**< hit percentage above which to resize */
  367. int cacheSlack; /**< slots still available for resizing */
  368. unsigned int maxCacheHard; /**< hard limit for cache size */
  369. /* Unique Table */
  370. int size; /**< number of unique subtables */
  371. int sizeZ; /**< for %ZDD */
  372. int maxSize; /**< max number of subtables before resizing */
  373. int maxSizeZ; /**< for %ZDD */
  374. DdSubtable *subtables; /**< array of unique subtables */
  375. DdSubtable *subtableZ; /**< for %ZDD */
  376. DdSubtable constants; /**< unique subtable for the constants */
  377. unsigned int slots; /**< total number of hash buckets */
  378. unsigned int keys; /**< total number of %BDD and %ADD nodes */
  379. unsigned int keysZ; /**< total number of %ZDD nodes */
  380. unsigned int dead; /**< total number of dead %BDD and %ADD nodes */
  381. unsigned int deadZ; /**< total number of dead %ZDD nodes */
  382. unsigned int maxLive; /**< maximum number of live nodes */
  383. unsigned int minDead; /**< do not GC if fewer than these dead */
  384. int gcEnabled; /**< gc is enabled */
  385. double gcFrac; /**< gc when this fraction is dead */
  386. unsigned int looseUpTo; /**< slow growth beyond this limit */
  387. /**< (measured w.r.t. slots, not keys) */
  388. unsigned int initSlots; /**< initial size of a subtable */
  389. DdNode **stack; /**< stack for iterative procedures */
  390. double allocated; /**< number of nodes allocated */
  391. /**< (not during reordering) */
  392. double reclaimed; /**< number of nodes brought back from the dead */
  393. int *perm; /**< current variable perm. (index to level) */
  394. int *permZ; /**< for %ZDD */
  395. int *invperm; /**< current inv. var. perm. (level to index) */
  396. int *invpermZ; /**< for %ZDD */
  397. DdNode **vars; /**< projection functions */
  398. int *map; /**< variable map for fast swap */
  399. DdNode **univ; /**< %ZDD 1 for each variable */
  400. unsigned int isolated; /**< isolated projection functions */
  401. unsigned int originalSize; /**< used by lazy sifting */
  402. int linearSize; /**< number of rows and columns of linear */
  403. ptruint *interact; /**< interacting variable matrix */
  404. ptruint *linear; /**< linear transform matrix */
  405. /* Memory Management */
  406. DdNode **memoryList; /**< memory manager for symbol table */
  407. DdNode *nextFree; /**< list of free nodes */
  408. char *stash; /**< memory reserve */
  409. #ifndef DD_NO_DEATH_ROW
  410. DdNode **deathRow; /**< queue for dereferencing */
  411. int deathRowDepth; /**< number of slots in the queue */
  412. int nextDead; /**< index in the queue */
  413. unsigned deadMask; /**< mask for circular index update */
  414. #endif
  415. /* General Parameters */
  416. CUDD_VALUE_TYPE epsilon; /**< tolerance on comparisons */
  417. /* Dynamic Reordering Parameters */
  418. int reordered; /**< flag set at the end of reordering */
  419. unsigned int reorderings; /**< number of calls to Cudd_ReduceHeap */
  420. unsigned int maxReorderings;/**< maximum number of calls to Cudd_ReduceHeap */
  421. int siftMaxVar; /**< maximum number of vars sifted */
  422. int siftMaxSwap; /**< maximum number of swaps per sifting */
  423. int ddTotalNumberSwapping; /**< number of %BDD/%ADD swaps completed */
  424. int zddTotalNumberSwapping; /**< number of %ZDD swaps completed */
  425. int reordCycle; /**< how often to apply alternate threshold */
  426. double maxGrowth; /**< maximum growth during reordering */
  427. double maxGrowthAlt; /**< alternate maximum growth for reordering */
  428. int autoDyn; /**< automatic dynamic reordering flag (BDD) */
  429. int autoDynZ; /**< automatic dynamic reordering flag (ZDD) */
  430. Cudd_ReorderingType autoMethod; /**< default reordering method */
  431. Cudd_ReorderingType autoMethodZ; /**< default reordering method (ZDD) */
  432. int realign; /**< realign %ZDD order after %BDD reordering */
  433. int realignZ; /**< realign %BDD order after %ZDD reordering */
  434. unsigned int nextDyn; /**< reorder if this size is reached */
  435. unsigned int countDead; /**< if 0, count deads to trigger reordering */
  436. MtrNode *tree; /**< variable group tree (BDD) */
  437. MtrNode *treeZ; /**< variable group tree (ZDD) */
  438. Cudd_AggregationType groupcheck; /**< used during group sifting */
  439. int recomb; /**< used during group sifting */
  440. int symmviolation; /**< used during group sifting */
  441. int arcviolation; /**< used during group sifting */
  442. int populationSize; /**< population size for GA */
  443. int numberXovers; /**< number of crossovers for GA */
  444. unsigned int randomizeOrder; /**< perturb the next reordering threshold */
  445. DdLocalCache *localCaches; /**< local caches currently in existence */
  446. void *hooks; /**< application-specific field (used by vis) */
  447. DdHook *preGCHook; /**< hooks to be called before GC */
  448. DdHook *postGCHook; /**< hooks to be called after GC */
  449. DdHook *preReorderingHook; /**< hooks to be called before reordering */
  450. DdHook *postReorderingHook; /**< hooks to be called after reordering */
  451. FILE *out; /**< stdout for this manager */
  452. FILE *err; /**< stderr for this manager */
  453. Cudd_ErrorType errorCode; /**< info on last error */
  454. unsigned long startTime; /**< start time in milliseconds */
  455. unsigned long timeLimit; /**< CPU time limit */
  456. DD_THFP terminationCallback; /**< termination callback */
  457. void * tcbArg; /**< second argument passed to termination handler */
  458. DD_OOMFP outOfMemCallback; /**< out-of-memory callback */
  459. DD_TOHFP timeoutHandler; /**< timeout handler */
  460. void * tohArg; /**< second argument passed to timeout handler */
  461. /* Statistical counters. */
  462. size_t memused; /**< total memory allocated for the manager */
  463. size_t maxmem; /**< target maximum memory */
  464. size_t maxmemhard; /**< hard limit for maximum memory */
  465. int garbageCollections; /**< number of garbage collections */
  466. unsigned long GCTime; /**< total time spent in garbage collection */
  467. unsigned long reordTime; /**< total time spent in reordering */
  468. double totCachehits; /**< total number of cache hits */
  469. double totCacheMisses; /**< total number of cache misses */
  470. double cachecollisions; /**< number of cache collisions */
  471. double cacheinserts; /**< number of cache insertions */
  472. double cacheLastInserts; /**< insertions at the last cache resizing */
  473. double cachedeletions; /**< number of deletions during garbage coll. */
  474. unsigned int peakLiveNodes; /**< maximum number of live nodes */
  475. /* Random number generator. */
  476. int32_t cuddRand; /**< state of the random number generator */
  477. int32_t cuddRand2; /**< state of the random number generator */
  478. int32_t shuffleSelect; /**< state of the random number generator */
  479. int32_t shuffleTable[STAB_SIZE]; /**< state of the random number generator */
  480. #ifdef DD_STATS
  481. double nodesFreed; /**< number of nodes returned to the free list */
  482. double nodesDropped; /**< number of nodes killed by dereferencing */
  483. int totalNISwaps; /**< number of non-interacting (cheap) swaps */
  484. int extsymmcalls; /**< number of calls to symmetry check fn */
  485. int extsymm; /**< number of successful symmetry checks */
  486. int secdiffcalls; /**< number of calls to second difference fn */
  487. int secdiff; /**< number of successful second diff. checks */
  488. int secdiffmisfire; /**< number of misfired second diff. checks */
  489. int tosses; /**< number of coin tosses in annealing */
  490. int acceptances; /**< number of acceptances in annealing */
  491. int totalShuffles; /**< number of shuffles in exact reordering */
  492. int totalNumberLinearTr; /**< number of linear transformations */
  493. int num_calls; /**< should equal 2n-1 (n is the # of nodes) */
  494. #endif
  495. #ifdef DD_UNIQUE_PROFILE
  496. double uniqueLookUps; /**< number of unique table lookups */
  497. double uniqueLinks; /**< total distance traveled in coll. chains */
  498. #endif
  499. #ifdef DD_COUNT
  500. double recursiveCalls; /**< number of recursive calls */
  501. #ifdef DD_STATS
  502. double nextSample; /**< when to write next line of stats */
  503. #endif
  504. double swapSteps; /**< number of elementary reordering steps */
  505. #endif
  506. #ifdef DD_DEBUG
  507. int addPermuteRecurHits; /**< debug variable for variable permutation */
  508. int bddPermuteRecurHits; /**< debug variable for variable permutation */
  509. int bddVectorComposeHits; /**< debug variable for vector composition */
  510. int addVectorComposeHits; /**< debug variable for vector composition */
  511. int addGeneralVectorComposeHits; /**< debug var. for vector composition */
  512. int enableExtraDebug; /**< deposit a 1 here to enable more debugging */
  513. #endif
  514. };
  515. /**
  516. * @brief Reordering move record.
  517. */
  518. struct Move {
  519. DdHalfWord x;
  520. DdHalfWord y;
  521. unsigned int flags;
  522. int size;
  523. struct Move *next;
  524. };
  525. /**
  526. * @brief Used to sort variables for reordering.
  527. */
  528. struct IndexKey {
  529. int index;
  530. int keys;
  531. };
  532. /**
  533. * @brief Generic level queue item.
  534. */
  535. struct DdQueueItem {
  536. struct DdQueueItem *next;
  537. struct DdQueueItem *cnext;
  538. void *key;
  539. };
  540. /**
  541. * @brief Level queue.
  542. */
  543. struct DdLevelQueue {
  544. void *first;
  545. DdQueueItem **last;
  546. DdQueueItem *freelist;
  547. DdQueueItem **buckets;
  548. int levels;
  549. int itemsize;
  550. int size;
  551. int maxsize;
  552. int numBuckets;
  553. int shift;
  554. DdManager *manager;
  555. };
  556. /*---------------------------------------------------------------------------*/
  557. /* Variable declarations */
  558. /*---------------------------------------------------------------------------*/
  559. /*---------------------------------------------------------------------------*/
  560. /* Macro declarations */
  561. /*---------------------------------------------------------------------------*/
  562. /**
  563. @brief Adds node to the head of the free list.
  564. @details Does not deallocate memory chunks that become free. This
  565. function is also used by the dynamic reordering functions.
  566. @sideeffect None
  567. @see cuddAllocNode cuddDynamicAllocNode cuddDeallocMove
  568. */
  569. #define cuddDeallocNode(unique,node) \
  570. (node)->next = (unique)->nextFree; \
  571. (unique)->nextFree = node;
  572. /**
  573. @brief Adds node to the head of the free list.
  574. @details Does not deallocate memory chunks that become free. This
  575. function is also used by the dynamic reordering functions.
  576. @sideeffect None
  577. @see cuddDeallocNode cuddDynamicAllocNode
  578. */
  579. #define cuddDeallocMove(unique,node) \
  580. ((DdNode *)(node))->ref = 0; \
  581. ((DdNode *)(node))->next = (unique)->nextFree; \
  582. (unique)->nextFree = (DdNode *)(node);
  583. /**
  584. @brief Increases the reference count of a node, if it is not
  585. saturated.
  586. @details This being a macro, it is faster than Cudd_Ref, but it
  587. cannot be used in constructs like cuddRef(a = b()).
  588. @sideeffect none
  589. @see Cudd_Ref
  590. */
  591. #define cuddRef(n) cuddSatInc(Cudd_Regular(n)->ref)
  592. /**
  593. @brief Decreases the reference count of a node, if it is not
  594. saturated.
  595. @details It is primarily used in recursive procedures to decrease
  596. the ref count of a result node before returning it. This
  597. accomplishes the goal of removing the protection applied by a
  598. previous cuddRef. This being a macro, it is faster than Cudd_Deref,
  599. but it cannot be used in constructs like cuddDeref(a = b()).
  600. @sideeffect none
  601. @see Cudd_Deref
  602. */
  603. #define cuddDeref(n) cuddSatDec(Cudd_Regular(n)->ref)
  604. /**
  605. @brief Returns 1 if the node is a constant node.
  606. @details Returns 1 if the node is a constant node (rather than an
  607. internal node). All constant nodes have the same index
  608. (CUDD_CONST_INDEX). The pointer passed to Cudd_IsConstantInt may be either
  609. regular or complemented.
  610. @sideeffect none
  611. @see cuddIsConstant Cudd_IsConstant
  612. */
  613. #define Cudd_IsConstantInt(node) ((Cudd_Regular(node))->index == CUDD_CONST_INDEX)
  614. /**
  615. @brief Returns 1 if the node is a constant node.
  616. @details Returns 1 if the node is a constant node (rather than an
  617. internal node). All constant nodes have the same index
  618. (CUDD_CONST_INDEX). The pointer passed to cuddIsConstant must be regular.
  619. @sideeffect none
  620. @see Cudd_IsConstant Cudd_IsConstantInt
  621. */
  622. #define cuddIsConstant(node) ((node)->index == CUDD_CONST_INDEX)
  623. /**
  624. @brief Returns the then child of an internal node.
  625. @details If <code>node</code> is a constant node, the result is
  626. unpredictable. The pointer passed to cuddT must be regular.
  627. @sideeffect none
  628. @see Cudd_T
  629. */
  630. #define cuddT(node) ((node)->type.kids.T)
  631. /**
  632. @brief Returns the else child of an internal node.
  633. @details If <code>node</code> is a constant node, the result is
  634. unpredictable. The pointer passed to cuddE must be regular.
  635. @sideeffect none
  636. @see Cudd_E
  637. */
  638. #define cuddE(node) ((node)->type.kids.E)
  639. /**
  640. @brief Returns the value of a constant node.
  641. @details If <code>node</code> is an internal node, the result is
  642. unpredictable. The pointer passed to cuddV must be regular.
  643. @sideeffect none
  644. @see Cudd_V
  645. */
  646. #define cuddV(node) ((node)->type.value)
  647. /**
  648. @brief Finds the current position of variable index in the
  649. order.
  650. @details This macro duplicates the functionality of Cudd_ReadPerm,
  651. but it does not check for out-of-bounds indices and it is more
  652. efficient.
  653. @sideeffect none
  654. @see Cudd_ReadPerm
  655. */
  656. #define cuddI(dd,index) (((index)==CUDD_CONST_INDEX)?(int)(index):(dd)->perm[(index)])
  657. /**
  658. @brief Finds the current position of %ZDD variable index in the
  659. order.
  660. @details This macro duplicates the functionality of
  661. Cudd_ReadPermZdd, but it does not check for out-of-bounds indices
  662. and it is more efficient.
  663. @sideeffect none
  664. @see Cudd_ReadPermZdd
  665. */
  666. #define cuddIZ(dd,index) (((index)==CUDD_CONST_INDEX)?(int)(index):(dd)->permZ[(index)])
  667. /**
  668. @brief Hash function for the unique table.
  669. @details
  670. @sideeffect none
  671. @see ddCHash ddCHash2
  672. */
  673. #if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
  674. #define ddHash(f,g,s) \
  675. ((((unsigned)(ptruint)(f) * DD_P1 + \
  676. (unsigned)(ptruint)(g)) * DD_P2) >> (s))
  677. #else
  678. #define ddHash(f,g,s) \
  679. ((((unsigned)(f) * DD_P1 + (unsigned)(g)) * DD_P2) >> (s))
  680. #endif
  681. /**
  682. @brief Hash function for the cache.
  683. @sideeffect none
  684. @see ddHash ddCHash2
  685. */
  686. #if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
  687. #define ddCHash(o,f,g,h,s) \
  688. ((((((unsigned)(ptruint)(f) + (unsigned)(ptruint)(o)) * DD_P1 + \
  689. (unsigned)(ptruint)(g)) * DD_P2 + \
  690. (unsigned)(ptruint)(h)) * DD_P3) >> (s))
  691. #else
  692. #define ddCHash(o,f,g,h,s) \
  693. ((((((unsigned)(f) + (unsigned)(o)) * DD_P1 + (unsigned)(g)) * DD_P2 + \
  694. (unsigned)(h)) * DD_P3) >> (s))
  695. #endif
  696. /**
  697. @brief Hash function for the cache for functions with two operands.
  698. @sideeffect none
  699. @see ddHash ddCHash
  700. */
  701. #if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
  702. #define ddCHash2(o,f,g,s) \
  703. (((((unsigned)(ptruint)(f) + (unsigned)(ptruint)(o)) * DD_P1 + \
  704. (unsigned)(ptruint)(g)) * DD_P2) >> (s))
  705. #else
  706. #define ddCHash2(o,f,g,s) \
  707. (((((unsigned)(f) + (unsigned)(o)) * DD_P1 + (unsigned)(g)) * DD_P2) >> (s))
  708. #endif
  709. /**
  710. @brief Clears the 4 least significant bits of a pointer.
  711. @sideeffect none
  712. */
  713. #define cuddClean(p) ((DdNode *)((ptruint)(p) & ~ (ptruint) 0xf))
  714. /**
  715. @brief Computes the minimum of two numbers.
  716. @sideeffect none
  717. @see ddMax
  718. */
  719. #define ddMin(x,y) (((y) < (x)) ? (y) : (x))
  720. /**
  721. @brief Computes the maximum of two numbers.
  722. @sideeffect none
  723. @see ddMin
  724. */
  725. #define ddMax(x,y) (((y) > (x)) ? (y) : (x))
  726. /**
  727. @brief Computes the absolute value of a number.
  728. @sideeffect none
  729. */
  730. #define ddAbs(x) (((x)<0) ? -(x) : (x))
  731. /**
  732. @brief Returns 1 if the absolute value of the difference of the two
  733. arguments x and y is less than e.
  734. @sideeffect none
  735. */
  736. #define ddEqualVal(x,y,e) (ddAbs((x)-(y))<(e))
  737. /**
  738. @brief Saturating increment operator.
  739. @details Saturation is only necessary on 32-bit machines, where the
  740. reference count is only 16-bit wide.
  741. @sideeffect none
  742. @see cuddSatDec
  743. */
  744. #if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
  745. #define cuddSatInc(x) ((x)++)
  746. #else
  747. #define cuddSatInc(x) ((x) += (x) != (DdHalfWord)DD_MAXREF)
  748. #endif
  749. /**
  750. @brief Saturating decrement operator.
  751. @details Saturation is only necessary on 32-bit machines, where the
  752. reference count is only 16-bit wide.
  753. @sideeffect none
  754. @see cuddSatInc
  755. */
  756. #if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
  757. #define cuddSatDec(x) ((x)--)
  758. #else
  759. #define cuddSatDec(x) ((x) -= (x) != (DdHalfWord)DD_MAXREF)
  760. #endif
  761. /**
  762. @brief Returns the constant 1 node.
  763. @sideeffect none
  764. @see DD_ZERO DD_PLUS_INFINITY DD_MINUS_INFINITY
  765. */
  766. #define DD_ONE(dd) ((dd)->one)
  767. /**
  768. @brief Returns the arithmetic 0 constant node.
  769. @details This is different from the logical zero. The latter is
  770. obtained by Cudd_Not(DD_ONE(dd)).
  771. @sideeffect none
  772. @see DD_ONE Cudd_Not DD_PLUS_INFINITY DD_MINUS_INFINITY
  773. */
  774. #define DD_ZERO(dd) ((dd)->zero)
  775. /**
  776. @brief Returns the plus infinity constant node.
  777. @sideeffect none
  778. @see DD_ONE DD_ZERO DD_MINUS_INFINITY
  779. */
  780. #define DD_PLUS_INFINITY(dd) ((dd)->plusinfinity)
  781. /**
  782. @brief Returns the minus infinity constant node.
  783. @sideeffect none
  784. @see DD_ONE DD_ZERO DD_PLUS_INFINITY
  785. */
  786. #define DD_MINUS_INFINITY(dd) ((dd)->minusinfinity)
  787. /**
  788. @brief Enforces DD_MINUS_INF_VAL <= x <= DD_PLUS_INF_VAL.
  789. @details Furthermore, if x <= DD_MINUS_INF_VAL/2, x is set to
  790. DD_MINUS_INF_VAL. Similarly, if DD_PLUS_INF_VAL/2 <= x, x is set to
  791. DD_PLUS_INF_VAL. Normally this macro is a NOOP. However, if
  792. HAVE_IEEE_754 is not defined, it makes sure that a value does not
  793. get larger than infinity in absolute value, and once it gets to
  794. infinity, stays there. If the value overflows before this macro is
  795. applied, no recovery is possible.
  796. @sideeffect none
  797. */
  798. #ifdef HAVE_IEEE_754
  799. #define cuddAdjust(x)
  800. #else
  801. #define cuddAdjust(x) ((x) = ((x) >= DD_CRI_HI_MARK) ? DD_PLUS_INF_VAL : (((x) <= DD_CRI_LO_MARK) ? DD_MINUS_INF_VAL : (x)))
  802. #endif
  803. /**
  804. @brief Outputs a line of stats.
  805. @details Outputs a line of stats if DD_COUNT and DD_STATS are
  806. defined. Increments the number of recursive calls if DD_COUNT is
  807. defined.
  808. @sideeffect None
  809. */
  810. #ifdef DD_COUNT
  811. #ifdef DD_STATS
  812. #define statLine(dd) \
  813. do { \
  814. (dd)->recursiveCalls++; \
  815. if ((dd)->recursiveCalls == (dd)->nextSample) { \
  816. (void) fprintf((dd)->err, \
  817. "@%.0f: %u nodes %u live %.0f dropped" \
  818. " %.0f reclaimed\n", \
  819. (dd)->recursiveCalls, (dd)->keys, \
  820. (dd)->keys - (dd)->dead, \
  821. (dd)->nodesDropped, (dd)->reclaimed); \
  822. (dd)->nextSample += 250000;} \
  823. } while (0)
  824. #else
  825. #define statLine(dd) (dd)->recursiveCalls++
  826. #endif
  827. #else
  828. #define statLine(dd)
  829. #endif
  830. /**
  831. @brief Checks for termination or timeout.
  832. */
  833. #define checkWhetherToGiveUp(dd) \
  834. do { \
  835. if (((int64_t) CUDD_CHECK_MASK & (int64_t) (dd)->cacheMisses) == 0) { \
  836. if ((dd)->terminationCallback != NULL && \
  837. (dd)->terminationCallback((dd)->tcbArg)) { \
  838. (dd)->errorCode = CUDD_TERMINATION; \
  839. return(NULL); \
  840. } \
  841. if (util_cpu_time() - (dd)->startTime > (dd)->timeLimit) { \
  842. (dd)->errorCode = CUDD_TIMEOUT_EXPIRED; \
  843. return(NULL); \
  844. } \
  845. } \
  846. } while (0)
  847. /** \cond */
  848. /*---------------------------------------------------------------------------*/
  849. /* Function prototypes */
  850. /*---------------------------------------------------------------------------*/
  851. #ifdef __cplusplus
  852. extern "C" {
  853. #endif
  854. extern DdNode * cuddAddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube);
  855. extern DdNode * cuddAddUnivAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube);
  856. extern DdNode * cuddAddOrAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube);
  857. extern DdNode * cuddAddMinAbstractRecur (DdManager *manager, DdNode *f, DdNode *cube);
  858. extern DdNode * cuddAddMinExcept0AbstractRecur (DdManager *manager, DdNode *f, DdNode *cube);
  859. extern DdNode * cuddAddMaxAbstractRecur (DdManager *manager, DdNode *f, DdNode *cube);
  860. extern DdNode * cuddAddMinAbstractRepresentativeRecur(DdManager * manager, DdNode * f, DdNode * cube);
  861. extern DdNode * cuddAddMaxAbstractRepresentativeRecur(DdManager * manager, DdNode * f, DdNode * cube);
  862. extern DdNode * cuddAddApplyRecur(DdManager *dd, DdNode * (*)(DdManager *, DdNode **, DdNode **), DdNode *f, DdNode *g);
  863. extern DdNode * cuddAddToBddApplyRecur(DdManager *dd, DdNode * (*)(DdManager *, DdNode **, DdNode **), DdNode *f, DdNode *g);
  864. extern DdNode * cuddAddMonadicApplyRecur(DdManager * dd, DdNode * (*op)(DdManager *, DdNode *), DdNode * f);
  865. extern DdNode * cuddAddScalarInverseRecur(DdManager *dd, DdNode *f, DdNode *epsilon);
  866. extern DdNode * cuddAddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h);
  867. extern DdNode * cuddAddCmplRecur(DdManager *dd, DdNode *f);
  868. extern DdNode * cuddAddNegateRecur(DdManager *dd, DdNode *f);
  869. extern DdNode * cuddAddRoundOffRecur(DdManager *dd, DdNode *f, double trunc);
  870. extern DdNode * cuddUnderApprox(DdManager *dd, DdNode *f, int numVars, int threshold, int safe, double quality);
  871. extern DdNode * cuddRemapUnderApprox(DdManager *dd, DdNode *f, int numVars, int threshold, double quality);
  872. extern DdNode * cuddBiasedUnderApprox(DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0);
  873. extern DdNode * cuddBddAndAbstractRecur(DdManager *manager, DdNode *f, DdNode *g, DdNode *cube);
  874. extern int cuddAnnealing(DdManager *table, int lower, int upper);
  875. extern DdNode * cuddBddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube);
  876. extern DdNode * cuddBddExistAbstractRepresentativeRecur(DdManager *manager, DdNode *f, DdNode *cube);
  877. extern DdNode * cuddBddXorExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *g, DdNode *cube);
  878. extern DdNode * cuddBddBooleanDiffRecur(DdManager *manager, DdNode *f, DdNode *var);
  879. extern DdNode * cuddBddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h);
  880. extern DdNode * cuddBddIntersectRecur(DdManager *dd, DdNode *f, DdNode *g);
  881. extern DdNode * cuddBddAndRecur(DdManager *manager, DdNode *f, DdNode *g);
  882. extern DdNode * cuddBddXorRecur(DdManager *manager, DdNode *f, DdNode *g);
  883. extern DdNode * cuddBddTransfer(DdManager *ddS, DdManager *ddD, DdNode *f);
  884. extern DdNode * cuddAddBddDoPattern(DdManager *dd, DdNode *f);
  885. extern int cuddInitCache(DdManager *unique, unsigned int cacheSize, unsigned int maxCacheSize);
  886. extern void cuddCacheInsert(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h, DdNode *data);
  887. extern void cuddCacheInsert2(DdManager *table, DdNode * (*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g, DdNode *data);
  888. extern void cuddCacheInsert1(DdManager *table, DdNode * (*)(DdManager *, DdNode *), DdNode *f, DdNode *data);
  889. extern DdNode * cuddCacheLookup(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h);
  890. extern DdNode * cuddCacheLookupZdd(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h);
  891. extern DdNode * cuddCacheLookup2(DdManager *table, DdNode * (*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g);
  892. extern DdNode * cuddCacheLookup1(DdManager *table, DdNode * (*)(DdManager *, DdNode *), DdNode *f);
  893. extern DdNode * cuddCacheLookup2Zdd(DdManager *table, DdNode * (*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g);
  894. extern DdNode * cuddCacheLookup1Zdd(DdManager *table, DdNode * (*)(DdManager *, DdNode *), DdNode *f);
  895. extern DdNode * cuddConstantLookup(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h);
  896. extern int cuddCacheProfile(DdManager *table, FILE *fp);
  897. extern void cuddCacheResize(DdManager *table);
  898. extern void cuddCacheFlush(DdManager *table);
  899. extern int cuddComputeFloorLog2(unsigned int value);
  900. extern int cuddHeapProfile(DdManager *dd);
  901. extern void cuddPrintNode(DdNode *f, FILE *fp);
  902. extern void cuddPrintVarGroups(DdManager * dd, MtrNode * root, int zdd, int silent);
  903. extern DdNode * cuddBddClippingAnd(DdManager *dd, DdNode *f, DdNode *g, int maxDepth, int direction);
  904. extern DdNode * cuddBddClippingAndAbstract(DdManager *dd, DdNode *f, DdNode *g, DdNode *cube, int maxDepth, int direction);
  905. extern void cuddGetBranches(DdNode *g, DdNode **g1, DdNode **g0);
  906. extern DdNode * cuddCofactorRecur(DdManager *dd, DdNode *f, DdNode *g);
  907. extern DdNode * cuddBddComposeRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *proj);
  908. extern DdNode * cuddAddComposeRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *proj);
  909. extern int cuddExact(DdManager *table, int lower, int upper);
  910. extern DdNode * cuddBddConstrainRecur(DdManager *dd, DdNode *f, DdNode *c);
  911. extern DdNode * cuddBddRestrictRecur(DdManager *dd, DdNode *f, DdNode *c);
  912. extern DdNode * cuddBddNPAndRecur(DdManager *dd, DdNode *f, DdNode *c);
  913. extern DdNode * cuddAddConstrainRecur(DdManager *dd, DdNode *f, DdNode *c);
  914. extern DdNode * cuddAddRestrictRecur(DdManager *dd, DdNode *f, DdNode *c);
  915. extern DdNode * cuddBddLICompaction(DdManager *dd, DdNode *f, DdNode *c);
  916. extern int cuddGa(DdManager *table, int lower, int upper);
  917. extern int cuddTreeSifting(DdManager *table, Cudd_ReorderingType method);
  918. extern int cuddZddInitUniv(DdManager *zdd);
  919. extern void cuddZddFreeUniv(DdManager *zdd);
  920. extern void cuddSetInteract(DdManager *table, int x, int y);
  921. extern int cuddTestInteract(DdManager *table, int x, int y);
  922. extern int cuddInitInteract(DdManager *table);
  923. extern DdLocalCache * cuddLocalCacheInit(DdManager *manager, unsigned int keySize, unsigned int cacheSize, unsigned int maxCacheSize);
  924. extern void cuddLocalCacheQuit(DdLocalCache *cache);
  925. extern void cuddLocalCacheInsert(DdLocalCache *cache, DdNodePtr *key, DdNode *value);
  926. extern DdNode * cuddLocalCacheLookup(DdLocalCache *cache, DdNodePtr *key);
  927. extern void cuddLocalCacheClearDead(DdManager *manager);
  928. extern int cuddIsInDeathRow(DdManager *dd, DdNode *f);
  929. extern int cuddTimesInDeathRow(DdManager *dd, DdNode *f);
  930. extern void cuddLocalCacheClearAll(DdManager *manager);
  931. #ifdef DD_CACHE_PROFILE
  932. extern int cuddLocalCacheProfile(DdLocalCache *cache);
  933. #endif
  934. extern DdHashTable * cuddHashTableInit(DdManager *manager, unsigned int keySize, unsigned int initSize);
  935. extern void cuddHashTableQuit(DdHashTable *hash);
  936. extern void cuddHashTableGenericQuit(DdHashTable *hash);
  937. extern int cuddHashTableInsert(DdHashTable *hash, DdNodePtr *key, DdNode *value, ptrint count);
  938. extern DdNode * cuddHashTableLookup(DdHashTable *hash, DdNodePtr *key);
  939. extern int cuddHashTableInsert1(DdHashTable *hash, DdNode *f, DdNode *value, ptrint count);
  940. extern DdNode * cuddHashTableLookup1(DdHashTable *hash, DdNode *f);
  941. extern int cuddHashTableInsert2(DdHashTable *hash, DdNode *f, DdNode *g, DdNode *value, ptrint count);
  942. extern DdNode * cuddHashTableLookup2(DdHashTable *hash, DdNode *f, DdNode *g);
  943. extern int cuddHashTableInsert3(DdHashTable *hash, DdNode *f, DdNode *g, DdNode *h, DdNode *value, ptrint count);
  944. extern DdNode * cuddHashTableLookup3(DdHashTable *hash, DdNode *f, DdNode *g, DdNode *h);
  945. extern int cuddHashTableGenericInsert(DdHashTable * hash, DdNode * f, void * value);
  946. extern void * cuddHashTableGenericLookup(DdHashTable * hash, DdNode * f);
  947. extern DdLevelQueue * cuddLevelQueueInit(int levels, int itemSize, int numBuckets, DdManager * manager);
  948. extern void cuddLevelQueueQuit(DdLevelQueue *queue);
  949. extern void * cuddLevelQueueFirst(DdLevelQueue * queue, void * key, int level);
  950. extern void * cuddLevelQueueEnqueue(DdLevelQueue *queue, void *key, int level);
  951. extern void cuddLevelQueueDequeue(DdLevelQueue *queue, int level);
  952. extern int cuddLinearAndSifting(DdManager *table, int lower, int upper);
  953. extern int cuddLinearInPlace(DdManager * table, int x, int y);
  954. extern void cuddUpdateInteractionMatrix(DdManager * table, int xindex, int yindex);
  955. extern int cuddInitLinear(DdManager *table);
  956. extern int cuddResizeLinear(DdManager *table);
  957. extern DdNode * cuddBddLiteralSetIntersectionRecur(DdManager *dd, DdNode *f, DdNode *g);
  958. extern DdNode * cuddCProjectionRecur(DdManager *dd, DdNode *R, DdNode *Y, DdNode *Ysupp);
  959. extern DdNode * cuddBddClosestCube(DdManager *dd, DdNode *f, DdNode *g, CUDD_VALUE_TYPE bound);
  960. extern void cuddReclaim(DdManager *table, DdNode *n);
  961. extern void cuddReclaimZdd(DdManager *table, DdNode *n);
  962. extern void cuddClearDeathRow(DdManager *table);
  963. extern void cuddShrinkDeathRow(DdManager *table);
  964. extern DdNode * cuddDynamicAllocNode(DdManager *table);
  965. extern int cuddSifting(DdManager *table, int lower, int upper);
  966. extern int cuddSwapping(DdManager *table, int lower, int upper, Cudd_ReorderingType heuristic);
  967. extern int cuddNextHigh(DdManager *table, int x);
  968. extern int cuddNextLow(DdManager *table, int x);
  969. extern int cuddSwapInPlace(DdManager *table, int x, int y);
  970. extern int cuddBddAlignToZdd(DdManager *table);
  971. extern DdNode * cuddBddMakePrime(DdManager *dd, DdNode *cube, DdNode *f);
  972. extern DdNode * cuddSolveEqnRecur(DdManager *bdd, DdNode *F, DdNode *Y, DdNode **G, int n, int *yIndex, int i);
  973. extern DdNode * cuddVerifySol(DdManager *bdd, DdNode *F, DdNode **G, int *yIndex, int n);
  974. #ifdef ST_H_
  975. extern DdNode* cuddSplitSetRecur(DdManager *manager, st_table *mtable, int *varSeen, DdNode *p, double n, double max, int index);
  976. #endif
  977. extern DdNode * cuddSubsetHeavyBranch(DdManager *dd, DdNode *f, int numVars, int threshold);
  978. extern DdNode * cuddSubsetShortPaths(DdManager *dd, DdNode *f, int numVars, int threshold, int hardlimit);
  979. extern int cuddSymmCheck(DdManager *table, int x, int y);
  980. extern int cuddSymmSifting(DdManager *table, int lower, int upper);
  981. extern int cuddSymmSiftingConv(DdManager *table, int lower, int upper);
  982. extern DdNode * cuddAllocNode(DdManager *unique);
  983. extern DdManager * cuddInitTable(unsigned int numVars, unsigned int numVarsZ, unsigned int numSlots, unsigned int looseUpTo);
  984. extern void cuddFreeTable(DdManager *unique);
  985. extern int cuddGarbageCollect(DdManager *unique, int clearCache);
  986. extern DdNode * cuddZddGetNode(DdManager *zdd, int id, DdNode *T, DdNode *E);
  987. extern DdNode * cuddZddGetNodeIVO(DdManager *dd, int index, DdNode *g, DdNode *h);
  988. extern DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E);
  989. extern DdNode * cuddUniqueInterIVO(DdManager *unique, int index, DdNode *T, DdNode *E);
  990. extern DdNode * cuddUniqueInterZdd(DdManager *unique, int index, DdNode *T, DdNode *E);
  991. extern DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value);
  992. extern void cuddRehash(DdManager *unique, int i);
  993. extern void cuddShrinkSubtable(DdManager *unique, int i);
  994. extern int cuddInsertSubtables(DdManager *unique, int n, int level);
  995. extern int cuddDestroySubtables(DdManager *unique, int n);
  996. extern int cuddResizeTableZdd(DdManager *unique, int index);
  997. extern void cuddSlowTableGrowth(DdManager *unique);
  998. extern int cuddP(DdManager *dd, DdNode *f);
  999. #ifdef ST_H_
  1000. extern enum st_retval cuddStCountfree(void *key, void *value, void *arg);
  1001. extern int cuddCollectNodes(DdNode *f, st_table *visited);
  1002. #endif
  1003. extern DdNodePtr * cuddNodeArray(DdNode *f, int *n);
  1004. extern int cuddWindowReorder(DdManager *table, int low, int high, Cudd_ReorderingType submethod);
  1005. extern DdNode * cuddZddProduct(DdManager *dd, DdNode *f, DdNode *g);
  1006. extern DdNode * cuddZddUnateProduct(DdManager *dd, DdNode *f, DdNode *g);
  1007. extern DdNode * cuddZddWeakDiv(DdManager *dd, DdNode *f, DdNode *g);
  1008. extern DdNode * cuddZddWeakDivF(DdManager *dd, DdNode *f, DdNode *g);
  1009. extern DdNode * cuddZddDivide(DdManager *dd, DdNode *f, DdNode *g);
  1010. extern DdNode * cuddZddDivideF(DdManager *dd, DdNode *f, DdNode *g);
  1011. extern int cuddZddGetCofactors3(DdManager *dd, DdNode *f, int v, DdNode **f1, DdNode **f0, DdNode **fd);
  1012. extern int cuddZddGetCofactors2(DdManager *dd, DdNode *f, int v, DdNode **f1, DdNode **f0);
  1013. extern DdNode * cuddZddComplement(DdManager *dd, DdNode *node);
  1014. extern int cuddZddGetPosVarIndex(DdManager * dd, int index);
  1015. extern int cuddZddGetNegVarIndex(DdManager * dd, int index);
  1016. extern int cuddZddGetPosVarLevel(DdManager * dd, int index);
  1017. extern int cuddZddGetNegVarLevel(DdManager * dd, int index);
  1018. extern int cuddZddTreeSifting(DdManager *table, Cudd_ReorderingType method);
  1019. extern DdNode * cuddZddIsop(DdManager *dd, DdNode *L, DdNode *U, DdNode **zdd_I);
  1020. extern DdNode * cuddBddIsop(DdManager *dd, DdNode *L, DdNode *U);
  1021. extern DdNode * cuddMakeBddFromZddCover(DdManager *dd, DdNode *node);
  1022. extern int cuddZddLinearSifting(DdManager *table, int lower, int upper);
  1023. extern int cuddZddAlignToBdd(DdManager *table);
  1024. extern int cuddZddNextHigh(DdManager *table, int x);
  1025. extern int cuddZddNextLow(DdManager *table, int x);
  1026. extern int cuddZddUniqueCompare(void const *ptr_x, void const *ptr_y);
  1027. extern int cuddZddSwapInPlace(DdManager *table, int x, int y);
  1028. extern int cuddZddSwapping(DdManager *table, int lower, int upper, Cudd_ReorderingType heuristic);
  1029. extern int cuddZddSifting(DdManager *table, int lower, int upper);
  1030. extern DdNode * cuddZddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h);
  1031. extern DdNode * cuddZddUnion(DdManager *zdd, DdNode *P, DdNode *Q);
  1032. extern DdNode * cuddZddIntersect(DdManager *zdd, DdNode *P, DdNode *Q);
  1033. extern DdNode * cuddZddDiff(DdManager *zdd, DdNode *P, DdNode *Q);
  1034. extern DdNode * cuddZddChangeAux(DdManager *zdd, DdNode *P, DdNode *zvar);
  1035. extern DdNode * cuddZddSubset1(DdManager *dd, DdNode *P, int var);
  1036. extern DdNode * cuddZddSubset0(DdManager *dd, DdNode *P, int var);
  1037. extern DdNode * cuddZddChange(DdManager *dd, DdNode *P, int var);
  1038. extern int cuddZddSymmCheck(DdManager *table, int x, int y);
  1039. extern int cuddZddSymmSifting(DdManager *table, int lower, int upper);
  1040. extern int cuddZddSymmSiftingConv(DdManager *table, int lower, int upper);
  1041. extern int cuddZddP(DdManager *zdd, DdNode *f);
  1042. #ifdef __cplusplus
  1043. } /* end of extern "C" */
  1044. #endif
  1045. /** \endcond */
  1046. #endif /* CUDD_INT_H_ */