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.

769 lines
29 KiB

  1. /**
  2. @file
  3. @ingroup cplusplus
  4. @brief Class definitions for C++ object-oriented encapsulation of
  5. CUDD.
  6. @author Fabio Somenzi
  7. @copyright@parblock
  8. Copyright (c) 1995-2015, Regents of the University of Colorado
  9. All rights reserved.
  10. Redistribution and use in source and binary forms, with or without
  11. modification, are permitted provided that the following conditions
  12. are met:
  13. Redistributions of source code must retain the above copyright
  14. notice, this list of conditions and the following disclaimer.
  15. Redistributions in binary form must reproduce the above copyright
  16. notice, this list of conditions and the following disclaimer in the
  17. documentation and/or other materials provided with the distribution.
  18. Neither the name of the University of Colorado nor the names of its
  19. contributors may be used to endorse or promote products derived from
  20. this software without specific prior written permission.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  28. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. POSSIBILITY OF SUCH DAMAGE.
  33. @endparblock
  34. */
  35. #ifndef CUDD_OBJ_H_
  36. #define CUDD_OBJ_H_
  37. /*---------------------------------------------------------------------------*/
  38. /* Nested includes */
  39. /*---------------------------------------------------------------------------*/
  40. #include <cstdio>
  41. #include <string>
  42. #include <vector>
  43. #include "mtr.h"
  44. #include "cudd.h"
  45. namespace cudd {
  46. /*---------------------------------------------------------------------------*/
  47. /* Type definitions */
  48. /*---------------------------------------------------------------------------*/
  49. class BDD;
  50. class ADD;
  51. class ZDD;
  52. class Cudd;
  53. typedef void (*PFC)(std::string); // handler function type
  54. /*---------------------------------------------------------------------------*/
  55. /* Class definitions */
  56. /*---------------------------------------------------------------------------*/
  57. class Capsule;
  58. /**
  59. @brief Base class for all decision diagrams in CUDD.
  60. @see Cudd ABDD ADD BDD ZDD
  61. */
  62. class DD {
  63. protected:
  64. Capsule *p;
  65. DdNode *node;
  66. inline DdManager * checkSameManager(const DD &other) const;
  67. inline void checkReturnValue(const void *result) const;
  68. inline void checkReturnValue(int result, int expected = 1)
  69. const;
  70. DD();
  71. DD(Capsule *cap, DdNode *ddNode);
  72. DD(Cudd const & manager, DdNode *ddNode);
  73. DD(const DD &from);
  74. ~DD();
  75. public:
  76. // This operator should be declared explicit, but there are still too many
  77. // compilers out there that do not support this C++11 feature.
  78. operator bool() const { return node; }
  79. DdManager * manager() const;
  80. DdNode * getNode() const;
  81. DdNode * getRegularNode() const;
  82. int nodeCount() const;
  83. unsigned int NodeReadIndex() const;
  84. }; // DD
  85. /**
  86. @brief Class for ADDs and BDDs.
  87. @see Cudd ADD BDD
  88. */
  89. class ABDD : public DD {
  90. friend class Cudd;
  91. protected:
  92. ABDD();
  93. ABDD(Capsule *cap, DdNode *bddNode);
  94. ABDD(Cudd const & manager, DdNode *ddNode);
  95. ABDD(const ABDD &from);
  96. ~ABDD();
  97. public:
  98. bool operator==(const ABDD &other) const;
  99. bool operator!=(const ABDD &other) const;
  100. void print(int nvars, int verbosity = 1) const;
  101. void summary(int nvars, int mode = 0) const;
  102. DdApaNumber ApaCountMinterm(int nvars, int * digits) const;
  103. void ApaPrintMinterm(int nvars, FILE * fp = stdout) const;
  104. void ApaPrintMintermExp(int nvars, int precision = 6, FILE * fp = stdout) const;
  105. void EpdPrintMinterm(int nvars, FILE * fp = stdout) const;
  106. long double LdblCountMinterm(int nvars) const;
  107. bool IsOne() const;
  108. bool IsCube() const;
  109. BDD FindEssential() const;
  110. void PrintTwoLiteralClauses(char ** names = 0, FILE * fp = stdout) const;
  111. BDD ShortestPath(int * weight, int * support, int * length) const;
  112. BDD LargestCube(int * length = 0) const;
  113. int ShortestLength(int * weight = 0) const;
  114. bool EquivDC(const ABDD& G, const ABDD& D) const;
  115. double * CofMinterm() const;
  116. void PrintMinterm() const;
  117. double CountMinterm(int nvars) const;
  118. double CountPath() const;
  119. BDD Support() const;
  120. int SupportSize() const;
  121. std::vector<unsigned int> SupportIndices() const;
  122. void ClassifySupport(const ABDD& g, BDD* common, BDD* onlyF, BDD* onlyG)
  123. const;
  124. int CountLeaves() const;
  125. DdGen * FirstCube(int ** cube, CUDD_VALUE_TYPE * value) const;
  126. static int NextCube(DdGen * gen, int ** cube, CUDD_VALUE_TYPE * value);
  127. double Density(int nvars) const;
  128. }; // ABDD
  129. /**
  130. @brief Class for BDDs.
  131. @see Cudd
  132. */
  133. class BDD : public ABDD {
  134. friend class Cudd;
  135. public:
  136. BDD();
  137. BDD(Capsule *cap, DdNode *bddNode);
  138. BDD(Cudd const & manager, DdNode *ddNode);
  139. BDD(const BDD &from);
  140. BDD operator=(const BDD& right);
  141. bool operator<=(const BDD& other) const;
  142. bool operator>=(const BDD& other) const;
  143. bool operator<(const BDD& other) const;
  144. bool operator>(const BDD& other) const;
  145. BDD operator!() const;
  146. BDD operator~() const;
  147. BDD operator*(const BDD& other) const;
  148. BDD operator*=(const BDD& other);
  149. BDD operator&(const BDD& other) const;
  150. BDD operator&=(const BDD& other);
  151. BDD operator+(const BDD& other) const;
  152. BDD operator+=(const BDD& other);
  153. BDD operator|(const BDD& other) const;
  154. BDD operator|=(const BDD& other);
  155. BDD operator^(const BDD& other) const;
  156. BDD operator^=(const BDD& other);
  157. BDD operator-(const BDD& other) const;
  158. BDD operator-=(const BDD& other);
  159. friend std::ostream & operator<<(std::ostream & os, BDD const & f);
  160. bool IsZero() const;
  161. bool IsVar() const;
  162. BDD AndAbstract(const BDD& g, const BDD& cube, unsigned int limit = 0)
  163. const;
  164. BDD UnderApprox(
  165. int numVars,
  166. int threshold = 0,
  167. bool safe = false,
  168. double quality = 1.0) const;
  169. BDD OverApprox(
  170. int numVars,
  171. int threshold = 0,
  172. bool safe = false,
  173. double quality = 1.0) const;
  174. BDD RemapUnderApprox(int numVars, int threshold = 0, double quality = 1.0)
  175. const;
  176. BDD RemapOverApprox(int numVars, int threshold = 0, double quality = 1.0)
  177. const;
  178. BDD BiasedUnderApprox(const BDD& bias, int numVars, int threshold = 0,
  179. double quality1 = 1.0, double quality0 = 1.0) const;
  180. BDD BiasedOverApprox(const BDD& bias, int numVars, int threshold = 0,
  181. double quality1 = 1.0, double quality0 = 1.0) const;
  182. BDD ExistAbstract(const BDD& cube, unsigned int limit = 0) const;
  183. BDD XorExistAbstract(const BDD& g, const BDD& cube) const;
  184. BDD UnivAbstract(const BDD& cube) const;
  185. BDD BooleanDiff(int x) const;
  186. bool VarIsDependent(const BDD& var) const;
  187. double Correlation(const BDD& g) const;
  188. double CorrelationWeights(const BDD& g, double * prob) const;
  189. BDD Ite(const BDD& g, const BDD& h, unsigned int limit = 0) const;
  190. BDD IteConstant(const BDD& g, const BDD& h) const;
  191. BDD Intersect(const BDD& g) const;
  192. BDD And(const BDD& g, unsigned int limit = 0) const;
  193. BDD Or(const BDD& g, unsigned int limit = 0) const;
  194. BDD Nand(const BDD& g) const;
  195. BDD Nor(const BDD& g) const;
  196. BDD Xor(const BDD& g) const;
  197. BDD Xnor(const BDD& g, unsigned int limit = 0) const;
  198. bool Leq(const BDD& g) const;
  199. ADD Add() const;
  200. BDD Transfer(Cudd& destination) const;
  201. BDD ClippingAnd(const BDD& g, int maxDepth, int direction = 0) const;
  202. BDD ClippingAndAbstract(const BDD& g, const BDD& cube, int maxDepth,
  203. int direction = 0) const;
  204. BDD Cofactor(const BDD& g) const;
  205. bool VarAreSymmetric(int index1, int index2) const;
  206. BDD Compose(const BDD& g, int v) const;
  207. BDD Permute(int * permut) const;
  208. BDD SwapVariables(std::vector<BDD> x, std::vector<BDD> y) const;
  209. BDD AdjPermuteX(std::vector<BDD> x) const;
  210. BDD VectorCompose(std::vector<BDD> vector) const;
  211. void ApproxConjDecomp(BDD* g, BDD* h) const;
  212. void ApproxDisjDecomp(BDD* g, BDD* h) const;
  213. void IterConjDecomp(BDD* g, BDD* h) const;
  214. void IterDisjDecomp(BDD* g, BDD* h) const;
  215. void GenConjDecomp(BDD* g, BDD* h) const;
  216. void GenDisjDecomp(BDD* g, BDD* h) const;
  217. void VarConjDecomp(BDD* g, BDD* h) const;
  218. void VarDisjDecomp(BDD* g, BDD* h) const;
  219. bool IsVarEssential(int id, int phase) const;
  220. BDD Constrain(const BDD& c) const;
  221. BDD Restrict(const BDD& c) const;
  222. BDD NPAnd(const BDD& g) const;
  223. std::vector<BDD> ConstrainDecomp() const;
  224. std::vector<BDD> CharToVect() const;
  225. BDD LICompaction(const BDD& c) const;
  226. BDD Squeeze(const BDD& u) const;
  227. BDD Interpolate(const BDD& u) const;
  228. BDD Minimize(const BDD& c) const;
  229. BDD SubsetCompress(int nvars, int threshold) const;
  230. BDD SupersetCompress(int nvars, int threshold) const;
  231. BDD LiteralSetIntersection(const BDD& g) const;
  232. BDD PrioritySelect(std::vector<BDD> x, std::vector<BDD> y,
  233. std::vector<BDD> z, const BDD& Pi, DD_PRFP Pifunc) const;
  234. BDD CProjection(const BDD& Y) const;
  235. int MinHammingDist(int *minterm, int upperBound) const;
  236. BDD Eval(int * inputs) const;
  237. BDD Decreasing(int i) const;
  238. BDD Increasing(int i) const;
  239. bool LeqUnless(const BDD& G, const BDD& D) const;
  240. BDD MakePrime(const BDD& F) const;
  241. BDD MaximallyExpand(const BDD& ub, const BDD& f);
  242. BDD LargestPrimeUnate(const BDD& phases);
  243. BDD SolveEqn(const BDD& Y, std::vector<BDD> & G, int ** yIndex, int n) const;
  244. BDD VerifySol(std::vector<BDD> const & G, int * yIndex) const;
  245. BDD SplitSet(std::vector<BDD> xVars, double m) const;
  246. BDD SubsetHeavyBranch(int numVars, int threshold) const;
  247. BDD SupersetHeavyBranch(int numVars, int threshold) const;
  248. BDD SubsetShortPaths(int numVars, int threshold, bool hardlimit = false) const;
  249. BDD SupersetShortPaths(int numVars, int threshold, bool hardlimit = false) const;
  250. void PrintCover() const;
  251. void PrintCover(const BDD& u) const;
  252. int EstimateCofactor(int i, int phase) const;
  253. int EstimateCofactorSimple(int i) const;
  254. void PickOneCube(char * string) const;
  255. BDD PickOneMinterm(std::vector<BDD> vars) const;
  256. BDD zddIsop(const BDD& U, ZDD* zdd_I) const;
  257. BDD Isop(const BDD& U) const;
  258. ZDD PortToZdd() const;
  259. void PrintFactoredForm(char const * const * inames = 0, FILE * fp = stdout) const;
  260. std::string FactoredFormString(char const * const * inames = 0) const;
  261. }; // BDD
  262. /**
  263. @brief Class for ADDs.
  264. @see Cudd
  265. */
  266. class ADD : public ABDD {
  267. friend class Cudd;
  268. public:
  269. ADD();
  270. ADD(Capsule *cap, DdNode *bddNode);
  271. ADD(Cudd const & manager, DdNode *ddNode);
  272. ADD(const ADD &from);
  273. ADD operator=(const ADD& right);
  274. // Relational operators
  275. bool operator<=(const ADD& other) const;
  276. bool operator>=(const ADD& other) const;
  277. bool operator<(const ADD& other) const;
  278. bool operator>(const ADD& other) const;
  279. // Arithmetic operators
  280. ADD operator-() const;
  281. ADD operator*(const ADD& other) const;
  282. ADD operator*=(const ADD& other);
  283. ADD operator+(const ADD& other) const;
  284. ADD operator+=(const ADD& other);
  285. ADD operator-(const ADD& other) const;
  286. ADD operator-=(const ADD& other);
  287. // Logical operators
  288. ADD operator~() const;
  289. ADD operator&(const ADD& other) const;
  290. ADD operator&=(const ADD& other);
  291. ADD operator|(const ADD& other) const;
  292. ADD operator|=(const ADD& other);
  293. bool IsZero() const;
  294. ADD ExistAbstract(const ADD& cube) const;
  295. ADD UnivAbstract(const ADD& cube) const;
  296. ADD OrAbstract(const ADD& cube) const;
  297. ADD MinAbstract(const ADD& cube) const;
  298. ADD MaxAbstract(const ADD& cube) const;
  299. ADD Plus(const ADD& g) const;
  300. ADD Times(const ADD& g) const;
  301. ADD Threshold(const ADD& g) const;
  302. ADD SetNZ(const ADD& g) const;
  303. ADD Divide(const ADD& g) const;
  304. ADD Minus(const ADD& g) const;
  305. ADD Minimum(const ADD& g) const;
  306. ADD Maximum(const ADD& g) const;
  307. ADD OneZeroMaximum(const ADD& g) const;
  308. ADD Diff(const ADD& g) const;
  309. ADD Agreement(const ADD& g) const;
  310. ADD Or(const ADD& g) const;
  311. ADD Nand(const ADD& g) const;
  312. ADD Nor(const ADD& g) const;
  313. ADD Xor(const ADD& g) const;
  314. ADD Xnor(const ADD& g) const;
  315. ADD Pow(const ADD& g) const;
  316. ADD Mod(const ADD& g) const;
  317. ADD LogXY(const ADD& g) const;
  318. ADD Log() const;
  319. ADD Floor() const;
  320. ADD Ceil() const;
  321. ADD FindMax() const;
  322. ADD FindMin() const;
  323. ADD IthBit(int bit) const;
  324. ADD ScalarInverse(const ADD& epsilon) const;
  325. ADD Ite(const ADD& g, const ADD& h) const;
  326. ADD IteConstant(const ADD& g, const ADD& h) const;
  327. ADD EvalConst(const ADD& g) const;
  328. bool Leq(const ADD& g) const;
  329. ADD Cmpl() const;
  330. ADD Negate() const;
  331. ADD RoundOff(int N) const;
  332. ADD Equals(const ADD& g) const;
  333. ADD NotEquals(const ADD& g) const;
  334. ADD LessThan(const ADD& g) const;
  335. ADD LessThanOrEqual(const ADD& g) const;
  336. ADD GreaterThan(const ADD& g) const;
  337. ADD GreaterThanOrEqual(const ADD& g) const;
  338. BDD BddThreshold(CUDD_VALUE_TYPE value) const;
  339. BDD BddStrictThreshold(CUDD_VALUE_TYPE value) const;
  340. BDD BddInterval(CUDD_VALUE_TYPE lower, CUDD_VALUE_TYPE upper) const;
  341. BDD BddIthBit(int bit) const;
  342. BDD BddPattern() const;
  343. ADD Cofactor(const ADD& g) const;
  344. ADD Compose(const ADD& g, int v) const;
  345. ADD Permute(int * permut) const;
  346. ADD SwapVariables(std::vector<ADD> x, std::vector<ADD> y) const;
  347. ADD VectorCompose(std::vector<ADD> vector) const;
  348. ADD NonSimCompose(std::vector<ADD> vector) const;
  349. ADD Constrain(const ADD& c) const;
  350. ADD Restrict(const ADD& c) const;
  351. ADD MatrixMultiply(const ADD& B, std::vector<ADD> z) const;
  352. ADD TimesPlus(const ADD& B, std::vector<ADD> z) const;
  353. ADD Triangle(const ADD& g, std::vector<ADD> z) const;
  354. ADD Eval(int * inputs) const;
  355. bool EqualSupNorm(const ADD& g, CUDD_VALUE_TYPE tolerance, int pr = 0) const;
  356. bool EqualSupNormRel(const ADD& g, CUDD_VALUE_TYPE tolerance, int pr = 0) const;
  357. }; // ADD
  358. /**
  359. @brief Class for ZDDs.
  360. @see Cudd
  361. */
  362. class ZDD : public DD {
  363. friend class Cudd;
  364. public:
  365. ZDD(Capsule *cap, DdNode *bddNode);
  366. ZDD();
  367. ZDD(const ZDD &from);
  368. ~ZDD();
  369. ZDD operator=(const ZDD& right);
  370. bool operator==(const ZDD& other) const;
  371. bool operator!=(const ZDD& other) const;
  372. bool operator<=(const ZDD& other) const;
  373. bool operator>=(const ZDD& other) const;
  374. bool operator<(const ZDD& other) const;
  375. bool operator>(const ZDD& other) const;
  376. void print(int nvars, int verbosity = 1) const;
  377. ZDD operator*(const ZDD& other) const;
  378. ZDD operator*=(const ZDD& other);
  379. ZDD operator&(const ZDD& other) const;
  380. ZDD operator&=(const ZDD& other);
  381. ZDD operator+(const ZDD& other) const;
  382. ZDD operator+=(const ZDD& other);
  383. ZDD operator|(const ZDD& other) const;
  384. ZDD operator|=(const ZDD& other);
  385. ZDD operator-(const ZDD& other) const;
  386. ZDD operator-=(const ZDD& other);
  387. int Count() const;
  388. double CountDouble() const;
  389. ZDD Product(const ZDD& g) const;
  390. ZDD UnateProduct(const ZDD& g) const;
  391. ZDD WeakDiv(const ZDD& g) const;
  392. ZDD Divide(const ZDD& g) const;
  393. ZDD WeakDivF(const ZDD& g) const;
  394. ZDD DivideF(const ZDD& g) const;
  395. double CountMinterm(int path) const;
  396. BDD PortToBdd() const;
  397. ZDD Ite(const ZDD& g, const ZDD& h) const;
  398. ZDD Union(const ZDD& Q) const;
  399. ZDD Intersect(const ZDD& Q) const;
  400. ZDD Diff(const ZDD& Q) const;
  401. ZDD DiffConst(const ZDD& Q) const;
  402. ZDD Subset1(int var) const;
  403. ZDD Subset0(int var) const;
  404. ZDD Change(int var) const;
  405. void PrintMinterm() const;
  406. void PrintCover() const;
  407. BDD Support() const;
  408. }; // ZDD
  409. /**
  410. @brief Default error handler.
  411. */
  412. extern void defaultError(std::string message);
  413. /**
  414. @brief Class for CUDD managers.
  415. @see DD
  416. */
  417. class Cudd {
  418. friend class DD;
  419. friend class ABDD;
  420. friend class BDD;
  421. friend class ADD;
  422. friend class ZDD;
  423. friend std::ostream & operator<<(std::ostream & os, BDD const & f);
  424. private:
  425. Capsule *p;
  426. public:
  427. Cudd(
  428. unsigned int numVars = 0,
  429. unsigned int numVarsZ = 0,
  430. unsigned int numSlots = CUDD_UNIQUE_SLOTS,
  431. unsigned int cacheSize = CUDD_CACHE_SLOTS,
  432. unsigned long maxMemory = 0,
  433. PFC defaultHandler = defaultError);
  434. Cudd(const Cudd& x);
  435. ~Cudd(void);
  436. PFC setHandler(PFC newHandler) const;
  437. PFC getHandler(void) const;
  438. PFC setTimeoutHandler(PFC newHandler) const;
  439. PFC getTimeoutHandler(void) const;
  440. PFC setTerminationHandler(PFC newHandler) const;
  441. PFC getTerminationHandler(void) const;
  442. void pushVariableName(std::string s) const;
  443. void clearVariableNames(void) const;
  444. std::string getVariableName(size_t i) const;
  445. DdManager *getManager(void) const;
  446. void makeVerbose(void) const;
  447. void makeTerse(void) const;
  448. bool isVerbose(void) const;
  449. void checkReturnValue(const void *result) const;
  450. void checkReturnValue(const int result) const;
  451. Cudd& operator=(const Cudd& right);
  452. void info(void) const;
  453. BDD bddVar(void) const;
  454. BDD bddVar(int index) const;
  455. BDD bddOne(void) const;
  456. BDD bddZero(void) const;
  457. ADD addVar(void) const;
  458. ADD addVar(int index) const;
  459. ADD addOne(void) const;
  460. ADD addZero(void) const;
  461. ADD constant(CUDD_VALUE_TYPE c) const;
  462. ADD plusInfinity(void) const;
  463. ADD minusInfinity(void) const;
  464. ZDD zddVar(int index) const;
  465. ZDD zddOne(int i) const;
  466. ZDD zddZero(void) const;
  467. ADD addNewVarAtLevel(int level) const;
  468. BDD bddNewVarAtLevel(int level) const;
  469. void zddVarsFromBddVars(int multiplicity) const;
  470. unsigned long ReadStartTime(void) const;
  471. unsigned long ReadElapsedTime(void) const;
  472. void SetStartTime(unsigned long st) const;
  473. void ResetStartTime(void) const;
  474. unsigned long ReadTimeLimit(void) const;
  475. unsigned long SetTimeLimit(unsigned long tl) const;
  476. void UpdateTimeLimit(void) const;
  477. void IncreaseTimeLimit(unsigned long increase) const;
  478. void UnsetTimeLimit(void) const;
  479. bool TimeLimited(void) const;
  480. void RegisterTerminationCallback(DD_THFP callback,
  481. void * callback_arg) const;
  482. void UnregisterTerminationCallback(void) const;
  483. DD_OOMFP RegisterOutOfMemoryCallback(DD_OOMFP callback) const;
  484. void UnregisterOutOfMemoryCallback(void) const;
  485. void AutodynEnable(Cudd_ReorderingType method = CUDD_REORDER_SIFT) const;
  486. void AutodynDisable(void) const;
  487. bool ReorderingStatus(Cudd_ReorderingType * method) const;
  488. void AutodynEnableZdd(Cudd_ReorderingType method = CUDD_REORDER_SIFT) const;
  489. void AutodynDisableZdd(void) const;
  490. bool ReorderingStatusZdd(Cudd_ReorderingType * method) const;
  491. bool zddRealignmentEnabled(void) const;
  492. void zddRealignEnable(void) const;
  493. void zddRealignDisable(void) const;
  494. bool bddRealignmentEnabled(void) const;
  495. void bddRealignEnable(void) const;
  496. void bddRealignDisable(void) const;
  497. ADD background(void) const;
  498. void SetBackground(ADD bg) const;
  499. unsigned int ReadCacheSlots(void) const;
  500. double ReadCacheUsedSlots(void) const;
  501. double ReadCacheLookUps(void) const;
  502. double ReadCacheHits(void) const;
  503. unsigned int ReadMinHit(void) const;
  504. void SetMinHit(unsigned int hr) const;
  505. unsigned int ReadLooseUpTo(void) const;
  506. void SetLooseUpTo(unsigned int lut) const;
  507. unsigned int ReadMaxCache(void) const;
  508. unsigned int ReadMaxCacheHard(void) const;
  509. void SetMaxCacheHard(unsigned int mc) const;
  510. int ReadSize(void) const;
  511. int ReadZddSize(void) const;
  512. unsigned int ReadSlots(void) const;
  513. unsigned int ReadKeys(void) const;
  514. unsigned int ReadDead(void) const;
  515. unsigned int ReadMinDead(void) const;
  516. unsigned int ReadReorderings(void) const;
  517. unsigned int ReadMaxReorderings(void) const;
  518. void SetMaxReorderings(unsigned int mr) const;
  519. long ReadReorderingTime(void) const;
  520. int ReadGarbageCollections(void) const;
  521. long ReadGarbageCollectionTime(void) const;
  522. int ReadSiftMaxVar(void) const;
  523. void SetSiftMaxVar(int smv) const;
  524. int ReadSiftMaxSwap(void) const;
  525. void SetSiftMaxSwap(int sms) const;
  526. double ReadMaxGrowth(void) const;
  527. void SetMaxGrowth(double mg) const;
  528. #ifdef MTR_H_
  529. MtrNode * ReadTree(void) const;
  530. void SetTree(MtrNode * tree) const;
  531. void FreeTree(void) const;
  532. MtrNode * ReadZddTree(void) const;
  533. void SetZddTree(MtrNode * tree) const;
  534. void FreeZddTree(void) const;
  535. MtrNode * MakeTreeNode(unsigned int low, unsigned int size,
  536. unsigned int type) const;
  537. MtrNode * MakeZddTreeNode(unsigned int low, unsigned int size,
  538. unsigned int type) const;
  539. #endif
  540. int ReadPerm(int i) const;
  541. int ReadPermZdd(int i) const;
  542. int ReadInvPerm(int i) const;
  543. int ReadInvPermZdd(int i) const;
  544. BDD ReadVars(int i) const;
  545. CUDD_VALUE_TYPE ReadEpsilon(void) const;
  546. void SetEpsilon(CUDD_VALUE_TYPE ep) const;
  547. Cudd_AggregationType ReadGroupcheck(void) const;
  548. void SetGroupcheck(Cudd_AggregationType gc) const;
  549. bool GarbageCollectionEnabled(void) const;
  550. void EnableGarbageCollection(void) const;
  551. void DisableGarbageCollection(void) const;
  552. bool DeadAreCounted(void) const;
  553. void TurnOnCountDead(void) const;
  554. void TurnOffCountDead(void) const;
  555. int ReadRecomb(void) const;
  556. void SetRecomb(int recomb) const;
  557. int ReadSymmviolation(void) const;
  558. void SetSymmviolation(int symmviolation) const;
  559. int ReadArcviolation(void) const;
  560. void SetArcviolation(int arcviolation) const;
  561. int ReadPopulationSize(void) const;
  562. void SetPopulationSize(int populationSize) const;
  563. int ReadNumberXovers(void) const;
  564. void SetNumberXovers(int numberXovers) const;
  565. unsigned int ReadOrderRandomization(void) const;
  566. void SetOrderRandomization(unsigned int factor) const;
  567. unsigned long ReadMemoryInUse(void) const;
  568. long ReadPeakNodeCount(void) const;
  569. long ReadNodeCount(void) const;
  570. long zddReadNodeCount(void) const;
  571. void AddHook(DD_HFP f, Cudd_HookType where) const;
  572. void RemoveHook(DD_HFP f, Cudd_HookType where) const;
  573. bool IsInHook(DD_HFP f, Cudd_HookType where) const;
  574. void EnableReorderingReporting(void) const;
  575. void DisableReorderingReporting(void) const;
  576. bool ReorderingReporting(void) const;
  577. int ReadErrorCode(void) const;
  578. DD_OOMFP InstallOutOfMemoryHandler(DD_OOMFP newHandler) const;
  579. void ClearErrorCode(void) const;
  580. FILE *ReadStdout(void) const;
  581. void SetStdout(FILE * fp) const;
  582. FILE *ReadStderr(void) const;
  583. void SetStderr(FILE * fp) const;
  584. unsigned int ReadNextReordering(void) const;
  585. void SetNextReordering(unsigned int) const;
  586. double ReadSwapSteps(void) const;
  587. unsigned int ReadMaxLive(void) const;
  588. void SetMaxLive(unsigned int) const;
  589. size_t ReadMaxMemory(void) const;
  590. size_t SetMaxMemory(size_t) const;
  591. int bddBindVar(int) const;
  592. int bddUnbindVar(int) const;
  593. bool bddVarIsBound(int) const;
  594. ADD Walsh(std::vector<ADD> x, std::vector<ADD> y) const;
  595. ADD addResidue(int n, int m, int options, int top) const;
  596. int ApaNumberOfDigits(int binaryDigits) const;
  597. DdApaNumber NewApaNumber(int digits) const;
  598. void ApaCopy(int digits, DdApaNumber source, DdApaNumber dest) const;
  599. DdApaDigit ApaAdd(int digits, DdApaNumber a, DdApaNumber b, DdApaNumber
  600. sum) const;
  601. DdApaDigit ApaSubtract(int digits, DdApaNumber a, DdApaNumber b,
  602. DdApaNumber diff) const;
  603. DdApaDigit ApaShortDivision(int digits, DdApaNumber dividend, DdApaDigit
  604. divisor, DdApaNumber quotient) const;
  605. void ApaShiftRight(int digits, DdApaDigit in, DdApaNumber a, DdApaNumber
  606. b) const;
  607. void ApaSetToLiteral(int digits, DdApaNumber number, DdApaDigit literal)
  608. const;
  609. void ApaPowerOfTwo(int digits, DdApaNumber number, int power) const;
  610. void ApaPrintHex(int digits, DdApaNumber number, FILE * fp = stdout) const;
  611. void ApaPrintDecimal(int digits, DdApaNumber number, FILE * fp = stdout) const;
  612. std::string ApaStringDecimal(int digits, DdApaNumber number) const;
  613. void ApaPrintExponential(int digits, DdApaNumber number,
  614. int precision = 6, FILE * fp = stdout) const;
  615. void DebugCheck(void) const;
  616. void CheckKeys(void) const;
  617. ADD Harwell(FILE * fp, std::vector<ADD>& x, std::vector<ADD>& y,
  618. std::vector<ADD>& xn, std::vector<ADD>& yn_,
  619. int * m, int * n, int bx = 0, int sx = 2, int by = 1,
  620. int sy = 2, int pr = 0) const;
  621. void PrintLinear(void) const;
  622. int ReadLinear(int x, int y) const;
  623. BDD Xgty(std::vector<BDD> z, std::vector<BDD> x, std::vector<BDD> y) const;
  624. BDD Xeqy(std::vector<BDD> x, std::vector<BDD> y) const;
  625. ADD Xeqy(std::vector<ADD> x, std::vector<ADD> y) const;
  626. BDD Dxygtdxz(std::vector<BDD> x, std::vector<BDD> y,
  627. std::vector<BDD> z) const;
  628. BDD Dxygtdyz(std::vector<BDD> x, std::vector<BDD> y,
  629. std::vector<BDD> z) const;
  630. BDD Inequality(int c, std::vector<BDD> x, std::vector<BDD> y) const;
  631. BDD Disequality(int c, std::vector<BDD> x, std::vector<BDD> y) const;
  632. BDD Interval(std::vector<BDD> x, unsigned int lowerB,
  633. unsigned int upperB) const;
  634. ADD Hamming(std::vector<ADD> xVars, std::vector<ADD> yVars) const;
  635. ADD Read(FILE * fp, std::vector<ADD>& x, std::vector<ADD>& y, std::vector<ADD>& xn,
  636. std::vector<ADD>& yn_, int * m, int * n, int bx = 0, int sx = 2,
  637. int by = 1, int sy = 2) const;
  638. BDD Read(FILE * fp, std::vector<BDD>& x, std::vector<BDD>& y,
  639. int * m, int * n, int bx = 0, int sx = 2, int by = 1,
  640. int sy = 2) const;
  641. void ReduceHeap(Cudd_ReorderingType heuristic = CUDD_REORDER_SIFT,
  642. int minsize = 0) const;
  643. void ShuffleHeap(int * permutation) const;
  644. void SymmProfile(int lower, int upper) const;
  645. unsigned int Prime(unsigned int pr) const;
  646. void Reserve(int amount) const;
  647. int SharingSize(DD* nodes, int n) const;
  648. int SharingSize(const std::vector<BDD>& v) const;
  649. BDD bddComputeCube(BDD * vars, int * phase, int n) const;
  650. BDD computeCube(std::vector<BDD> const & vars) const;
  651. ADD addComputeCube(ADD * vars, int * phase, int n) const;
  652. ADD computeCube(std::vector<ADD> const & vars) const;
  653. BDD IndicesToCube(int * array, int n) const;
  654. void PrintVersion(FILE * fp) const;
  655. double AverageDistance(void) const;
  656. int32_t Random(void) const;
  657. void Srandom(int32_t seed) const;
  658. void zddPrintSubtable() const;
  659. void zddReduceHeap(Cudd_ReorderingType heuristic = CUDD_REORDER_SIFT,
  660. int minsize = 0) const;
  661. void zddShuffleHeap(int * permutation) const;
  662. void zddSymmProfile(int lower, int upper) const;
  663. void DumpDot(
  664. const std::vector<BDD>& nodes,
  665. char const * const * inames = 0,
  666. char const * const * onames = 0,
  667. FILE * fp = stdout) const;
  668. void DumpDaVinci(
  669. const std::vector<BDD>& nodes,
  670. char const * const * inames = 0,
  671. char const * const * onames = 0,
  672. FILE * fp = stdout) const;
  673. void DumpBlif(
  674. const std::vector<BDD>& nodes,
  675. char const * const * inames = 0,
  676. char const * const * onames = 0,
  677. char * mname = 0,
  678. FILE * fp = stdout,
  679. int mv = 0) const;
  680. void DumpDDcal(
  681. const std::vector<BDD>& nodes,
  682. char const * const * inames = 0,
  683. char const * const * onames = 0,
  684. FILE * fp = stdout) const;
  685. void DumpFactoredForm(
  686. const std::vector<BDD>& nodes,
  687. char const * const * inames = 0,
  688. char const * const * onames = 0,
  689. FILE * fp = stdout) const;
  690. BDD VectorSupport(const std::vector<BDD>& roots) const;
  691. std::vector<unsigned int>
  692. SupportIndices(const std::vector<BDD>& roots) const;
  693. std::vector<unsigned int>
  694. SupportIndices(const std::vector<ADD>& roots) const;
  695. int nodeCount(const std::vector<BDD>& roots) const;
  696. int VectorSupportSize(const std::vector<BDD>& roots) const;
  697. void DumpDot(
  698. const std::vector<ADD>& nodes,
  699. char const * const * inames = 0,
  700. char const * const * onames = 0,
  701. FILE * fp = stdout) const;
  702. void DumpDaVinci(
  703. const std::vector<ADD>& nodes,
  704. char const * const * inames = 0,
  705. char const * const * onames = 0,
  706. FILE * fp = stdout) const;
  707. BDD VectorSupport(const std::vector<ADD>& roots) const;
  708. int VectorSupportSize(const std::vector<ADD>& roots) const;
  709. void DumpDot(
  710. const std::vector<ZDD>& nodes,
  711. char const * const * inames = 0,
  712. char const * const * onames = 0,
  713. FILE * fp = stdout) const;
  714. std::string OrderString(void) const;
  715. }; // Cudd
  716. } // end of namespace cudd
  717. #endif