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.

779 lines
29 KiB

2 months ago
  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 ExistAbstractRepresentative(const BDD& cube) const;
  184. BDD XorExistAbstract(const BDD& g, const BDD& cube) const;
  185. BDD UnivAbstract(const BDD& cube) const;
  186. BDD BooleanDiff(int x) const;
  187. bool VarIsDependent(const BDD& var) const;
  188. double Correlation(const BDD& g) const;
  189. double CorrelationWeights(const BDD& g, double * prob) const;
  190. BDD Ite(const BDD& g, const BDD& h, unsigned int limit = 0) const;
  191. BDD IteConstant(const BDD& g, const BDD& h) const;
  192. BDD Intersect(const BDD& g) const;
  193. BDD And(const BDD& g, unsigned int limit = 0) const;
  194. BDD Or(const BDD& g, unsigned int limit = 0) const;
  195. BDD Nand(const BDD& g) const;
  196. BDD Nor(const BDD& g) const;
  197. BDD Xor(const BDD& g) const;
  198. BDD Xnor(const BDD& g, unsigned int limit = 0) const;
  199. bool Leq(const BDD& g) const;
  200. ADD Add() const;
  201. BDD Transfer(Cudd& destination) const;
  202. BDD ClippingAnd(const BDD& g, int maxDepth, int direction = 0) const;
  203. BDD ClippingAndAbstract(const BDD& g, const BDD& cube, int maxDepth,
  204. int direction = 0) const;
  205. BDD Cofactor(const BDD& g) const;
  206. bool VarAreSymmetric(int index1, int index2) const;
  207. BDD Compose(const BDD& g, int v) const;
  208. BDD Permute(int * permut) const;
  209. BDD SwapVariables(std::vector<BDD> x, std::vector<BDD> y) const;
  210. BDD AdjPermuteX(std::vector<BDD> x) const;
  211. BDD VectorCompose(std::vector<BDD> vector) const;
  212. void ApproxConjDecomp(BDD* g, BDD* h) const;
  213. void ApproxDisjDecomp(BDD* g, BDD* h) const;
  214. void IterConjDecomp(BDD* g, BDD* h) const;
  215. void IterDisjDecomp(BDD* g, BDD* h) const;
  216. void GenConjDecomp(BDD* g, BDD* h) const;
  217. void GenDisjDecomp(BDD* g, BDD* h) const;
  218. void VarConjDecomp(BDD* g, BDD* h) const;
  219. void VarDisjDecomp(BDD* g, BDD* h) const;
  220. bool IsVarEssential(int id, int phase) const;
  221. BDD Constrain(const BDD& c) const;
  222. BDD Restrict(const BDD& c) const;
  223. BDD NPAnd(const BDD& g) const;
  224. std::vector<BDD> ConstrainDecomp() const;
  225. std::vector<BDD> CharToVect() const;
  226. BDD LICompaction(const BDD& c) const;
  227. BDD Squeeze(const BDD& u) const;
  228. BDD Interpolate(const BDD& u) const;
  229. BDD Minimize(const BDD& c) const;
  230. BDD SubsetCompress(int nvars, int threshold) const;
  231. BDD SupersetCompress(int nvars, int threshold) const;
  232. BDD LiteralSetIntersection(const BDD& g) const;
  233. BDD PrioritySelect(std::vector<BDD> x, std::vector<BDD> y,
  234. std::vector<BDD> z, const BDD& Pi, DD_PRFP Pifunc) const;
  235. BDD CProjection(const BDD& Y) const;
  236. int MinHammingDist(int *minterm, int upperBound) const;
  237. BDD Eval(int * inputs) const;
  238. BDD Decreasing(int i) const;
  239. BDD Increasing(int i) const;
  240. bool LeqUnless(const BDD& G, const BDD& D) const;
  241. BDD MakePrime(const BDD& F) const;
  242. BDD MaximallyExpand(const BDD& ub, const BDD& f);
  243. BDD LargestPrimeUnate(const BDD& phases);
  244. BDD SolveEqn(const BDD& Y, std::vector<BDD> & G, int ** yIndex, int n) const;
  245. BDD VerifySol(std::vector<BDD> const & G, int * yIndex) const;
  246. BDD SplitSet(std::vector<BDD> xVars, double m) const;
  247. BDD SubsetHeavyBranch(int numVars, int threshold) const;
  248. BDD SupersetHeavyBranch(int numVars, int threshold) const;
  249. BDD SubsetShortPaths(int numVars, int threshold, bool hardlimit = false) const;
  250. BDD SupersetShortPaths(int numVars, int threshold, bool hardlimit = false) const;
  251. void PrintCover() const;
  252. void PrintCover(const BDD& u) const;
  253. int EstimateCofactor(int i, int phase) const;
  254. int EstimateCofactorSimple(int i) const;
  255. void PickOneCube(char * string) const;
  256. BDD PickOneMinterm(std::vector<BDD> vars) const;
  257. BDD zddIsop(const BDD& U, ZDD* zdd_I) const;
  258. BDD Isop(const BDD& U) const;
  259. ZDD PortToZdd() const;
  260. void PrintFactoredForm(char const * const * inames = 0, FILE * fp = stdout) const;
  261. std::string FactoredFormString(char const * const * inames = 0) const;
  262. }; // BDD
  263. /**
  264. @brief Class for ADDs.
  265. @see Cudd
  266. */
  267. class ADD : public ABDD {
  268. friend class Cudd;
  269. public:
  270. ADD();
  271. ADD(Capsule *cap, DdNode *bddNode);
  272. ADD(Cudd const & manager, DdNode *ddNode);
  273. ADD(const ADD &from);
  274. ADD operator=(const ADD& right);
  275. // Relational operators
  276. bool operator<=(const ADD& other) const;
  277. bool operator>=(const ADD& other) const;
  278. bool operator<(const ADD& other) const;
  279. bool operator>(const ADD& other) const;
  280. // Arithmetic operators
  281. ADD operator-() const;
  282. ADD operator*(const ADD& other) const;
  283. ADD operator*=(const ADD& other);
  284. ADD operator+(const ADD& other) const;
  285. ADD operator+=(const ADD& other);
  286. ADD operator-(const ADD& other) const;
  287. ADD operator-=(const ADD& other);
  288. // Logical operators
  289. ADD operator~() const;
  290. ADD operator&(const ADD& other) const;
  291. ADD operator&=(const ADD& other);
  292. ADD operator|(const ADD& other) const;
  293. ADD operator|=(const ADD& other);
  294. bool IsZero() const;
  295. ADD ExistAbstract(const ADD& cube) const;
  296. ADD UnivAbstract(const ADD& cube) const;
  297. ADD OrAbstract(const ADD& cube) const;
  298. ADD MinAbstract(const ADD& cube) const;
  299. ADD MinAbstractExcept0(const ADD& cube) const;
  300. ADD MaxAbstract(const ADD& cube) const;
  301. BDD MinAbstractRepresentative(const ADD& cube) const;
  302. BDD MaxAbstractRepresentative(const ADD& cube) const;
  303. ADD Plus(const ADD& g) const;
  304. ADD Times(const ADD& g) const;
  305. ADD Threshold(const ADD& g) const;
  306. ADD SetNZ(const ADD& g) const;
  307. ADD Divide(const ADD& g) const;
  308. ADD Minus(const ADD& g) const;
  309. ADD Minimum(const ADD& g) const;
  310. ADD Maximum(const ADD& g) const;
  311. ADD OneZeroMaximum(const ADD& g) const;
  312. ADD Diff(const ADD& g) const;
  313. ADD Agreement(const ADD& g) const;
  314. ADD Or(const ADD& g) const;
  315. ADD Nand(const ADD& g) const;
  316. ADD Nor(const ADD& g) const;
  317. ADD Xor(const ADD& g) const;
  318. ADD Xnor(const ADD& g) const;
  319. ADD Pow(const ADD& g) const;
  320. ADD Mod(const ADD& g) const;
  321. ADD LogXY(const ADD& g) const;
  322. ADD Log() const;
  323. ADD Floor() const;
  324. ADD Ceil() const;
  325. ADD FindMax() const;
  326. ADD FindMin() const;
  327. ADD IthBit(int bit) const;
  328. ADD ScalarInverse(const ADD& epsilon) const;
  329. ADD Ite(const ADD& g, const ADD& h) const;
  330. ADD IteConstant(const ADD& g, const ADD& h) const;
  331. ADD EvalConst(const ADD& g) const;
  332. bool Leq(const ADD& g) const;
  333. ADD Cmpl() const;
  334. ADD Negate() const;
  335. ADD RoundOff(int N) const;
  336. ADD Equals(const ADD& g) const;
  337. ADD NotEquals(const ADD& g) const;
  338. ADD LessThan(const ADD& g) const;
  339. ADD LessThanOrEqual(const ADD& g) const;
  340. ADD GreaterThan(const ADD& g) const;
  341. ADD GreaterThanOrEqual(const ADD& g) const;
  342. BDD EqualsBdd(const ADD& g) const;
  343. BDD NotEqualsBdd(const ADD& g) const;
  344. BDD LessThanBdd(const ADD& g) const;
  345. BDD LessThanOrEqualBdd(const ADD& g) const;
  346. BDD GreaterThanBdd(const ADD& g) const;
  347. BDD GreaterThanOrEqualBdd(const ADD& g) const;
  348. BDD BddThreshold(CUDD_VALUE_TYPE value) const;
  349. BDD BddStrictThreshold(CUDD_VALUE_TYPE value) const;
  350. BDD BddInterval(CUDD_VALUE_TYPE lower, CUDD_VALUE_TYPE upper) const;
  351. BDD BddIthBit(int bit) const;
  352. BDD BddPattern() const;
  353. ADD Cofactor(const ADD& g) const;
  354. ADD Compose(const ADD& g, int v) const;
  355. ADD Permute(int * permut) const;
  356. ADD SwapVariables(std::vector<ADD> x, std::vector<ADD> y) const;
  357. ADD VectorCompose(std::vector<ADD> vector) const;
  358. ADD NonSimCompose(std::vector<ADD> vector) const;
  359. ADD Constrain(const ADD& c) const;
  360. ADD Restrict(const ADD& c) const;
  361. ADD MatrixMultiply(const ADD& B, std::vector<ADD> z) const;
  362. ADD TimesPlus(const ADD& B, std::vector<ADD> z) const;
  363. ADD Triangle(const ADD& g, std::vector<ADD> z) const;
  364. ADD Eval(int * inputs) const;
  365. bool EqualSupNorm(const ADD& g, CUDD_VALUE_TYPE tolerance, int pr = 0) const;
  366. bool EqualSupNormRel(const ADD& g, CUDD_VALUE_TYPE tolerance, int pr = 0) const;
  367. }; // ADD
  368. /**
  369. @brief Class for ZDDs.
  370. @see Cudd
  371. */
  372. class ZDD : public DD {
  373. friend class Cudd;
  374. public:
  375. ZDD(Capsule *cap, DdNode *bddNode);
  376. ZDD();
  377. ZDD(const ZDD &from);
  378. ~ZDD();
  379. ZDD operator=(const ZDD& right);
  380. bool operator==(const ZDD& other) const;
  381. bool operator!=(const ZDD& other) const;
  382. bool operator<=(const ZDD& other) const;
  383. bool operator>=(const ZDD& other) const;
  384. bool operator<(const ZDD& other) const;
  385. bool operator>(const ZDD& other) const;
  386. void print(int nvars, int verbosity = 1) const;
  387. ZDD operator*(const ZDD& other) const;
  388. ZDD operator*=(const ZDD& other);
  389. ZDD operator&(const ZDD& other) const;
  390. ZDD operator&=(const ZDD& other);
  391. ZDD operator+(const ZDD& other) const;
  392. ZDD operator+=(const ZDD& other);
  393. ZDD operator|(const ZDD& other) const;
  394. ZDD operator|=(const ZDD& other);
  395. ZDD operator-(const ZDD& other) const;
  396. ZDD operator-=(const ZDD& other);
  397. int Count() const;
  398. double CountDouble() const;
  399. ZDD Product(const ZDD& g) const;
  400. ZDD UnateProduct(const ZDD& g) const;
  401. ZDD WeakDiv(const ZDD& g) const;
  402. ZDD Divide(const ZDD& g) const;
  403. ZDD WeakDivF(const ZDD& g) const;
  404. ZDD DivideF(const ZDD& g) const;
  405. double CountMinterm(int path) const;
  406. BDD PortToBdd() const;
  407. ZDD Ite(const ZDD& g, const ZDD& h) const;
  408. ZDD Union(const ZDD& Q) const;
  409. ZDD Intersect(const ZDD& Q) const;
  410. ZDD Diff(const ZDD& Q) const;
  411. ZDD DiffConst(const ZDD& Q) const;
  412. ZDD Subset1(int var) const;
  413. ZDD Subset0(int var) const;
  414. ZDD Change(int var) const;
  415. void PrintMinterm() const;
  416. void PrintCover() const;
  417. BDD Support() const;
  418. }; // ZDD
  419. /**
  420. @brief Default error handler.
  421. */
  422. extern void defaultError(std::string message);
  423. /**
  424. @brief Class for CUDD managers.
  425. @see DD
  426. */
  427. class Cudd {
  428. friend class DD;
  429. friend class ABDD;
  430. friend class BDD;
  431. friend class ADD;
  432. friend class ZDD;
  433. friend std::ostream & operator<<(std::ostream & os, BDD const & f);
  434. private:
  435. Capsule *p;
  436. public:
  437. Cudd(
  438. unsigned int numVars = 0,
  439. unsigned int numVarsZ = 0,
  440. unsigned int numSlots = CUDD_UNIQUE_SLOTS,
  441. unsigned int cacheSize = CUDD_CACHE_SLOTS,
  442. unsigned long maxMemory = 0,
  443. PFC defaultHandler = defaultError);
  444. Cudd(const Cudd& x);
  445. ~Cudd(void);
  446. PFC setHandler(PFC newHandler) const;
  447. PFC getHandler(void) const;
  448. PFC setTimeoutHandler(PFC newHandler) const;
  449. PFC getTimeoutHandler(void) const;
  450. PFC setTerminationHandler(PFC newHandler) const;
  451. PFC getTerminationHandler(void) const;
  452. void pushVariableName(std::string s) const;
  453. void clearVariableNames(void) const;
  454. std::string getVariableName(size_t i) const;
  455. DdManager *getManager(void) const;
  456. void makeVerbose(void) const;
  457. void makeTerse(void) const;
  458. bool isVerbose(void) const;
  459. void checkReturnValue(const void *result) const;
  460. void checkReturnValue(const int result) const;
  461. Cudd& operator=(const Cudd& right);
  462. void info(void) const;
  463. BDD bddVar(void) const;
  464. BDD bddVar(int index) const;
  465. BDD bddOne(void) const;
  466. BDD bddZero(void) const;
  467. ADD addVar(void) const;
  468. ADD addVar(int index) const;
  469. ADD addOne(void) const;
  470. ADD addZero(void) const;
  471. ADD constant(CUDD_VALUE_TYPE c) const;
  472. ADD plusInfinity(void) const;
  473. ADD minusInfinity(void) const;
  474. ZDD zddVar(int index) const;
  475. ZDD zddOne(int i) const;
  476. ZDD zddZero(void) const;
  477. ADD addNewVarAtLevel(int level) const;
  478. BDD bddNewVarAtLevel(int level) const;
  479. void zddVarsFromBddVars(int multiplicity) const;
  480. unsigned long ReadStartTime(void) const;
  481. unsigned long ReadElapsedTime(void) const;
  482. void SetStartTime(unsigned long st) const;
  483. void ResetStartTime(void) const;
  484. unsigned long ReadTimeLimit(void) const;
  485. unsigned long SetTimeLimit(unsigned long tl) const;
  486. void UpdateTimeLimit(void) const;
  487. void IncreaseTimeLimit(unsigned long increase) const;
  488. void UnsetTimeLimit(void) const;
  489. bool TimeLimited(void) const;
  490. void RegisterTerminationCallback(DD_THFP callback,
  491. void * callback_arg) const;
  492. void UnregisterTerminationCallback(void) const;
  493. DD_OOMFP RegisterOutOfMemoryCallback(DD_OOMFP callback) const;
  494. void UnregisterOutOfMemoryCallback(void) const;
  495. void AutodynEnable(Cudd_ReorderingType method = CUDD_REORDER_SIFT) const;
  496. void AutodynDisable(void) const;
  497. bool ReorderingStatus(Cudd_ReorderingType * method) const;
  498. void AutodynEnableZdd(Cudd_ReorderingType method = CUDD_REORDER_SIFT) const;
  499. void AutodynDisableZdd(void) const;
  500. bool ReorderingStatusZdd(Cudd_ReorderingType * method) const;
  501. bool zddRealignmentEnabled(void) const;
  502. void zddRealignEnable(void) const;
  503. void zddRealignDisable(void) const;
  504. bool bddRealignmentEnabled(void) const;
  505. void bddRealignEnable(void) const;
  506. void bddRealignDisable(void) const;
  507. ADD background(void) const;
  508. void SetBackground(ADD bg) const;
  509. unsigned int ReadCacheSlots(void) const;
  510. double ReadCacheUsedSlots(void) const;
  511. double ReadCacheLookUps(void) const;
  512. double ReadCacheHits(void) const;
  513. unsigned int ReadMinHit(void) const;
  514. void SetMinHit(unsigned int hr) const;
  515. unsigned int ReadLooseUpTo(void) const;
  516. void SetLooseUpTo(unsigned int lut) const;
  517. unsigned int ReadMaxCache(void) const;
  518. unsigned int ReadMaxCacheHard(void) const;
  519. void SetMaxCacheHard(unsigned int mc) const;
  520. int ReadSize(void) const;
  521. int ReadZddSize(void) const;
  522. unsigned int ReadSlots(void) const;
  523. unsigned int ReadKeys(void) const;
  524. unsigned int ReadDead(void) const;
  525. unsigned int ReadMinDead(void) const;
  526. unsigned int ReadReorderings(void) const;
  527. unsigned int ReadMaxReorderings(void) const;
  528. void SetMaxReorderings(unsigned int mr) const;
  529. long ReadReorderingTime(void) const;
  530. int ReadGarbageCollections(void) const;
  531. long ReadGarbageCollectionTime(void) const;
  532. int ReadSiftMaxVar(void) const;
  533. void SetSiftMaxVar(int smv) const;
  534. int ReadSiftMaxSwap(void) const;
  535. void SetSiftMaxSwap(int sms) const;
  536. double ReadMaxGrowth(void) const;
  537. void SetMaxGrowth(double mg) const;
  538. #ifdef MTR_H_
  539. MtrNode * ReadTree(void) const;
  540. void SetTree(MtrNode * tree) const;
  541. void FreeTree(void) const;
  542. MtrNode * ReadZddTree(void) const;
  543. void SetZddTree(MtrNode * tree) const;
  544. void FreeZddTree(void) const;
  545. MtrNode * MakeTreeNode(unsigned int low, unsigned int size,
  546. unsigned int type) const;
  547. MtrNode * MakeZddTreeNode(unsigned int low, unsigned int size,
  548. unsigned int type) const;
  549. #endif
  550. int ReadPerm(int i) const;
  551. int ReadPermZdd(int i) const;
  552. int ReadInvPerm(int i) const;
  553. int ReadInvPermZdd(int i) const;
  554. BDD ReadVars(int i) const;
  555. CUDD_VALUE_TYPE ReadEpsilon(void) const;
  556. void SetEpsilon(CUDD_VALUE_TYPE ep) const;
  557. Cudd_AggregationType ReadGroupcheck(void) const;
  558. void SetGroupcheck(Cudd_AggregationType gc) const;
  559. bool GarbageCollectionEnabled(void) const;
  560. void EnableGarbageCollection(void) const;
  561. void DisableGarbageCollection(void) const;
  562. bool DeadAreCounted(void) const;
  563. void TurnOnCountDead(void) const;
  564. void TurnOffCountDead(void) const;
  565. int ReadRecomb(void) const;
  566. void SetRecomb(int recomb) const;
  567. int ReadSymmviolation(void) const;
  568. void SetSymmviolation(int symmviolation) const;
  569. int ReadArcviolation(void) const;
  570. void SetArcviolation(int arcviolation) const;
  571. int ReadPopulationSize(void) const;
  572. void SetPopulationSize(int populationSize) const;
  573. int ReadNumberXovers(void) const;
  574. void SetNumberXovers(int numberXovers) const;
  575. unsigned int ReadOrderRandomization(void) const;
  576. void SetOrderRandomization(unsigned int factor) const;
  577. unsigned long ReadMemoryInUse(void) const;
  578. long ReadPeakNodeCount(void) const;
  579. long ReadNodeCount(void) const;
  580. long zddReadNodeCount(void) const;
  581. void AddHook(DD_HFP f, Cudd_HookType where) const;
  582. void RemoveHook(DD_HFP f, Cudd_HookType where) const;
  583. bool IsInHook(DD_HFP f, Cudd_HookType where) const;
  584. void EnableReorderingReporting(void) const;
  585. void DisableReorderingReporting(void) const;
  586. bool ReorderingReporting(void) const;
  587. int ReadErrorCode(void) const;
  588. DD_OOMFP InstallOutOfMemoryHandler(DD_OOMFP newHandler) const;
  589. void ClearErrorCode(void) const;
  590. FILE *ReadStdout(void) const;
  591. void SetStdout(FILE * fp) const;
  592. FILE *ReadStderr(void) const;
  593. void SetStderr(FILE * fp) const;
  594. unsigned int ReadNextReordering(void) const;
  595. void SetNextReordering(unsigned int) const;
  596. double ReadSwapSteps(void) const;
  597. unsigned int ReadMaxLive(void) const;
  598. void SetMaxLive(unsigned int) const;
  599. size_t ReadMaxMemory(void) const;
  600. size_t SetMaxMemory(size_t) const;
  601. int bddBindVar(int) const;
  602. int bddUnbindVar(int) const;
  603. bool bddVarIsBound(int) const;
  604. ADD Walsh(std::vector<ADD> x, std::vector<ADD> y) const;
  605. ADD addResidue(int n, int m, int options, int top) const;
  606. int ApaNumberOfDigits(int binaryDigits) const;
  607. DdApaNumber NewApaNumber(int digits) const;
  608. void ApaCopy(int digits, DdApaNumber source, DdApaNumber dest) const;
  609. DdApaDigit ApaAdd(int digits, DdApaNumber a, DdApaNumber b, DdApaNumber
  610. sum) const;
  611. DdApaDigit ApaSubtract(int digits, DdApaNumber a, DdApaNumber b,
  612. DdApaNumber diff) const;
  613. DdApaDigit ApaShortDivision(int digits, DdApaNumber dividend, DdApaDigit
  614. divisor, DdApaNumber quotient) const;
  615. void ApaShiftRight(int digits, DdApaDigit in, DdApaNumber a, DdApaNumber
  616. b) const;
  617. void ApaSetToLiteral(int digits, DdApaNumber number, DdApaDigit literal)
  618. const;
  619. void ApaPowerOfTwo(int digits, DdApaNumber number, int power) const;
  620. void ApaPrintHex(int digits, DdApaNumber number, FILE * fp = stdout) const;
  621. void ApaPrintDecimal(int digits, DdApaNumber number, FILE * fp = stdout) const;
  622. std::string ApaStringDecimal(int digits, DdApaNumber number) const;
  623. void ApaPrintExponential(int digits, DdApaNumber number,
  624. int precision = 6, FILE * fp = stdout) const;
  625. void DebugCheck(void) const;
  626. void CheckKeys(void) const;
  627. ADD Harwell(FILE * fp, std::vector<ADD>& x, std::vector<ADD>& y,
  628. std::vector<ADD>& xn, std::vector<ADD>& yn_,
  629. int * m, int * n, int bx = 0, int sx = 2, int by = 1,
  630. int sy = 2, int pr = 0) const;
  631. void PrintLinear(void) const;
  632. int ReadLinear(int x, int y) const;
  633. BDD Xgty(std::vector<BDD> z, std::vector<BDD> x, std::vector<BDD> y) const;
  634. BDD Xeqy(std::vector<BDD> x, std::vector<BDD> y) const;
  635. ADD Xeqy(std::vector<ADD> x, std::vector<ADD> y) const;
  636. BDD Dxygtdxz(std::vector<BDD> x, std::vector<BDD> y,
  637. std::vector<BDD> z) const;
  638. BDD Dxygtdyz(std::vector<BDD> x, std::vector<BDD> y,
  639. std::vector<BDD> z) const;
  640. BDD Inequality(int c, std::vector<BDD> x, std::vector<BDD> y) const;
  641. BDD Disequality(int c, std::vector<BDD> x, std::vector<BDD> y) const;
  642. BDD Interval(std::vector<BDD> x, unsigned int lowerB,
  643. unsigned int upperB) const;
  644. ADD Hamming(std::vector<ADD> xVars, std::vector<ADD> yVars) const;
  645. ADD Read(FILE * fp, std::vector<ADD>& x, std::vector<ADD>& y, std::vector<ADD>& xn,
  646. std::vector<ADD>& yn_, int * m, int * n, int bx = 0, int sx = 2,
  647. int by = 1, int sy = 2) const;
  648. BDD Read(FILE * fp, std::vector<BDD>& x, std::vector<BDD>& y,
  649. int * m, int * n, int bx = 0, int sx = 2, int by = 1,
  650. int sy = 2) const;
  651. void ReduceHeap(Cudd_ReorderingType heuristic = CUDD_REORDER_SIFT,
  652. int minsize = 0) const;
  653. void ShuffleHeap(int * permutation) const;
  654. void SymmProfile(int lower, int upper) const;
  655. unsigned int Prime(unsigned int pr) const;
  656. void Reserve(int amount) const;
  657. int SharingSize(DD* nodes, int n) const;
  658. int SharingSize(const std::vector<BDD>& v) const;
  659. BDD bddComputeCube(BDD * vars, int * phase, int n) const;
  660. BDD computeCube(std::vector<BDD> const & vars) const;
  661. ADD addComputeCube(ADD * vars, int * phase, int n) const;
  662. ADD computeCube(std::vector<ADD> const & vars) const;
  663. BDD IndicesToCube(int * array, int n) const;
  664. void PrintVersion(FILE * fp) const;
  665. double AverageDistance(void) const;
  666. int32_t Random(void) const;
  667. void Srandom(int32_t seed) const;
  668. void zddPrintSubtable() const;
  669. void zddReduceHeap(Cudd_ReorderingType heuristic = CUDD_REORDER_SIFT,
  670. int minsize = 0) const;
  671. void zddShuffleHeap(int * permutation) const;
  672. void zddSymmProfile(int lower, int upper) const;
  673. void DumpDot(
  674. const std::vector<BDD>& nodes,
  675. char const * const * inames = 0,
  676. char const * const * onames = 0,
  677. FILE * fp = stdout) const;
  678. void DumpDaVinci(
  679. const std::vector<BDD>& nodes,
  680. char const * const * inames = 0,
  681. char const * const * onames = 0,
  682. FILE * fp = stdout) const;
  683. void DumpBlif(
  684. const std::vector<BDD>& nodes,
  685. char const * const * inames = 0,
  686. char const * const * onames = 0,
  687. char * mname = 0,
  688. FILE * fp = stdout,
  689. int mv = 0) const;
  690. void DumpDDcal(
  691. const std::vector<BDD>& nodes,
  692. char const * const * inames = 0,
  693. char const * const * onames = 0,
  694. FILE * fp = stdout) const;
  695. void DumpFactoredForm(
  696. const std::vector<BDD>& nodes,
  697. char const * const * inames = 0,
  698. char const * const * onames = 0,
  699. FILE * fp = stdout) const;
  700. BDD VectorSupport(const std::vector<BDD>& roots) const;
  701. std::vector<unsigned int>
  702. SupportIndices(const std::vector<BDD>& roots) const;
  703. std::vector<unsigned int>
  704. SupportIndices(const std::vector<ADD>& roots) const;
  705. int nodeCount(const std::vector<BDD>& roots) const;
  706. int VectorSupportSize(const std::vector<BDD>& roots) const;
  707. void DumpDot(
  708. const std::vector<ADD>& nodes,
  709. char const * const * inames = 0,
  710. char const * const * onames = 0,
  711. FILE * fp = stdout) const;
  712. void DumpDaVinci(
  713. const std::vector<ADD>& nodes,
  714. char const * const * inames = 0,
  715. char const * const * onames = 0,
  716. FILE * fp = stdout) const;
  717. BDD VectorSupport(const std::vector<ADD>& roots) const;
  718. int VectorSupportSize(const std::vector<ADD>& roots) const;
  719. void DumpDot(
  720. const std::vector<ZDD>& nodes,
  721. char const * const * inames = 0,
  722. char const * const * onames = 0,
  723. FILE * fp = stdout) const;
  724. std::string OrderString(void) const;
  725. }; // Cudd
  726. } // end of namespace cudd
  727. #endif