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.

6426 lines
122 KiB

2 months ago
  1. /**
  2. @file
  3. @ingroup cplusplus
  4. @brief Functions for the C++ object-oriented encapsulation of CUDD.
  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. #include <iostream>
  35. #include <sstream>
  36. #include <cassert>
  37. #include <cstdlib>
  38. #include <cstring>
  39. #include <algorithm>
  40. #include <stdexcept>
  41. #include "epdInt.h"
  42. #include "cuddInt.h"
  43. #include "cuddObj.hh"
  44. using std::cout;
  45. using std::cerr;
  46. using std::ostream;
  47. using std::endl;
  48. using std::hex;
  49. using std::dec;
  50. using std::string;
  51. using std::vector;
  52. using std::sort;
  53. namespace cudd {
  54. // ---------------------------------------------------------------------------
  55. // Variable declarations
  56. // ---------------------------------------------------------------------------
  57. // ---------------------------------------------------------------------------
  58. // Members of class Capsule
  59. // ---------------------------------------------------------------------------
  60. /**
  61. @brief Class for reference counting of CUDD managers.
  62. @see Cudd DD ABDD ADD BDD ZDD
  63. */
  64. class Capsule {
  65. public:
  66. Capsule(unsigned int numVars, unsigned int numVarsZ,
  67. unsigned int numSlots, unsigned int cacheSize,
  68. unsigned long maxMemory, PFC defaultHandler);
  69. ~Capsule();
  70. #if HAVE_MODERN_CXX == 1
  71. Capsule(Capsule const &) = delete;
  72. Capsule & operator=(Capsule const &) = delete;
  73. #else
  74. private:
  75. Capsule(Capsule const &); // not defined
  76. Capsule & operator=(Capsule const &); // not defined
  77. public:
  78. #endif
  79. DdManager *manager;
  80. PFC errorHandler;
  81. PFC timeoutHandler;
  82. PFC terminationHandler;
  83. std::vector<char *> varnames;
  84. int ref;
  85. bool verbose;
  86. };
  87. Capsule::Capsule(
  88. unsigned int numVars,
  89. unsigned int numVarsZ,
  90. unsigned int numSlots,
  91. unsigned int cacheSize,
  92. unsigned long maxMemory,
  93. PFC defaultHandler)
  94. {
  95. errorHandler = defaultHandler;
  96. timeoutHandler = defaultHandler;
  97. terminationHandler = defaultHandler;
  98. manager = Cudd_Init(numVars, numVarsZ, numSlots, cacheSize, maxMemory);
  99. if (!manager)
  100. errorHandler("Out of memory");
  101. verbose = 0; // initially terse
  102. ref = 1;
  103. } // Capsule::Capsule
  104. Capsule::~Capsule()
  105. {
  106. #ifdef DD_DEBUG
  107. if (manager) {
  108. int retval = Cudd_CheckZeroRef(manager);
  109. if (retval != 0) {
  110. cerr << retval << " unexpected non-zero reference counts" << endl;
  111. } else if (verbose) {
  112. cerr << "All went well" << endl;
  113. }
  114. }
  115. #endif
  116. for (vector<char *>::iterator it = varnames.begin();
  117. it != varnames.end(); ++it) {
  118. delete [] *it;
  119. }
  120. Cudd_Quit(manager);
  121. } // Capsule::~Capsule
  122. // ---------------------------------------------------------------------------
  123. // Members of class DD
  124. // ---------------------------------------------------------------------------
  125. DD::DD() : p(0), node(0) {}
  126. DD::DD(Capsule *cap, DdNode *ddNode) : p(cap), node(ddNode) {
  127. if (node) Cudd_Ref(node);
  128. if (p->verbose) {
  129. cout << "Standard DD constructor for node " << hex << node << dec <<
  130. " ref = " << Cudd_Regular(node)->ref << "\n";
  131. }
  132. } // DD::DD
  133. DD::DD(Cudd const & manager, DdNode *ddNode) : p(manager.p), node(ddNode) {
  134. checkReturnValue(ddNode);
  135. if (node) Cudd_Ref(node);
  136. if (p->verbose) {
  137. cout << "Standard DD constructor for node " << hex << node << dec <<
  138. " ref = " << Cudd_Regular(node)->ref << "\n";
  139. }
  140. } // DD::DD
  141. DD::DD(const DD &from) {
  142. p = from.p;
  143. node = from.node;
  144. if (node) {
  145. Cudd_Ref(node);
  146. if (p->verbose) {
  147. cout << "Copy DD constructor for node " << hex << node << dec <<
  148. " ref = " << Cudd_Regular(node)->ref << "\n";
  149. }
  150. }
  151. } // DD::DD
  152. DD::~DD() {}
  153. inline DdManager *
  154. DD::checkSameManager(
  155. const DD &other) const
  156. {
  157. DdManager *mgr = p->manager;
  158. if (mgr != other.p->manager) {
  159. p->errorHandler("Operands come from different manager.");
  160. }
  161. return mgr;
  162. } // DD::checkSameManager
  163. inline void
  164. DD::checkReturnValue(
  165. const void *result) const
  166. {
  167. if (result == 0) {
  168. DdManager *mgr = p->manager;
  169. Cudd_ErrorType errType = Cudd_ReadErrorCode(mgr);
  170. switch (errType) {
  171. case CUDD_MEMORY_OUT:
  172. p->errorHandler("Out of memory.");
  173. break;
  174. case CUDD_TOO_MANY_NODES:
  175. break;
  176. case CUDD_MAX_MEM_EXCEEDED:
  177. p->errorHandler("Maximum memory exceeded.");
  178. break;
  179. case CUDD_TIMEOUT_EXPIRED:
  180. {
  181. std::ostringstream msg;
  182. unsigned long lag =
  183. Cudd_ReadElapsedTime(mgr) - Cudd_ReadTimeLimit(mgr);
  184. msg << "Timeout expired. Lag = " << lag << " ms.";
  185. p->timeoutHandler(msg.str());
  186. }
  187. break;
  188. case CUDD_TERMINATION:
  189. {
  190. std::ostringstream msg;
  191. msg << "Terminated.\n";
  192. p->terminationHandler(msg.str());
  193. }
  194. break;
  195. case CUDD_INVALID_ARG:
  196. p->errorHandler("Invalid argument.");
  197. break;
  198. case CUDD_INTERNAL_ERROR:
  199. p->errorHandler("Internal error.");
  200. break;
  201. case CUDD_NO_ERROR:
  202. p->errorHandler("Unexpected error.");
  203. break;
  204. }
  205. }
  206. } // DD::checkReturnValue
  207. inline void
  208. DD::checkReturnValue(
  209. int result,
  210. int expected) const
  211. {
  212. if (result != expected) {
  213. DdManager *mgr = p->manager;
  214. Cudd_ErrorType errType = Cudd_ReadErrorCode(mgr);
  215. switch (errType) {
  216. case CUDD_MEMORY_OUT:
  217. p->errorHandler("Out of memory.");
  218. break;
  219. case CUDD_TOO_MANY_NODES:
  220. break;
  221. case CUDD_MAX_MEM_EXCEEDED:
  222. p->errorHandler("Maximum memory exceeded.");
  223. break;
  224. case CUDD_TIMEOUT_EXPIRED:
  225. {
  226. std::ostringstream msg;
  227. unsigned long lag =
  228. Cudd_ReadElapsedTime(mgr) - Cudd_ReadTimeLimit(mgr);
  229. msg << "Timeout expired. Lag = " << lag << " ms.\n";
  230. p->timeoutHandler(msg.str());
  231. }
  232. break;
  233. case CUDD_TERMINATION:
  234. {
  235. std::ostringstream msg;
  236. msg << "Terminated.\n";
  237. p->terminationHandler(msg.str());
  238. }
  239. break;
  240. case CUDD_INVALID_ARG:
  241. p->errorHandler("Invalid argument.");
  242. break;
  243. case CUDD_INTERNAL_ERROR:
  244. p->errorHandler("Internal error.");
  245. break;
  246. case CUDD_NO_ERROR:
  247. p->errorHandler("Unexpected error.");
  248. break;
  249. }
  250. }
  251. } // DD::checkReturnValue
  252. DdManager *
  253. DD::manager() const
  254. {
  255. return p->manager;
  256. } // DD::manager
  257. DdNode *
  258. DD::getNode() const
  259. {
  260. return node;
  261. } // DD::getNode
  262. DdNode *
  263. DD::getRegularNode() const
  264. {
  265. return Cudd_Regular(node);
  266. } // DD::getRegularNode
  267. int
  268. DD::nodeCount() const
  269. {
  270. return Cudd_DagSize(node);
  271. } // DD::nodeCount
  272. unsigned int
  273. DD::NodeReadIndex() const
  274. {
  275. return Cudd_NodeReadIndex(node);
  276. } // DD::NodeReadIndex
  277. // ---------------------------------------------------------------------------
  278. // Members of class ABDD
  279. // ---------------------------------------------------------------------------
  280. ABDD::ABDD() : DD() {}
  281. ABDD::ABDD(Capsule *cap, DdNode *bddNode) : DD(cap,bddNode) {}
  282. ABDD::ABDD(Cudd const & manager, DdNode *bddNode) : DD(manager,bddNode) {}
  283. ABDD::ABDD(const ABDD &from) : DD(from) {}
  284. ABDD::~ABDD() {
  285. if (node) {
  286. Cudd_RecursiveDeref(p->manager,node);
  287. if (p->verbose) {
  288. cout << "ADD/BDD destructor called for node " << hex << dec <<
  289. node << " ref = " << Cudd_Regular(node)->ref << "\n";
  290. }
  291. }
  292. } // ABDD::~ABDD
  293. bool
  294. ABDD::operator==(
  295. const ABDD& other) const
  296. {
  297. checkSameManager(other);
  298. return node == other.node;
  299. } // ABDD::operator==
  300. bool
  301. ABDD::operator!=(
  302. const ABDD& other) const
  303. {
  304. checkSameManager(other);
  305. return node != other.node;
  306. } // ABDD::operator!=
  307. bool
  308. ABDD::IsOne() const
  309. {
  310. return node == Cudd_ReadOne(p->manager);
  311. } // ABDD::IsOne
  312. void
  313. ABDD::print(
  314. int nvars,
  315. int verbosity) const
  316. {
  317. cout.flush();
  318. if (!node) defaultError("empty DD.");
  319. int retval = Cudd_PrintDebug(p->manager,node,nvars,verbosity);
  320. fflush(Cudd_ReadStdout(p->manager));
  321. checkReturnValue(retval);
  322. //if (retval == 0) p->errorHandler("print failed");
  323. } // ABDD::print
  324. void
  325. ABDD::summary(
  326. int nvars,
  327. int mode) const
  328. {
  329. cout.flush();
  330. if (!node) defaultError("empty DD.");
  331. int retval = Cudd_PrintSummary(p->manager,node,nvars,mode);
  332. fflush(Cudd_ReadStdout(p->manager));
  333. checkReturnValue(retval);
  334. } // ABDD::summary
  335. // ---------------------------------------------------------------------------
  336. // Members of class BDD
  337. // ---------------------------------------------------------------------------
  338. BDD::BDD() : ABDD() {}
  339. BDD::BDD(Capsule *cap, DdNode *bddNode) : ABDD(cap,bddNode) {}
  340. BDD::BDD(Cudd const & manager, DdNode *bddNode) : ABDD(manager,bddNode) {}
  341. BDD::BDD(const BDD &from) : ABDD(from) {}
  342. BDD
  343. BDD::operator=(
  344. const BDD& right)
  345. {
  346. if (this == &right) return *this;
  347. if (right.node) Cudd_Ref(right.node);
  348. if (node) {
  349. Cudd_RecursiveDeref(p->manager,node);
  350. if (p->verbose) {
  351. cout << "BDD dereferencing for node " << hex << node << dec <<
  352. " ref = " << Cudd_Regular(node)->ref << "\n";
  353. }
  354. }
  355. node = right.node;
  356. p = right.p;
  357. if (node && p->verbose) {
  358. cout << "BDD assignment for node " << hex << node << dec <<
  359. " ref = " << Cudd_Regular(node)->ref << "\n";
  360. }
  361. return *this;
  362. } // BDD::operator=
  363. bool
  364. BDD::operator<=(
  365. const BDD& other) const
  366. {
  367. DdManager *mgr = checkSameManager(other);
  368. return Cudd_bddLeq(mgr,node,other.node);
  369. } // BDD::operator<=
  370. bool
  371. BDD::operator>=(
  372. const BDD& other) const
  373. {
  374. DdManager *mgr = checkSameManager(other);
  375. return Cudd_bddLeq(mgr,other.node,node);
  376. } // BDD::operator>=
  377. bool
  378. BDD::operator<(
  379. const BDD& other) const
  380. {
  381. DdManager *mgr = checkSameManager(other);
  382. return node != other.node && Cudd_bddLeq(mgr,node,other.node);
  383. } // BDD::operator<
  384. bool
  385. BDD::operator>(
  386. const BDD& other) const
  387. {
  388. DdManager *mgr = checkSameManager(other);
  389. return node != other.node && Cudd_bddLeq(mgr,other.node,node);
  390. } // BDD::operator>
  391. BDD
  392. BDD::operator!() const
  393. {
  394. return BDD(p, Cudd_Not(node));
  395. } // BDD::operator!
  396. BDD
  397. BDD::operator~() const
  398. {
  399. return BDD(p, Cudd_Not(node));
  400. } // BDD::operator~
  401. BDD
  402. BDD::operator*(
  403. const BDD& other) const
  404. {
  405. DdManager *mgr = checkSameManager(other);
  406. DdNode *result = Cudd_bddAnd(mgr,node,other.node);
  407. checkReturnValue(result);
  408. return BDD(p, result);
  409. } // BDD::operator*
  410. BDD
  411. BDD::operator*=(
  412. const BDD& other)
  413. {
  414. DdManager *mgr = checkSameManager(other);
  415. DdNode *result = Cudd_bddAnd(mgr,node,other.node);
  416. checkReturnValue(result);
  417. Cudd_Ref(result);
  418. Cudd_RecursiveDeref(mgr,node);
  419. node = result;
  420. return *this;
  421. } // BDD::operator*=
  422. BDD
  423. BDD::operator&(
  424. const BDD& other) const
  425. {
  426. DdManager *mgr = checkSameManager(other);
  427. DdNode *result = Cudd_bddAnd(mgr,node,other.node);
  428. checkReturnValue(result);
  429. return BDD(p, result);
  430. } // BDD::operator&
  431. BDD
  432. BDD::operator&=(
  433. const BDD& other)
  434. {
  435. DdManager *mgr = checkSameManager(other);
  436. DdNode *result = Cudd_bddAnd(mgr,node,other.node);
  437. checkReturnValue(result);
  438. Cudd_Ref(result);
  439. Cudd_RecursiveDeref(mgr,node);
  440. node = result;
  441. return *this;
  442. } // BDD::operator&=
  443. BDD
  444. BDD::operator+(
  445. const BDD& other) const
  446. {
  447. DdManager *mgr = checkSameManager(other);
  448. DdNode *result = (mgr,node,other.node);
  449. checkReturnValue(result);
  450. return BDD(p, result);
  451. } // BDD::operator+
  452. BDD
  453. BDD::operator+=(
  454. const BDD& other)
  455. {
  456. DdManager *mgr = checkSameManager(other);
  457. DdNode *result = Cudd_bddOr(mgr,node,other.node);
  458. checkReturnValue(result);
  459. Cudd_Ref(result);
  460. Cudd_RecursiveDeref(mgr,node);
  461. node = result;
  462. return *this;
  463. } // BDD::operator+=
  464. BDD
  465. BDD::operator|(
  466. const BDD& other) const
  467. {
  468. DdManager *mgr = checkSameManager(other);
  469. DdNode *result = Cudd_bddOr(mgr,node,other.node);
  470. checkReturnValue(result);
  471. return BDD(p, result);
  472. } // BDD::operator|
  473. BDD
  474. BDD::operator|=(
  475. const BDD& other)
  476. {
  477. DdManager *mgr = checkSameManager(other);
  478. DdNode *result = Cudd_bddOr(mgr,node,other.node);
  479. checkReturnValue(result);
  480. Cudd_Ref(result);
  481. Cudd_RecursiveDeref(mgr,node);
  482. node = result;
  483. return *this;
  484. } // BDD::operator|=
  485. BDD
  486. BDD::operator^(
  487. const BDD& other) const
  488. {
  489. DdManager *mgr = checkSameManager(other);
  490. DdNode *result = Cudd_bddXor(mgr,node,other.node);
  491. checkReturnValue(result);
  492. return BDD(p, result);
  493. } // BDD::operator^
  494. BDD
  495. BDD::operator^=(
  496. const BDD& other)
  497. {
  498. DdManager *mgr = checkSameManager(other);
  499. DdNode *result = Cudd_bddXor(mgr,node,other.node);
  500. checkReturnValue(result);
  501. Cudd_Ref(result);
  502. Cudd_RecursiveDeref(mgr,node);
  503. node = result;
  504. return *this;
  505. } // BDD::operator^=
  506. BDD
  507. BDD::operator-(
  508. const BDD& other) const
  509. {
  510. DdManager *mgr = checkSameManager(other);
  511. DdNode *result = Cudd_bddAnd(mgr,node,Cudd_Not(other.node));
  512. checkReturnValue(result);
  513. return BDD(p, result);
  514. } // BDD::operator-
  515. BDD
  516. BDD::operator-=(
  517. const BDD& other)
  518. {
  519. DdManager *mgr = checkSameManager(other);
  520. DdNode *result = Cudd_bddAnd(mgr,node,Cudd_Not(other.node));
  521. checkReturnValue(result);
  522. Cudd_Ref(result);
  523. Cudd_RecursiveDeref(mgr,node);
  524. node = result;
  525. return *this;
  526. } // BDD::operator-=
  527. ostream & operator<<(ostream & os, BDD const & f)
  528. {
  529. if (!f.node) defaultError("empty DD.");
  530. DdManager *mgr = f.p->manager;
  531. vector<char *> const & vn = f.p->varnames;
  532. char const * const *inames = vn.size() == (size_t) Cudd_ReadSize(mgr) ?
  533. &vn[0] : 0;
  534. char * str = Cudd_FactoredFormString(mgr, f.node, inames);
  535. f.checkReturnValue(str);
  536. os << string(str);
  537. free(str);
  538. return os;
  539. } // operator<<
  540. bool
  541. BDD::IsZero() const
  542. {
  543. return node == Cudd_ReadLogicZero(p->manager);
  544. } // BDD::IsZero
  545. bool
  546. BDD::IsVar() const
  547. {
  548. return Cudd_bddIsVar(p->manager, node);
  549. } // BDD::IsVar
  550. // ---------------------------------------------------------------------------
  551. // Members of class ADD
  552. // ---------------------------------------------------------------------------
  553. ADD::ADD() : ABDD() {}
  554. ADD::ADD(Capsule *cap, DdNode *bddNode) : ABDD(cap,bddNode) {}
  555. ADD::ADD(Cudd const & manager, DdNode *bddNode) : ABDD(manager,bddNode) {}
  556. ADD::ADD(const ADD &from) : ABDD(from) {}
  557. ADD
  558. ADD::operator=(
  559. const ADD& right)
  560. {
  561. if (this == &right) return *this;
  562. if (right.node) Cudd_Ref(right.node);
  563. if (node) {
  564. Cudd_RecursiveDeref(p->manager,node);
  565. }
  566. node = right.node;
  567. p = right.p;
  568. return *this;
  569. } // ADD::operator=
  570. bool
  571. ADD::operator<=(
  572. const ADD& other) const
  573. {
  574. DdManager *mgr = checkSameManager(other);
  575. return Cudd_addLeq(mgr,node,other.node);
  576. } // ADD::operator<=
  577. bool
  578. ADD::operator>=(
  579. const ADD& other) const
  580. {
  581. DdManager *mgr = checkSameManager(other);
  582. return Cudd_addLeq(mgr,other.node,node);
  583. } // ADD::operator>=
  584. bool
  585. ADD::operator<(
  586. const ADD& other) const
  587. {
  588. DdManager *mgr = checkSameManager(other);
  589. return node != other.node && Cudd_addLeq(mgr,node,other.node);
  590. } // ADD::operator<
  591. bool
  592. ADD::operator>(
  593. const ADD& other) const
  594. {
  595. DdManager *mgr = checkSameManager(other);
  596. return node != other.node && Cudd_addLeq(mgr,other.node,node);
  597. } // ADD::operator>
  598. ADD
  599. ADD::operator-() const
  600. {
  601. return ADD(p, Cudd_addNegate(p->manager,node));
  602. } // ADD::operator-
  603. ADD
  604. ADD::operator*(
  605. const ADD& other) const
  606. {
  607. DdManager *mgr = checkSameManager(other);
  608. DdNode *result = Cudd_addApply(mgr,Cudd_addTimes,node,other.node);
  609. checkReturnValue(result);
  610. return ADD(p, result);
  611. } // ADD::operator*
  612. ADD
  613. ADD::operator*=(
  614. const ADD& other)
  615. {
  616. DdManager *mgr = checkSameManager(other);
  617. DdNode *result = Cudd_addApply(mgr,Cudd_addTimes,node,other.node);
  618. checkReturnValue(result);
  619. Cudd_Ref(result);
  620. Cudd_RecursiveDeref(mgr,node);
  621. node = result;
  622. return *this;
  623. } // ADD::operator*=
  624. ADD
  625. ADD::operator+(
  626. const ADD& other) const
  627. {
  628. DdManager *mgr = checkSameManager(other);
  629. DdNode *result = Cudd_addApply(mgr,Cudd_addPlus,node,other.node);
  630. checkReturnValue(result);
  631. return ADD(p, result);
  632. } // ADD::operator+
  633. ADD
  634. ADD::operator+=(
  635. const ADD& other)
  636. {
  637. DdManager *mgr = checkSameManager(other);
  638. DdNode *result = Cudd_addApply(mgr,Cudd_addPlus,node,other.node);
  639. checkReturnValue(result);
  640. Cudd_Ref(result);
  641. Cudd_RecursiveDeref(mgr,node);
  642. node = result;
  643. return *this;
  644. } // ADD::operator+=
  645. ADD
  646. ADD::operator-(
  647. const ADD& other) const
  648. {
  649. DdManager *mgr = checkSameManager(other);
  650. DdNode *result = Cudd_addApply(mgr,Cudd_addMinus,node,other.node);
  651. checkReturnValue(result);
  652. return ADD(p, result);
  653. } // ADD::operator-
  654. ADD
  655. ADD::operator-=(
  656. const ADD& other)
  657. {
  658. DdManager *mgr = checkSameManager(other);
  659. DdNode *result = Cudd_addApply(mgr,Cudd_addMinus,node,other.node);
  660. checkReturnValue(result);
  661. Cudd_Ref(result);
  662. Cudd_RecursiveDeref(mgr,node);
  663. node = result;
  664. return *this;
  665. } // ADD::operator-=
  666. ADD
  667. ADD::operator~() const
  668. {
  669. return ADD(p, Cudd_addCmpl(p->manager,node));
  670. } // ADD::operator~
  671. ADD
  672. ADD::operator&(
  673. const ADD& other) const
  674. {
  675. DdManager *mgr = checkSameManager(other);
  676. DdNode *result = Cudd_addApply(mgr,Cudd_addTimes,node,other.node);
  677. checkReturnValue(result);
  678. return ADD(p, result);
  679. } // ADD::operator&
  680. ADD
  681. ADD::operator&=(
  682. const ADD& other)
  683. {
  684. DdManager *mgr = checkSameManager(other);
  685. DdNode *result = Cudd_addApply(mgr,Cudd_addTimes,node,other.node);
  686. checkReturnValue(result);
  687. Cudd_Ref(result);
  688. Cudd_RecursiveDeref(mgr,node);
  689. node = result;
  690. return *this;
  691. } // ADD::operator&=
  692. ADD
  693. ADD::operator|(
  694. const ADD& other) const
  695. {
  696. DdManager *mgr = checkSameManager(other);
  697. DdNode *result = Cudd_addApply(mgr,Cudd_addOr,node,other.node);
  698. checkReturnValue(result);
  699. return ADD(p, result);
  700. } // ADD::operator|
  701. ADD
  702. ADD::operator|=(
  703. const ADD& other)
  704. {
  705. DdManager *mgr = checkSameManager(other);
  706. DdNode *result = Cudd_addApply(mgr,Cudd_addOr,node,other.node);
  707. checkReturnValue(result);
  708. Cudd_Ref(result);
  709. Cudd_RecursiveDeref(mgr,node);
  710. node = result;
  711. return *this;
  712. } // ADD::operator|=
  713. bool
  714. ADD::IsZero() const
  715. {
  716. return node == Cudd_ReadZero(p->manager);
  717. } // ADD::IsZero
  718. // ---------------------------------------------------------------------------
  719. // Members of class ZDD
  720. // ---------------------------------------------------------------------------
  721. ZDD::ZDD(Capsule *cap, DdNode *bddNode) : DD(cap,bddNode) {}
  722. ZDD::ZDD() : DD() {}
  723. ZDD::ZDD(const ZDD &from) : DD(from) {}
  724. ZDD::~ZDD() {
  725. if (node) {
  726. Cudd_RecursiveDerefZdd(p->manager,node);
  727. if (p->verbose) {
  728. cout << "ZDD destructor called for node " << hex << node << dec <<
  729. " ref = " << Cudd_Regular(node)->ref << "\n";
  730. }
  731. }
  732. } // ZDD::~ZDD
  733. ZDD
  734. ZDD::operator=(
  735. const ZDD& right)
  736. {
  737. if (this == &right) return *this;
  738. if (right.node) Cudd_Ref(right.node);
  739. if (node) {
  740. Cudd_RecursiveDerefZdd(p->manager,node);
  741. if (p->verbose) {
  742. cout << "ZDD dereferencing for node " << hex << node << dec <<
  743. " ref = " << node->ref << "\n";
  744. }
  745. }
  746. node = right.node;
  747. p = right.p;
  748. if (node && p->verbose) {
  749. cout << "ZDD assignment for node " << hex << node << dec <<
  750. " ref = " << node->ref << "\n";
  751. }
  752. return *this;
  753. } // ZDD::operator=
  754. bool
  755. ZDD::operator==(
  756. const ZDD& other) const
  757. {
  758. checkSameManager(other);
  759. return node == other.node;
  760. } // ZDD::operator==
  761. bool
  762. ZDD::operator!=(
  763. const ZDD& other) const
  764. {
  765. checkSameManager(other);
  766. return node != other.node;
  767. } // ZDD::operator!=
  768. bool
  769. ZDD::operator<=(
  770. const ZDD& other) const
  771. {
  772. DdManager *mgr = checkSameManager(other);
  773. return Cudd_zddDiffConst(mgr,node,other.node) == Cudd_ReadZero(mgr);
  774. } // ZDD::operator<=
  775. bool
  776. ZDD::operator>=(
  777. const ZDD& other) const
  778. {
  779. DdManager *mgr = checkSameManager(other);
  780. return Cudd_zddDiffConst(mgr,other.node,node) == Cudd_ReadZero(mgr);
  781. } // ZDD::operator>=
  782. bool
  783. ZDD::operator<(
  784. const ZDD& other) const
  785. {
  786. DdManager *mgr = checkSameManager(other);
  787. return node != other.node &&
  788. Cudd_zddDiffConst(mgr,node,other.node) == Cudd_ReadZero(mgr);
  789. } // ZDD::operator<
  790. bool
  791. ZDD::operator>(
  792. const ZDD& other) const
  793. {
  794. DdManager *mgr = checkSameManager(other);
  795. return node != other.node &&
  796. Cudd_zddDiffConst(mgr,other.node,node) == Cudd_ReadZero(mgr);
  797. } // ZDD::operator>
  798. void
  799. ZDD::print(
  800. int nvars,
  801. int verbosity) const
  802. {
  803. cout.flush();
  804. int retval = Cudd_zddPrintDebug(p->manager,node,nvars,verbosity);
  805. fflush(Cudd_ReadStdout(p->manager));
  806. if (retval == 0) p->errorHandler("print failed");
  807. } // ZDD::print
  808. ZDD
  809. ZDD::operator*(
  810. const ZDD& other) const
  811. {
  812. DdManager *mgr = checkSameManager(other);
  813. DdNode *result = Cudd_zddIntersect(mgr,node,other.node);
  814. checkReturnValue(result);
  815. return ZDD(p, result);
  816. } // ZDD::operator*
  817. ZDD
  818. ZDD::operator*=(
  819. const ZDD& other)
  820. {
  821. DdManager *mgr = checkSameManager(other);
  822. DdNode *result = Cudd_zddIntersect(mgr,node,other.node);
  823. checkReturnValue(result);
  824. Cudd_Ref(result);
  825. Cudd_RecursiveDerefZdd(mgr,node);
  826. node = result;
  827. return *this;
  828. } // ZDD::operator*=
  829. ZDD
  830. ZDD::operator&(
  831. const ZDD& other) const
  832. {
  833. DdManager *mgr = checkSameManager(other);
  834. DdNode *result = Cudd_zddIntersect(mgr,node,other.node);
  835. checkReturnValue(result);
  836. return ZDD(p, result);
  837. } // ZDD::operator&
  838. ZDD
  839. ZDD::operator&=(
  840. const ZDD& other)
  841. {
  842. DdManager *mgr = checkSameManager(other);
  843. DdNode *result = Cudd_zddIntersect(mgr,node,other.node);
  844. checkReturnValue(result);
  845. Cudd_Ref(result);
  846. Cudd_RecursiveDerefZdd(mgr,node);
  847. node = result;
  848. return *this;
  849. } // ZDD::operator&=
  850. ZDD
  851. ZDD::operator+(
  852. const ZDD& other) const
  853. {
  854. DdManager *mgr = checkSameManager(other);
  855. DdNode *result = Cudd_zddUnion(mgr,node,other.node);
  856. checkReturnValue(result);
  857. return ZDD(p, result);
  858. } // ZDD::operator+
  859. ZDD
  860. ZDD::operator+=(
  861. const ZDD& other)
  862. {
  863. DdManager *mgr = checkSameManager(other);
  864. DdNode *result = Cudd_zddUnion(mgr,node,other.node);
  865. checkReturnValue(result);
  866. Cudd_Ref(result);
  867. Cudd_RecursiveDerefZdd(mgr,node);
  868. node = result;
  869. return *this;
  870. } // ZDD::operator+=
  871. ZDD
  872. ZDD::operator|(
  873. const ZDD& other) const
  874. {
  875. DdManager *mgr = checkSameManager(other);
  876. DdNode *result = Cudd_zddUnion(mgr,node,other.node);
  877. checkReturnValue(result);
  878. return ZDD(p, result);
  879. } // ZDD::operator|
  880. ZDD
  881. ZDD::operator|=(
  882. const ZDD& other)
  883. {
  884. DdManager *mgr = checkSameManager(other);
  885. DdNode *result = Cudd_zddUnion(mgr,node,other.node);
  886. checkReturnValue(result);
  887. Cudd_Ref(result);
  888. Cudd_RecursiveDerefZdd(mgr,node);
  889. node = result;
  890. return *this;
  891. } // ZDD::operator|=
  892. ZDD
  893. ZDD::operator-(
  894. const ZDD& other) const
  895. {
  896. DdManager *mgr = checkSameManager(other);
  897. DdNode *result = Cudd_zddDiff(mgr,node,other.node);
  898. checkReturnValue(result);
  899. return ZDD(p, result);
  900. } // ZDD::operator-
  901. ZDD
  902. ZDD::operator-=(
  903. const ZDD& other)
  904. {
  905. DdManager *mgr = checkSameManager(other);
  906. DdNode *result = Cudd_zddDiff(mgr,node,other.node);
  907. checkReturnValue(result);
  908. Cudd_Ref(result);
  909. Cudd_RecursiveDerefZdd(mgr,node);
  910. node = result;
  911. return *this;
  912. } // ZDD::operator-=
  913. // ---------------------------------------------------------------------------
  914. // Members of class Cudd
  915. // ---------------------------------------------------------------------------
  916. Cudd::Cudd(
  917. unsigned int numVars,
  918. unsigned int numVarsZ,
  919. unsigned int numSlots,
  920. unsigned int cacheSize,
  921. unsigned long maxMemory,
  922. PFC defaultHandler)
  923. {
  924. p = new Capsule(numVars,numVarsZ,numSlots,cacheSize,maxMemory,defaultHandler);
  925. } // Cudd::Cudd
  926. Cudd::Cudd(
  927. const Cudd& x)
  928. {
  929. p = x.p;
  930. x.p->ref++;
  931. if (p->verbose)
  932. cout << "Cudd Copy Constructor" << endl;
  933. } // Cudd::Cudd
  934. Cudd::~Cudd()
  935. {
  936. if (--p->ref == 0) {
  937. delete p;
  938. }
  939. } // Cudd::~Cudd
  940. DdManager *
  941. Cudd::getManager(void) const
  942. {
  943. return p->manager;
  944. } // Cudd::getManager
  945. void
  946. Cudd::makeVerbose(void) const
  947. {
  948. p->verbose = 1;
  949. } // Cudd::makeVerbose
  950. void
  951. Cudd::makeTerse(void) const
  952. {
  953. p->verbose = 0;
  954. } // Cudd::makeTerse
  955. bool
  956. Cudd::isVerbose(void) const
  957. {
  958. return p->verbose;
  959. } // Cudd::isVerbose
  960. Cudd&
  961. Cudd::operator=(
  962. const Cudd& right)
  963. {
  964. right.p->ref++;
  965. if (--p->ref == 0) { // disconnect self
  966. delete p;
  967. }
  968. p = right.p;
  969. return *this;
  970. } // Cudd::operator=
  971. PFC
  972. Cudd::setHandler(
  973. PFC newHandler) const
  974. {
  975. PFC oldHandler = p->errorHandler;
  976. p->errorHandler = newHandler;
  977. return oldHandler;
  978. } // Cudd::setHandler
  979. PFC
  980. Cudd::getHandler() const
  981. {
  982. return p->errorHandler;
  983. } // Cudd::getHandler
  984. PFC
  985. Cudd::setTimeoutHandler(
  986. PFC newHandler) const
  987. {
  988. PFC oldHandler = p->timeoutHandler;
  989. p->timeoutHandler = newHandler;
  990. return oldHandler;
  991. } // Cudd::setTimeoutHandler
  992. PFC
  993. Cudd::getTimeoutHandler() const
  994. {
  995. return p->timeoutHandler;
  996. } // Cudd::getTimeourHandler
  997. PFC
  998. Cudd::setTerminationHandler(
  999. PFC newHandler) const
  1000. {
  1001. PFC oldHandler = p->terminationHandler;
  1002. p->terminationHandler = newHandler;
  1003. return oldHandler;
  1004. } // Cudd::setTerminationHandler
  1005. PFC
  1006. Cudd::getTerminationHandler() const
  1007. {
  1008. return p->terminationHandler;
  1009. } // Cudd::getTerminationHandler
  1010. void
  1011. Cudd::pushVariableName(std::string s) const
  1012. {
  1013. char * cstr = new char[s.length() + 1];
  1014. strcpy(cstr, s.c_str());
  1015. p->varnames.push_back(cstr);
  1016. }
  1017. void
  1018. Cudd::clearVariableNames(void) const
  1019. {
  1020. for (vector<char *>::iterator it = p->varnames.begin();
  1021. it != p->varnames.end(); ++it) {
  1022. delete [] *it;
  1023. }
  1024. p->varnames.clear();
  1025. }
  1026. std::string
  1027. Cudd::getVariableName(size_t i) const
  1028. {
  1029. return std::string(p->varnames.at(i));
  1030. }
  1031. inline void
  1032. Cudd::checkReturnValue(
  1033. const void *result) const
  1034. {
  1035. if (result == 0) {
  1036. if (Cudd_ReadErrorCode(p->manager) == CUDD_MEMORY_OUT) {
  1037. p->errorHandler("Out of memory.");
  1038. } else if (Cudd_ReadErrorCode(p->manager) == CUDD_TOO_MANY_NODES) {
  1039. p->errorHandler("Too many nodes.");
  1040. } else if (Cudd_ReadErrorCode(p->manager) == CUDD_MAX_MEM_EXCEEDED) {
  1041. p->errorHandler("Maximum memory exceeded.");
  1042. } else if (Cudd_ReadErrorCode(p->manager) == CUDD_TIMEOUT_EXPIRED) {
  1043. std::ostringstream msg;
  1044. DdManager *mgr = p->manager;
  1045. unsigned long lag =
  1046. Cudd_ReadElapsedTime(mgr) - Cudd_ReadTimeLimit(mgr);
  1047. msg << "Timeout expired. Lag = " << lag << " ms.\n";
  1048. p->timeoutHandler(msg.str());
  1049. } else if (Cudd_ReadErrorCode(p->manager) == CUDD_TERMINATION) {
  1050. std::ostringstream msg;
  1051. msg << "Terminated.\n";
  1052. p->terminationHandler(msg.str());
  1053. } else if (Cudd_ReadErrorCode(p->manager) == CUDD_INVALID_ARG) {
  1054. p->errorHandler("Invalid argument.");
  1055. } else if (Cudd_ReadErrorCode(p->manager) == CUDD_INTERNAL_ERROR) {
  1056. p->errorHandler("Internal error.");
  1057. } else {
  1058. p->errorHandler("Unexpected error.");
  1059. }
  1060. }
  1061. } // Cudd::checkReturnValue
  1062. inline void
  1063. Cudd::checkReturnValue(
  1064. const int result) const
  1065. {
  1066. if (result == 0) {
  1067. if (Cudd_ReadErrorCode(p->manager) == CUDD_MEMORY_OUT) {
  1068. p->errorHandler("Out of memory.");
  1069. } else if (Cudd_ReadErrorCode(p->manager) == CUDD_TOO_MANY_NODES) {
  1070. p->errorHandler("Too many nodes.");
  1071. } else if (Cudd_ReadErrorCode(p->manager) == CUDD_MAX_MEM_EXCEEDED) {
  1072. p->errorHandler("Maximum memory exceeded.");
  1073. } else if (Cudd_ReadErrorCode(p->manager) == CUDD_TIMEOUT_EXPIRED) {
  1074. std::ostringstream msg;
  1075. DdManager *mgr = p->manager;
  1076. unsigned long lag =
  1077. Cudd_ReadElapsedTime(mgr) - Cudd_ReadTimeLimit(mgr);
  1078. msg << "Timeout expired. Lag = " << lag << " ms.\n";
  1079. p->timeoutHandler(msg.str());
  1080. } else if (Cudd_ReadErrorCode(p->manager) == CUDD_TERMINATION) {
  1081. std::ostringstream msg;
  1082. msg << "Terminated.\n";
  1083. p->terminationHandler(msg.str());
  1084. } else if (Cudd_ReadErrorCode(p->manager) == CUDD_INVALID_ARG) {
  1085. p->errorHandler("Invalid argument.");
  1086. } else if (Cudd_ReadErrorCode(p->manager) == CUDD_INTERNAL_ERROR) {
  1087. p->errorHandler("Internal error.");
  1088. } else {
  1089. p->errorHandler("Unexpected error.");
  1090. }
  1091. }
  1092. } // Cudd::checkReturnValue
  1093. void
  1094. Cudd::info() const
  1095. {
  1096. cout.flush();
  1097. int retval = Cudd_PrintInfo(p->manager,stdout);
  1098. checkReturnValue(retval);
  1099. } // Cudd::info
  1100. BDD
  1101. Cudd::bddVar() const
  1102. {
  1103. DdNode *result = Cudd_bddNewVar(p->manager);
  1104. checkReturnValue(result);
  1105. return BDD(p, result);
  1106. } // Cudd::bddVar
  1107. BDD
  1108. Cudd::bddVar(
  1109. int index) const
  1110. {
  1111. DdNode *result = Cudd_bddIthVar(p->manager,index);
  1112. checkReturnValue(result);
  1113. return BDD(p, result);
  1114. } // Cudd::bddVar
  1115. BDD
  1116. Cudd::bddOne() const
  1117. {
  1118. DdNode *result = Cudd_ReadOne(p->manager);
  1119. checkReturnValue(result);
  1120. return BDD(p, result);
  1121. } // Cudd::bddOne
  1122. BDD
  1123. Cudd::bddZero() const
  1124. {
  1125. DdNode *result = Cudd_ReadLogicZero(p->manager);
  1126. checkReturnValue(result);
  1127. return BDD(p, result);
  1128. } // Cudd::bddZero
  1129. ADD
  1130. Cudd::addVar() const
  1131. {
  1132. DdNode *result = Cudd_addNewVar(p->manager);
  1133. checkReturnValue(result);
  1134. return ADD(p, result);
  1135. } // Cudd::addVar
  1136. ADD
  1137. Cudd::addVar(
  1138. int index) const
  1139. {
  1140. DdNode *result = Cudd_addIthVar(p->manager,index);
  1141. checkReturnValue(result);
  1142. return ADD(p, result);
  1143. } // Cudd::addVar
  1144. ADD
  1145. Cudd::addOne() const
  1146. {
  1147. DdNode *result = Cudd_ReadOne(p->manager);
  1148. checkReturnValue(result);
  1149. return ADD(p, result);
  1150. } // Cudd::addOne
  1151. ADD
  1152. Cudd::addZero() const
  1153. {
  1154. DdNode *result = Cudd_ReadZero(p->manager);
  1155. checkReturnValue(result);
  1156. return ADD(p, result);
  1157. } // Cudd::addZero
  1158. ADD
  1159. Cudd::constant(
  1160. CUDD_VALUE_TYPE c) const
  1161. {
  1162. DdNode *result = Cudd_addConst(p->manager, c);
  1163. checkReturnValue(result);
  1164. return ADD(p, result);
  1165. } // Cudd::constant
  1166. ADD
  1167. Cudd::plusInfinity() const
  1168. {
  1169. DdNode *result = Cudd_ReadPlusInfinity(p->manager);
  1170. checkReturnValue(result);
  1171. return ADD(p, result);
  1172. } // Cudd::plusInfinity
  1173. ADD
  1174. Cudd::minusInfinity() const
  1175. {
  1176. DdNode *result = Cudd_ReadMinusInfinity(p->manager);
  1177. checkReturnValue(result);
  1178. return ADD(p, result);
  1179. } // Cudd::minusInfinity
  1180. ZDD
  1181. Cudd::zddVar(
  1182. int index) const
  1183. {
  1184. DdNode *result = Cudd_zddIthVar(p->manager,index);
  1185. checkReturnValue(result);
  1186. return ZDD(p, result);
  1187. } // Cudd::zddVar
  1188. ZDD
  1189. Cudd::zddOne(
  1190. int i) const
  1191. {
  1192. DdNode *result = Cudd_ReadZddOne(p->manager,i);
  1193. checkReturnValue(result);
  1194. return ZDD(p, result);
  1195. } // Cudd::zddOne
  1196. ZDD
  1197. Cudd::zddZero() const
  1198. {
  1199. DdNode *result = Cudd_ReadZero(p->manager);
  1200. checkReturnValue(result);
  1201. return ZDD(p, result);
  1202. } // Cudd::zddZero
  1203. void
  1204. defaultError(
  1205. string message)
  1206. {
  1207. throw std::logic_error(message);
  1208. } // defaultError
  1209. // ---------------------------------------------------------------------------
  1210. // All the rest
  1211. // ---------------------------------------------------------------------------
  1212. ADD
  1213. Cudd::addNewVarAtLevel(
  1214. int level) const
  1215. {
  1216. DdNode *result = Cudd_addNewVarAtLevel(p->manager, level);
  1217. checkReturnValue(result);
  1218. return ADD(p, result);
  1219. } // Cudd::addNewVarAtLevel
  1220. BDD
  1221. Cudd::bddNewVarAtLevel(
  1222. int level) const
  1223. {
  1224. DdNode *result = Cudd_bddNewVarAtLevel(p->manager, level);
  1225. checkReturnValue(result);
  1226. return BDD(p, result);
  1227. } // Cudd::bddNewVarAtLevel
  1228. void
  1229. Cudd::zddVarsFromBddVars(
  1230. int multiplicity) const
  1231. {
  1232. int result = Cudd_zddVarsFromBddVars(p->manager, multiplicity);
  1233. checkReturnValue(result);
  1234. } // Cudd::zddVarsFromBddVars
  1235. unsigned long
  1236. Cudd::ReadStartTime() const
  1237. {
  1238. return Cudd_ReadStartTime(p->manager);
  1239. } // Cudd::ReadStartTime
  1240. unsigned long
  1241. Cudd::ReadElapsedTime() const
  1242. {
  1243. return Cudd_ReadElapsedTime(p->manager);
  1244. } // Cudd::ReadElapsedTime
  1245. void
  1246. Cudd::SetStartTime(
  1247. unsigned long st) const
  1248. {
  1249. Cudd_SetStartTime(p->manager, st);
  1250. } // Cudd::SetStartTime
  1251. void
  1252. Cudd::ResetStartTime() const
  1253. {
  1254. Cudd_ResetStartTime(p->manager);
  1255. } // Cudd::ResetStartTime
  1256. unsigned long
  1257. Cudd::ReadTimeLimit() const
  1258. {
  1259. return Cudd_ReadTimeLimit(p->manager);
  1260. } // Cudd::ReadTimeLimit
  1261. unsigned long
  1262. Cudd::SetTimeLimit(
  1263. unsigned long tl) const
  1264. {
  1265. return Cudd_SetTimeLimit(p->manager, tl);
  1266. } // Cudd::SetTimeLimit
  1267. void
  1268. Cudd::UpdateTimeLimit() const
  1269. {
  1270. Cudd_UpdateTimeLimit(p->manager);
  1271. } // Cudd::UpdateTimeLimit
  1272. void
  1273. Cudd::IncreaseTimeLimit(
  1274. unsigned long increase) const
  1275. {
  1276. Cudd_IncreaseTimeLimit(p->manager, increase);
  1277. } // Cudd::IncreaseTimeLimit
  1278. void
  1279. Cudd::UnsetTimeLimit() const
  1280. {
  1281. Cudd_UnsetTimeLimit(p->manager);
  1282. } // Cudd::UnsetTimeLimit
  1283. bool
  1284. Cudd::TimeLimited() const
  1285. {
  1286. return Cudd_TimeLimited(p->manager);
  1287. } // Cudd::TimeLimited
  1288. void
  1289. Cudd::RegisterTerminationCallback(
  1290. DD_THFP callback,
  1291. void * callback_arg) const
  1292. {
  1293. Cudd_RegisterTerminationCallback(p->manager, callback, callback_arg);
  1294. } // Cudd::RegisterTerminationCallback
  1295. void
  1296. Cudd::UnregisterTerminationCallback() const
  1297. {
  1298. Cudd_UnregisterTerminationCallback(p->manager);
  1299. } // Cudd::UnregisterTerminationCallback
  1300. DD_OOMFP
  1301. Cudd::RegisterOutOfMemoryCallback(
  1302. DD_OOMFP callback) const
  1303. {
  1304. return Cudd_RegisterOutOfMemoryCallback(p->manager, callback);
  1305. } // Cudd::RegisterOutOfMemoryCallback
  1306. void
  1307. Cudd::UnregisterOutOfMemoryCallback() const
  1308. {
  1309. Cudd_UnregisterOutOfMemoryCallback(p->manager);
  1310. } // Cudd::UnregisterOutOfMemoryCallback
  1311. void
  1312. Cudd::AutodynEnable(
  1313. Cudd_ReorderingType method) const
  1314. {
  1315. Cudd_AutodynEnable(p->manager, method);
  1316. } // Cudd::AutodynEnable
  1317. void
  1318. Cudd::AutodynDisable() const
  1319. {
  1320. Cudd_AutodynDisable(p->manager);
  1321. } // Cudd::AutodynDisable
  1322. bool
  1323. Cudd::ReorderingStatus(
  1324. Cudd_ReorderingType * method) const
  1325. {
  1326. return Cudd_ReorderingStatus(p->manager, method);
  1327. } // Cudd::ReorderingStatus
  1328. void
  1329. Cudd::AutodynEnableZdd(
  1330. Cudd_ReorderingType method) const
  1331. {
  1332. Cudd_AutodynEnableZdd(p->manager, method);
  1333. } // Cudd::AutodynEnableZdd
  1334. void
  1335. Cudd::AutodynDisableZdd() const
  1336. {
  1337. Cudd_AutodynDisableZdd(p->manager);
  1338. } // Cudd::AutodynDisableZdd
  1339. bool
  1340. Cudd::ReorderingStatusZdd(
  1341. Cudd_ReorderingType * method) const
  1342. {
  1343. return Cudd_ReorderingStatusZdd(p->manager, method);
  1344. } // Cudd::ReorderingStatusZdd
  1345. bool
  1346. Cudd::zddRealignmentEnabled() const
  1347. {
  1348. return Cudd_zddRealignmentEnabled(p->manager);
  1349. } // Cudd::zddRealignmentEnabled
  1350. void
  1351. Cudd::zddRealignEnable() const
  1352. {
  1353. Cudd_zddRealignEnable(p->manager);
  1354. } // Cudd::zddRealignEnable
  1355. void
  1356. Cudd::zddRealignDisable() const
  1357. {
  1358. Cudd_zddRealignDisable(p->manager);
  1359. } // Cudd::zddRealignDisable
  1360. bool
  1361. Cudd::bddRealignmentEnabled() const
  1362. {
  1363. return Cudd_bddRealignmentEnabled(p->manager);
  1364. } // Cudd::bddRealignmentEnabled
  1365. void
  1366. Cudd::bddRealignEnable() const
  1367. {
  1368. Cudd_bddRealignEnable(p->manager);
  1369. } // Cudd::bddRealignEnable
  1370. void
  1371. Cudd::bddRealignDisable() const
  1372. {
  1373. Cudd_bddRealignDisable(p->manager);
  1374. } // Cudd::bddRealignDisable
  1375. ADD
  1376. Cudd::background() const
  1377. {
  1378. DdNode *result = Cudd_ReadBackground(p->manager);
  1379. checkReturnValue(result);
  1380. return ADD(p, result);
  1381. } // Cudd::background
  1382. void
  1383. Cudd::SetBackground(
  1384. ADD bg) const
  1385. {
  1386. DdManager *mgr = p->manager;
  1387. if (mgr != bg.manager()) {
  1388. p->errorHandler("Background comes from different manager.");
  1389. }
  1390. Cudd_SetBackground(mgr, bg.getNode());
  1391. } // Cudd::SetBackground
  1392. unsigned int
  1393. Cudd::ReadCacheSlots() const
  1394. {
  1395. return Cudd_ReadCacheSlots(p->manager);
  1396. } // Cudd::ReadCacheSlots
  1397. double
  1398. Cudd::ReadCacheLookUps() const
  1399. {
  1400. return Cudd_ReadCacheLookUps(p->manager);
  1401. } // Cudd::ReadCacheLookUps
  1402. double
  1403. Cudd::ReadCacheUsedSlots() const
  1404. {
  1405. return Cudd_ReadCacheUsedSlots(p->manager);
  1406. } // Cudd::ReadCacheUsedSlots
  1407. double
  1408. Cudd::ReadCacheHits() const
  1409. {
  1410. return Cudd_ReadCacheHits(p->manager);
  1411. } // Cudd::ReadCacheHits
  1412. unsigned int
  1413. Cudd::ReadMinHit() const
  1414. {
  1415. return Cudd_ReadMinHit(p->manager);
  1416. } // Cudd::ReadMinHit
  1417. void
  1418. Cudd::SetMinHit(
  1419. unsigned int hr) const
  1420. {
  1421. Cudd_SetMinHit(p->manager, hr);
  1422. } // Cudd::SetMinHit
  1423. unsigned int
  1424. Cudd::ReadLooseUpTo() const
  1425. {
  1426. return Cudd_ReadLooseUpTo(p->manager);
  1427. } // Cudd::ReadLooseUpTo
  1428. void
  1429. Cudd::SetLooseUpTo(
  1430. unsigned int lut) const
  1431. {
  1432. Cudd_SetLooseUpTo(p->manager, lut);
  1433. } // Cudd::SetLooseUpTo
  1434. unsigned int
  1435. Cudd::ReadMaxCache() const
  1436. {
  1437. return Cudd_ReadMaxCache(p->manager);
  1438. } // Cudd::ReadMaxCache
  1439. unsigned int
  1440. Cudd::ReadMaxCacheHard() const
  1441. {
  1442. return Cudd_ReadMaxCacheHard(p->manager);
  1443. } // Cudd::ReadMaxCacheHard
  1444. void
  1445. Cudd::SetMaxCacheHard(
  1446. unsigned int mc) const
  1447. {
  1448. Cudd_SetMaxCacheHard(p->manager, mc);
  1449. } // Cudd::SetMaxCacheHard
  1450. int
  1451. Cudd::ReadSize() const
  1452. {
  1453. return Cudd_ReadSize(p->manager);
  1454. } // Cudd::ReadSize
  1455. int
  1456. Cudd::ReadZddSize() const
  1457. {
  1458. return Cudd_ReadZddSize(p->manager);
  1459. } // Cudd::ReadZddSize
  1460. unsigned int
  1461. Cudd::ReadSlots() const
  1462. {
  1463. return Cudd_ReadSlots(p->manager);
  1464. } // Cudd::ReadSlots
  1465. unsigned int
  1466. Cudd::ReadKeys() const
  1467. {
  1468. return Cudd_ReadKeys(p->manager);
  1469. } // Cudd::ReadKeys
  1470. unsigned int
  1471. Cudd::ReadDead() const
  1472. {
  1473. return Cudd_ReadDead(p->manager);
  1474. } // Cudd::ReadDead
  1475. unsigned int
  1476. Cudd::ReadMinDead() const
  1477. {
  1478. return Cudd_ReadMinDead(p->manager);
  1479. } // Cudd::ReadMinDead
  1480. unsigned int
  1481. Cudd::ReadReorderings() const
  1482. {
  1483. return Cudd_ReadReorderings(p->manager);
  1484. } // Cudd::ReadReorderings
  1485. unsigned int
  1486. Cudd::ReadMaxReorderings() const
  1487. {
  1488. return Cudd_ReadMaxReorderings(p->manager);
  1489. } // Cudd::ReadMaxReorderings
  1490. void
  1491. Cudd::SetMaxReorderings(
  1492. unsigned int mr) const
  1493. {
  1494. Cudd_SetMaxReorderings(p->manager, mr);
  1495. } // Cudd::SetMaxReorderings
  1496. long
  1497. Cudd::ReadReorderingTime() const
  1498. {
  1499. return Cudd_ReadReorderingTime(p->manager);
  1500. } // Cudd::ReadReorderingTime
  1501. int
  1502. Cudd::ReadGarbageCollections() const
  1503. {
  1504. return Cudd_ReadGarbageCollections(p->manager);
  1505. } // Cudd::ReadGarbageCollections
  1506. long
  1507. Cudd::ReadGarbageCollectionTime() const
  1508. {
  1509. return Cudd_ReadGarbageCollectionTime(p->manager);
  1510. } // Cudd::ReadGarbageCollectionTime
  1511. int
  1512. Cudd::ReadSiftMaxVar() const
  1513. {
  1514. return Cudd_ReadSiftMaxVar(p->manager);
  1515. } // Cudd::ReadSiftMaxVar
  1516. void
  1517. Cudd::SetSiftMaxVar(
  1518. int smv) const
  1519. {
  1520. Cudd_SetSiftMaxVar(p->manager, smv);
  1521. } // Cudd::SetSiftMaxVar
  1522. int
  1523. Cudd::ReadSiftMaxSwap() const
  1524. {
  1525. return Cudd_ReadSiftMaxSwap(p->manager);
  1526. } // Cudd::ReadSiftMaxSwap
  1527. void
  1528. Cudd::SetSiftMaxSwap(
  1529. int sms) const
  1530. {
  1531. Cudd_SetSiftMaxSwap(p->manager, sms);
  1532. } // Cudd::SetSiftMaxSwap
  1533. double
  1534. Cudd::ReadMaxGrowth() const
  1535. {
  1536. return Cudd_ReadMaxGrowth(p->manager);
  1537. } // Cudd::ReadMaxGrowth
  1538. void
  1539. Cudd::SetMaxGrowth(
  1540. double mg) const
  1541. {
  1542. Cudd_SetMaxGrowth(p->manager, mg);
  1543. } // Cudd::SetMaxGrowth
  1544. MtrNode *
  1545. Cudd::ReadTree() const
  1546. {
  1547. return Cudd_ReadTree(p->manager);
  1548. } // Cudd::ReadTree
  1549. void
  1550. Cudd::SetTree(
  1551. MtrNode * tree) const
  1552. {
  1553. Cudd_SetTree(p->manager, tree);
  1554. } // Cudd::SetTree
  1555. void
  1556. Cudd::FreeTree() const
  1557. {
  1558. Cudd_FreeTree(p->manager);
  1559. } // Cudd::FreeTree
  1560. MtrNode *
  1561. Cudd::ReadZddTree() const
  1562. {
  1563. return Cudd_ReadZddTree(p->manager);
  1564. } // Cudd::ReadZddTree
  1565. void
  1566. Cudd::SetZddTree(
  1567. MtrNode * tree) const
  1568. {
  1569. Cudd_SetZddTree(p->manager, tree);
  1570. } // Cudd::SetZddTree
  1571. void
  1572. Cudd::FreeZddTree() const
  1573. {
  1574. Cudd_FreeZddTree(p->manager);
  1575. } // Cudd::FreeZddTree
  1576. int
  1577. Cudd::ReadPerm(
  1578. int i) const
  1579. {
  1580. return Cudd_ReadPerm(p->manager, i);
  1581. } // Cudd::ReadPerm
  1582. int
  1583. Cudd::ReadPermZdd(
  1584. int i) const
  1585. {
  1586. return Cudd_ReadPermZdd(p->manager, i);
  1587. } // Cudd::ReadPermZdd
  1588. int
  1589. Cudd::ReadInvPerm(
  1590. int i) const
  1591. {
  1592. return Cudd_ReadInvPerm(p->manager, i);
  1593. } // Cudd::ReadInvPerm
  1594. int
  1595. Cudd::ReadInvPermZdd(
  1596. int i) const
  1597. {
  1598. return Cudd_ReadInvPermZdd(p->manager, i);
  1599. } // Cudd::ReadInvPermZdd
  1600. BDD
  1601. Cudd::ReadVars(
  1602. int i) const
  1603. {
  1604. DdNode *result = Cudd_ReadVars(p->manager, i);
  1605. checkReturnValue(result);
  1606. return BDD(p, result);
  1607. } // Cudd::ReadVars
  1608. CUDD_VALUE_TYPE
  1609. Cudd::ReadEpsilon() const
  1610. {
  1611. return Cudd_ReadEpsilon(p->manager);
  1612. } // Cudd::ReadEpsilon
  1613. void
  1614. Cudd::SetEpsilon(
  1615. CUDD_VALUE_TYPE ep) const
  1616. {
  1617. Cudd_SetEpsilon(p->manager, ep);
  1618. } // Cudd::SetEpsilon
  1619. Cudd_AggregationType
  1620. Cudd::ReadGroupcheck() const
  1621. {
  1622. return Cudd_ReadGroupcheck(p->manager);
  1623. } // Cudd::ReadGroupcheck
  1624. void
  1625. Cudd::SetGroupcheck(
  1626. Cudd_AggregationType gc) const
  1627. {
  1628. Cudd_SetGroupcheck(p->manager, gc);
  1629. } // Cudd::SetGroupcheck
  1630. bool
  1631. Cudd::GarbageCollectionEnabled() const
  1632. {
  1633. return Cudd_GarbageCollectionEnabled(p->manager);
  1634. } // Cudd::GarbageCollectionEnabled
  1635. void
  1636. Cudd::EnableGarbageCollection() const
  1637. {
  1638. Cudd_EnableGarbageCollection(p->manager);
  1639. } // Cudd::EnableGarbageCollection
  1640. void
  1641. Cudd::DisableGarbageCollection() const
  1642. {
  1643. Cudd_DisableGarbageCollection(p->manager);
  1644. } // Cudd::DisableGarbageCollection
  1645. bool
  1646. Cudd::DeadAreCounted() const
  1647. {
  1648. return Cudd_DeadAreCounted(p->manager);
  1649. } // Cudd::DeadAreCounted
  1650. void
  1651. Cudd::TurnOnCountDead() const
  1652. {
  1653. Cudd_TurnOnCountDead(p->manager);
  1654. } // Cudd::TurnOnCountDead
  1655. void
  1656. Cudd::TurnOffCountDead() const
  1657. {
  1658. Cudd_TurnOffCountDead(p->manager);
  1659. } // Cudd::TurnOffCountDead
  1660. int
  1661. Cudd::ReadRecomb() const
  1662. {
  1663. return Cudd_ReadRecomb(p->manager);
  1664. } // Cudd::ReadRecomb
  1665. void
  1666. Cudd::SetRecomb(
  1667. int recomb) const
  1668. {
  1669. Cudd_SetRecomb(p->manager, recomb);
  1670. } // Cudd::SetRecomb
  1671. int
  1672. Cudd::ReadSymmviolation() const
  1673. {
  1674. return Cudd_ReadSymmviolation(p->manager);
  1675. } // Cudd::ReadSymmviolation
  1676. void
  1677. Cudd::SetSymmviolation(
  1678. int symmviolation) const
  1679. {
  1680. Cudd_SetSymmviolation(p->manager, symmviolation);
  1681. } // Cudd::SetSymmviolation
  1682. int
  1683. Cudd::ReadArcviolation() const
  1684. {
  1685. return Cudd_ReadArcviolation(p->manager);
  1686. } // Cudd::ReadArcviolation
  1687. void
  1688. Cudd::SetArcviolation(
  1689. int arcviolation) const
  1690. {
  1691. Cudd_SetArcviolation(p->manager, arcviolation);
  1692. } // Cudd::SetArcviolation
  1693. int
  1694. Cudd::ReadPopulationSize() const
  1695. {
  1696. return Cudd_ReadPopulationSize(p->manager);
  1697. } // Cudd::ReadPopulationSize
  1698. void
  1699. Cudd::SetPopulationSize(
  1700. int populationSize) const
  1701. {
  1702. Cudd_SetPopulationSize(p->manager, populationSize);
  1703. } // Cudd::SetPopulationSize
  1704. int
  1705. Cudd::ReadNumberXovers() const
  1706. {
  1707. return Cudd_ReadNumberXovers(p->manager);
  1708. } // Cudd::ReadNumberXovers
  1709. void
  1710. Cudd::SetNumberXovers(
  1711. int numberXovers) const
  1712. {
  1713. Cudd_SetNumberXovers(p->manager, numberXovers);
  1714. } // Cudd::SetNumberXovers
  1715. unsigned int
  1716. Cudd::ReadOrderRandomization() const
  1717. {
  1718. return Cudd_ReadOrderRandomization(p->manager);
  1719. } // Cudd::ReadOrderRandomization
  1720. void
  1721. Cudd::SetOrderRandomization(
  1722. unsigned int factor) const
  1723. {
  1724. Cudd_SetOrderRandomization(p->manager, factor);
  1725. } // Cudd::SetOrderRandomization
  1726. unsigned long
  1727. Cudd::ReadMemoryInUse() const
  1728. {
  1729. return Cudd_ReadMemoryInUse(p->manager);
  1730. } // Cudd::ReadMemoryInUse
  1731. long
  1732. Cudd::ReadPeakNodeCount() const
  1733. {
  1734. return Cudd_ReadPeakNodeCount(p->manager);
  1735. } // Cudd::ReadPeakNodeCount
  1736. long
  1737. Cudd::ReadNodeCount() const
  1738. {
  1739. return Cudd_ReadNodeCount(p->manager);
  1740. } // Cudd::ReadNodeCount
  1741. long
  1742. Cudd::zddReadNodeCount() const
  1743. {
  1744. return Cudd_zddReadNodeCount(p->manager);
  1745. } // Cudd::zddReadNodeCount
  1746. void
  1747. Cudd::AddHook(
  1748. DD_HFP f,
  1749. Cudd_HookType where) const
  1750. {
  1751. int result = Cudd_AddHook(p->manager, f, where);
  1752. checkReturnValue(result);
  1753. } // Cudd::AddHook
  1754. void
  1755. Cudd::RemoveHook(
  1756. DD_HFP f,
  1757. Cudd_HookType where) const
  1758. {
  1759. int result = Cudd_RemoveHook(p->manager, f, where);
  1760. checkReturnValue(result);
  1761. } // Cudd::RemoveHook
  1762. bool
  1763. Cudd::IsInHook(
  1764. DD_HFP f,
  1765. Cudd_HookType where) const
  1766. {
  1767. return Cudd_IsInHook(p->manager, f, where);
  1768. } // Cudd::IsInHook
  1769. void
  1770. Cudd::EnableReorderingReporting() const
  1771. {
  1772. int result = Cudd_EnableReorderingReporting(p->manager);
  1773. checkReturnValue(result);
  1774. } // Cudd::EnableReorderingReporting
  1775. void
  1776. Cudd::DisableReorderingReporting() const
  1777. {
  1778. int result = Cudd_DisableReorderingReporting(p->manager);
  1779. checkReturnValue(result);
  1780. } // Cudd::DisableReorderingReporting
  1781. bool
  1782. Cudd::ReorderingReporting() const
  1783. {
  1784. return Cudd_ReorderingReporting(p->manager);
  1785. } // Cudd::ReorderingReporting
  1786. int
  1787. Cudd::ReadErrorCode() const
  1788. {
  1789. return Cudd_ReadErrorCode(p->manager);
  1790. } // Cudd::ReadErrorCode
  1791. void
  1792. Cudd::ClearErrorCode() const
  1793. {
  1794. Cudd_ClearErrorCode(p->manager);
  1795. } // Cudd::ClearErrorCode
  1796. DD_OOMFP Cudd::InstallOutOfMemoryHandler(DD_OOMFP newHandler) const
  1797. {
  1798. return Cudd_InstallOutOfMemoryHandler(newHandler);
  1799. } // Cudd::InstallOutOfMemoryHandler
  1800. FILE *
  1801. Cudd::ReadStdout() const
  1802. {
  1803. return Cudd_ReadStdout(p->manager);
  1804. } // Cudd::ReadStdout
  1805. void
  1806. Cudd::SetStdout(FILE *fp) const
  1807. {
  1808. Cudd_SetStdout(p->manager, fp);
  1809. } // Cudd::SetStdout
  1810. FILE *
  1811. Cudd::ReadStderr() const
  1812. {
  1813. return Cudd_ReadStderr(p->manager);
  1814. } // Cudd::ReadStderr
  1815. void
  1816. Cudd::SetStderr(FILE *fp) const
  1817. {
  1818. Cudd_SetStderr(p->manager, fp);
  1819. } // Cudd::SetStderr
  1820. unsigned int
  1821. Cudd::ReadNextReordering() const
  1822. {
  1823. return Cudd_ReadNextReordering(p->manager);
  1824. } // Cudd::ReadNextReordering
  1825. void
  1826. Cudd::SetNextReordering(
  1827. unsigned int next) const
  1828. {
  1829. Cudd_SetNextReordering(p->manager, next);
  1830. } // Cudd::SetNextReordering
  1831. double
  1832. Cudd::ReadSwapSteps() const
  1833. {
  1834. return Cudd_ReadSwapSteps(p->manager);
  1835. } // Cudd::ReadSwapSteps
  1836. unsigned int
  1837. Cudd::ReadMaxLive() const
  1838. {
  1839. return Cudd_ReadMaxLive(p->manager);
  1840. } // Cudd::ReadMaxLive
  1841. void
  1842. Cudd::SetMaxLive(unsigned int maxLive) const
  1843. {
  1844. Cudd_SetMaxLive(p->manager, maxLive);
  1845. } // Cudd::SetMaxLive
  1846. size_t
  1847. Cudd::ReadMaxMemory() const
  1848. {
  1849. return Cudd_ReadMaxMemory(p->manager);
  1850. } // Cudd::ReadMaxMemory
  1851. size_t
  1852. Cudd::SetMaxMemory(size_t maxMem) const
  1853. {
  1854. return Cudd_SetMaxMemory(p->manager, maxMem);
  1855. } // Cudd::SetMaxMemory
  1856. int
  1857. Cudd::bddBindVar(int index) const
  1858. {
  1859. return Cudd_bddBindVar(p->manager, index);
  1860. } // Cudd::bddBindVar
  1861. int
  1862. Cudd::bddUnbindVar(int index) const
  1863. {
  1864. return Cudd_bddUnbindVar(p->manager, index);
  1865. } // Cudd::bddUnbindVar
  1866. bool
  1867. Cudd::bddVarIsBound(int index) const
  1868. {
  1869. return Cudd_bddVarIsBound(p->manager, index);
  1870. } // Cudd::bddVarIsBound
  1871. ADD
  1872. ADD::ExistAbstract(
  1873. const ADD& cube) const
  1874. {
  1875. DdManager *mgr = checkSameManager(cube);
  1876. DdNode *result = Cudd_addExistAbstract(mgr, node, cube.node);
  1877. checkReturnValue(result);
  1878. return ADD(p, result);
  1879. } // ADD::ExistAbstract
  1880. ADD
  1881. ADD::UnivAbstract(
  1882. const ADD& cube) const
  1883. {
  1884. DdManager *mgr = checkSameManager(cube);
  1885. DdNode *result = Cudd_addUnivAbstract(mgr, node, cube.node);
  1886. checkReturnValue(result);
  1887. return ADD(p, result);
  1888. } // ADD::UnivAbstract
  1889. ADD
  1890. ADD::OrAbstract(
  1891. const ADD& cube) const
  1892. {
  1893. DdManager *mgr = checkSameManager(cube);
  1894. DdNode *result = Cudd_addOrAbstract(mgr, node, cube.node);
  1895. checkReturnValue(result);
  1896. return ADD(p, result);
  1897. } // ADD::OrAbstract
  1898. ADD
  1899. ADD::MinAbstract(const ADD& cube) const
  1900. {
  1901. DdManager *mgr = checkSameManager(cube);
  1902. DdNode *result = Cudd_addMinAbstract(mgr, node, cube.node);
  1903. checkReturnValue(result);
  1904. return ADD(p, result);
  1905. } // ADD::MinAbstract
  1906. ADD
  1907. ADD::MinAbstractExcept0(const ADD& cube) const
  1908. {
  1909. DdManager *mgr = checkSameManager(cube);
  1910. DdNode *result = Cudd_addMinExcept0Abstract(mgr, node, cube.node);
  1911. checkReturnValue(result);
  1912. return ADD(p, result);
  1913. } // ADD::MinAbstractExcept0
  1914. ADD
  1915. ADD::MaxAbstract(const ADD& cube) const
  1916. {
  1917. DdManager *mgr = checkSameManager(cube);
  1918. DdNode *result = Cudd_addMaxAbstract(mgr, node, cube.node);
  1919. checkReturnValue(result);
  1920. return ADD(p, result);
  1921. } // ADD::MaxAbstract
  1922. BDD
  1923. ADD::MinAbstractRepresentative(const ADD& cube) const
  1924. {
  1925. DdManager *mgr = checkSameManager(cube);
  1926. DdNode *result = Cudd_addMinAbstractRepresentative(mgr, node, cube.node);
  1927. checkReturnValue(result);
  1928. return BDD(p, result);
  1929. } // ADD::MinRepresentative
  1930. BDD
  1931. ADD::MaxAbstractRepresentative(const ADD& cube) const
  1932. {
  1933. DdManager *mgr = checkSameManager(cube);
  1934. DdNode *result = Cudd_addMaxAbstractRepresentative(mgr, node, cube.node);
  1935. checkReturnValue(result);
  1936. return BDD(p, result);
  1937. } // ADD::MaxRepresentative
  1938. ADD
  1939. ADD::Plus(
  1940. const ADD& g) const
  1941. {
  1942. DdManager *mgr = checkSameManager(g);
  1943. DdNode *result = Cudd_addApply(mgr, Cudd_addPlus, node, g.node);
  1944. checkReturnValue(result);
  1945. return ADD(p, result);
  1946. } // ADD::Plus
  1947. ADD
  1948. ADD::Times(
  1949. const ADD& g) const
  1950. {
  1951. DdManager *mgr = checkSameManager(g);
  1952. DdNode *result = Cudd_addApply(mgr, Cudd_addTimes, node, g.node);
  1953. checkReturnValue(result);
  1954. return ADD(p, result);
  1955. } // ADD::Times
  1956. ADD
  1957. ADD::Threshold(
  1958. const ADD& g) const
  1959. {
  1960. DdManager *mgr = checkSameManager(g);
  1961. DdNode *result = Cudd_addApply(mgr, Cudd_addThreshold, node, g.node);
  1962. checkReturnValue(result);
  1963. return ADD(p, result);
  1964. } // ADD::Threshold
  1965. ADD
  1966. ADD::SetNZ(
  1967. const ADD& g) const
  1968. {
  1969. DdManager *mgr = checkSameManager(g);
  1970. DdNode *result = Cudd_addApply(mgr, Cudd_addSetNZ, node, g.node);
  1971. checkReturnValue(result);
  1972. return ADD(p, result);
  1973. } // ADD::SetNZ
  1974. ADD
  1975. ADD::Divide(
  1976. const ADD& g) const
  1977. {
  1978. DdManager *mgr = checkSameManager(g);
  1979. DdNode *result = Cudd_addApply(mgr, Cudd_addDivide, node, g.node);
  1980. checkReturnValue(result);
  1981. return ADD(p, result);
  1982. } // ADD::Divide
  1983. ADD
  1984. ADD::Minus(
  1985. const ADD& g) const
  1986. {
  1987. DdManager *mgr = checkSameManager(g);
  1988. DdNode *result = Cudd_addApply(mgr, Cudd_addMinus, node, g.node);
  1989. checkReturnValue(result);
  1990. return ADD(p, result);
  1991. } // ADD::Minus
  1992. ADD
  1993. ADD::Minimum(
  1994. const ADD& g) const
  1995. {
  1996. DdManager *mgr = checkSameManager(g);
  1997. DdNode *result = Cudd_addApply(mgr, Cudd_addMinimum, node, g.node);
  1998. checkReturnValue(result);
  1999. return ADD(p, result);
  2000. } // ADD::Minimum
  2001. ADD
  2002. ADD::Maximum(
  2003. const ADD& g) const
  2004. {
  2005. DdManager *mgr = checkSameManager(g);
  2006. DdNode *result = Cudd_addApply(mgr, Cudd_addMaximum, node, g.node);
  2007. checkReturnValue(result);
  2008. return ADD(p, result);
  2009. } // ADD::Maximum
  2010. ADD
  2011. ADD::OneZeroMaximum(
  2012. const ADD& g) const
  2013. {
  2014. DdManager *mgr = checkSameManager(g);
  2015. DdNode *result = Cudd_addApply(mgr, Cudd_addOneZeroMaximum, node, g.node);
  2016. checkReturnValue(result);
  2017. return ADD(p, result);
  2018. } // ADD::OneZeroMaximum
  2019. ADD
  2020. ADD::Diff(
  2021. const ADD& g) const
  2022. {
  2023. DdManager *mgr = checkSameManager(g);
  2024. DdNode *result = Cudd_addApply(mgr, Cudd_addDiff, node, g.node);
  2025. checkReturnValue(result);
  2026. return ADD(p, result);
  2027. } // ADD::Diff
  2028. ADD
  2029. ADD::Agreement(
  2030. const ADD& g) const
  2031. {
  2032. DdManager *mgr = checkSameManager(g);
  2033. DdNode *result = Cudd_addApply(mgr, Cudd_addAgreement, node, g.node);
  2034. checkReturnValue(result);
  2035. return ADD(p, result);
  2036. } // ADD::Agreement
  2037. ADD
  2038. ADD::Or(
  2039. const ADD& g) const
  2040. {
  2041. DdManager *mgr = checkSameManager(g);
  2042. DdNode *result = Cudd_addApply(mgr, Cudd_addOr, node, g.node);
  2043. checkReturnValue(result);
  2044. return ADD(p, result);
  2045. } // ADD::Or
  2046. ADD
  2047. ADD::Nand(
  2048. const ADD& g) const
  2049. {
  2050. DdManager *mgr = checkSameManager(g);
  2051. DdNode *result = Cudd_addApply(mgr, Cudd_addNand, node, g.node);
  2052. checkReturnValue(result);
  2053. return ADD(p, result);
  2054. } // ADD::Nand
  2055. ADD
  2056. ADD::Nor(
  2057. const ADD& g) const
  2058. {
  2059. DdManager *mgr = checkSameManager(g);
  2060. DdNode *result = Cudd_addApply(mgr, Cudd_addNor, node, g.node);
  2061. checkReturnValue(result);
  2062. return ADD(p, result);
  2063. } // ADD::Nor
  2064. ADD
  2065. ADD::Xor(
  2066. const ADD& g) const
  2067. {
  2068. DdManager *mgr = checkSameManager(g);
  2069. DdNode *result = Cudd_addApply(mgr, Cudd_addXor, node, g.node);
  2070. checkReturnValue(result);
  2071. return ADD(p, result);
  2072. } // ADD::Xor
  2073. ADD
  2074. ADD::Xnor(
  2075. const ADD& g) const
  2076. {
  2077. DdManager *mgr = checkSameManager(g);
  2078. DdNode *result = Cudd_addApply(mgr, Cudd_addXnor, node, g.node);
  2079. checkReturnValue(result);
  2080. return ADD(p, result);
  2081. } // ADD::Xnor
  2082. ADD
  2083. ADD::Pow(
  2084. const ADD& g) const
  2085. {
  2086. DdManager *mgr = checkSameManager(g);
  2087. DdNode *result = Cudd_addApply(mgr, Cudd_addPow, node, g.node);
  2088. checkReturnValue(result);
  2089. return ADD(p, result);
  2090. } // ADD::Pow
  2091. ADD
  2092. ADD::Mod(
  2093. const ADD& g) const
  2094. {
  2095. DdManager *mgr = checkSameManager(g);
  2096. DdNode *result = Cudd_addApply(mgr, Cudd_addMod, node, g.node);
  2097. checkReturnValue(result);
  2098. return ADD(p, result);
  2099. } // ADD::Mod
  2100. ADD
  2101. ADD::LogXY(
  2102. const ADD& g) const
  2103. {
  2104. DdManager *mgr = checkSameManager(g);
  2105. DdNode *result = Cudd_addApply(mgr, Cudd_addLogXY, node, g.node);
  2106. checkReturnValue(result);
  2107. return ADD(p, result);
  2108. } // ADD::LogXY
  2109. ADD
  2110. ADD::Log() const
  2111. {
  2112. DdManager *mgr = p->manager;
  2113. DdNode *result = Cudd_addMonadicApply(mgr, Cudd_addLog, node);
  2114. checkReturnValue(result);
  2115. return ADD(p, result);
  2116. } // ADD::Log
  2117. ADD
  2118. ADD::Floor() const
  2119. {
  2120. DdManager *mgr = p->manager;
  2121. DdNode *result = Cudd_addMonadicApply(mgr, Cudd_addFloor, node);
  2122. checkReturnValue(result);
  2123. return ADD(p, result);
  2124. } // ADD::Floor
  2125. ADD
  2126. ADD::Ceil() const
  2127. {
  2128. DdManager *mgr = p->manager;
  2129. DdNode *result = Cudd_addMonadicApply(mgr, Cudd_addCeil, node);
  2130. checkReturnValue(result);
  2131. return ADD(p, result);
  2132. } // ADD::Ceil
  2133. ADD
  2134. ADD::FindMax() const
  2135. {
  2136. DdManager *mgr = p->manager;
  2137. DdNode *result = Cudd_addFindMax(mgr, node);
  2138. checkReturnValue(result);
  2139. return ADD(p, result);
  2140. } // ADD::FindMax
  2141. ADD
  2142. ADD::FindMin() const
  2143. {
  2144. DdManager *mgr = p->manager;
  2145. DdNode *result = Cudd_addFindMin(mgr, node);
  2146. checkReturnValue(result);
  2147. return ADD(p, result);
  2148. } // ADD::FindMin
  2149. ADD
  2150. ADD::IthBit(
  2151. int bit) const
  2152. {
  2153. DdManager *mgr = p->manager;
  2154. DdNode *result = Cudd_addIthBit(mgr, node, bit);
  2155. checkReturnValue(result);
  2156. return ADD(p, result);
  2157. } // ADD::IthBit
  2158. ADD
  2159. ADD::ScalarInverse(
  2160. const ADD& epsilon) const
  2161. {
  2162. DdManager *mgr = checkSameManager(epsilon);
  2163. DdNode *result = Cudd_addScalarInverse(mgr, node, epsilon.node);
  2164. checkReturnValue(result);
  2165. return ADD(p, result);
  2166. } // ADD::ScalarInverse
  2167. ADD
  2168. ADD::Ite(
  2169. const ADD& g,
  2170. const ADD& h) const
  2171. {
  2172. DdManager *mgr = checkSameManager(g);
  2173. checkSameManager(h);
  2174. DdNode *result = Cudd_addIte(mgr, node, g.node, h.node);
  2175. checkReturnValue(result);
  2176. return ADD(p, result);
  2177. } // ADD::Ite
  2178. ADD
  2179. ADD::IteConstant(
  2180. const ADD& g,
  2181. const ADD& h) const
  2182. {
  2183. DdManager *mgr = checkSameManager(g);
  2184. checkSameManager(h);
  2185. DdNode *result = Cudd_addIteConstant(mgr, node, g.node, h.node);
  2186. checkReturnValue(result);
  2187. return ADD(p, result);
  2188. } // ADD::IteConstant
  2189. ADD
  2190. ADD::EvalConst(
  2191. const ADD& g) const
  2192. {
  2193. DdManager *mgr = checkSameManager(g);
  2194. DdNode *result = Cudd_addEvalConst(mgr, node, g.node);
  2195. checkReturnValue(result);
  2196. return ADD(p, result);
  2197. } // ADD::EvalConst
  2198. bool
  2199. ADD::Leq(
  2200. const ADD& g) const
  2201. {
  2202. DdManager *mgr = checkSameManager(g);
  2203. return Cudd_addLeq(mgr, node, g.node);
  2204. } // ADD::Leq
  2205. ADD
  2206. ADD::Cmpl() const
  2207. {
  2208. DdManager *mgr = p->manager;
  2209. DdNode *result = Cudd_addCmpl(mgr, node);
  2210. checkReturnValue(result);
  2211. return ADD(p, result);
  2212. } // ADD::Cmpl
  2213. ADD
  2214. ADD::Negate() const
  2215. {
  2216. DdManager *mgr = p->manager;
  2217. DdNode *result = Cudd_addNegate(mgr, node);
  2218. checkReturnValue(result);
  2219. return ADD(p, result);
  2220. } // ADD::Negate
  2221. ADD
  2222. ADD::RoundOff(
  2223. int N) const
  2224. {
  2225. DdManager *mgr = p->manager;
  2226. DdNode *result = Cudd_addRoundOff(mgr, node, N);
  2227. checkReturnValue(result);
  2228. return ADD(p, result);
  2229. } // ADD::RoundOff
  2230. ADD
  2231. Cudd::Walsh(
  2232. std::vector<ADD> x,
  2233. std::vector<ADD> y) const
  2234. {
  2235. size_t n = x.size();
  2236. DdNode **X = new DdNode *[n];
  2237. DdNode **Y = new DdNode *[n];
  2238. for (size_t i = 0; i < n; i++) {
  2239. X[i] = x[i].getNode();
  2240. Y[i] = y[i].getNode();
  2241. }
  2242. DdNode *result = Cudd_addWalsh(p->manager, X, Y, (int) n);
  2243. delete [] X;
  2244. delete [] Y;
  2245. checkReturnValue(result);
  2246. return ADD(p, result);
  2247. } // ADD::Walsh
  2248. ADD
  2249. Cudd::addResidue(
  2250. int n,
  2251. int m,
  2252. int options,
  2253. int top) const
  2254. {
  2255. DdNode *result = Cudd_addResidue(p->manager, n, m, options, top);
  2256. checkReturnValue(result);
  2257. return ADD(p, result);
  2258. } // Cudd::addResidue
  2259. ADD
  2260. ADD::Equals(const ADD& g) const
  2261. {
  2262. DdManager *mgr = checkSameManager(g);
  2263. DdNode *result = Cudd_addApply(mgr, Cudd_addEquals, node, g.node);
  2264. checkReturnValue(result);
  2265. return ADD(p, result);
  2266. } // ADD::Equals
  2267. ADD
  2268. ADD::NotEquals(const ADD& g) const
  2269. {
  2270. DdManager *mgr = checkSameManager(g);
  2271. DdNode *result = Cudd_addApply(mgr, Cudd_addNotEquals, node, g.node);
  2272. checkReturnValue(result);
  2273. return ADD(p, result);
  2274. } // ADD::NotEquals
  2275. ADD
  2276. ADD::LessThan(const ADD& g) const
  2277. {
  2278. DdManager *mgr = checkSameManager(g);
  2279. DdNode *result = Cudd_addApply(mgr, Cudd_addLessThan, node, g.node);
  2280. checkReturnValue(result);
  2281. return ADD(p, result);
  2282. } // ADD::LessThan
  2283. ADD
  2284. ADD::LessThanOrEqual(const ADD& g) const
  2285. {
  2286. DdManager *mgr = checkSameManager(g);
  2287. DdNode *result = Cudd_addApply(mgr, Cudd_addLessThanEquals, node, g.node);
  2288. checkReturnValue(result);
  2289. return ADD(p, result);
  2290. } // ADD::LessThanOrEqual
  2291. ADD
  2292. ADD::GreaterThan(const ADD& g) const
  2293. {
  2294. DdManager *mgr = checkSameManager(g);
  2295. DdNode *result = Cudd_addApply(mgr, Cudd_addGreaterThan, node, g.node);
  2296. checkReturnValue(result);
  2297. return ADD(p, result);
  2298. } // ADD::GreaterThan
  2299. ADD
  2300. ADD::GreaterThanOrEqual(const ADD& g) const
  2301. {
  2302. DdManager *mgr = checkSameManager(g);
  2303. DdNode *result = Cudd_addApply(mgr, Cudd_addGreaterThanEquals, node, g.node);
  2304. checkReturnValue(result);
  2305. return ADD(p, result);
  2306. } // ADD::GreaterThanOrEqual
  2307. BDD
  2308. ADD::EqualsBdd(const ADD& g) const
  2309. {
  2310. DdManager *mgr = checkSameManager(g);
  2311. DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddEquals, node, g.node);
  2312. checkReturnValue(result);
  2313. return BDD(p, result);
  2314. } // ADD::EqualsBdd
  2315. BDD
  2316. ADD::NotEqualsBdd(const ADD& g) const
  2317. {
  2318. DdManager *mgr = checkSameManager(g);
  2319. DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddNotEquals, node, g.node);
  2320. checkReturnValue(result);
  2321. return BDD(p, result);
  2322. } // ADD::NotEqualsBdd
  2323. BDD
  2324. ADD::LessThanBdd(const ADD& g) const
  2325. {
  2326. DdManager *mgr = checkSameManager(g);
  2327. DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddLessThan, node, g.node);
  2328. checkReturnValue(result);
  2329. return BDD(p, result);
  2330. } // ADD::LessThanBdd
  2331. BDD
  2332. ADD::LessThanOrEqualBdd(const ADD& g) const
  2333. {
  2334. DdManager *mgr = checkSameManager(g);
  2335. DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddLessThanEquals, node, g.node);
  2336. checkReturnValue(result);
  2337. return BDD(p, result);
  2338. } // ADD::LessThanOrEqualBdd
  2339. BDD
  2340. ADD::GreaterThanBdd(const ADD& g) const
  2341. {
  2342. DdManager *mgr = checkSameManager(g);
  2343. DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddGreaterThan, node, g.node);
  2344. checkReturnValue(result);
  2345. return BDD(p, result);
  2346. } // ADD::GreaterThanBdd
  2347. BDD
  2348. ADD::GreaterThanOrEqualBdd(const ADD& g) const
  2349. {
  2350. DdManager *mgr = checkSameManager(g);
  2351. DdNode *result = Cudd_addToBddApply(mgr, Cudd_addToBddGreaterThanEquals, node, g.node);
  2352. checkReturnValue(result);
  2353. return BDD(p, result);
  2354. } // ADD::GreaterThanOrEqualBdd
  2355. BDD
  2356. BDD::AndAbstract(
  2357. const BDD& g,
  2358. const BDD& cube,
  2359. unsigned int limit) const
  2360. {
  2361. DdManager *mgr = checkSameManager(g);
  2362. checkSameManager(cube);
  2363. DdNode *result;
  2364. if (limit == 0)
  2365. result = Cudd_bddAndAbstract(mgr, node, g.node, cube.node);
  2366. else
  2367. result = Cudd_bddAndAbstractLimit(mgr, node, g.node,
  2368. cube.node, limit);
  2369. checkReturnValue(result);
  2370. return BDD(p, result);
  2371. } // BDD::AndAbstract
  2372. int
  2373. Cudd::ApaNumberOfDigits(
  2374. int binaryDigits) const
  2375. {
  2376. return Cudd_ApaNumberOfDigits(binaryDigits);
  2377. } // Cudd::ApaNumberOfDigits
  2378. DdApaNumber
  2379. Cudd::NewApaNumber(
  2380. int digits) const
  2381. {
  2382. return Cudd_NewApaNumber(digits);
  2383. } // Cudd::NewApaNumber
  2384. void
  2385. Cudd::ApaCopy(
  2386. int digits,
  2387. DdApaNumber source,
  2388. DdApaNumber dest) const
  2389. {
  2390. Cudd_ApaCopy(digits, source, dest);
  2391. } // Cudd::ApaCopy
  2392. DdApaDigit
  2393. Cudd::ApaAdd(
  2394. int digits,
  2395. DdApaNumber a,
  2396. DdApaNumber b,
  2397. DdApaNumber sum) const
  2398. {
  2399. return Cudd_ApaAdd(digits, a, b, sum);
  2400. } // Cudd::ApaAdd
  2401. DdApaDigit
  2402. Cudd::ApaSubtract(
  2403. int digits,
  2404. DdApaNumber a,
  2405. DdApaNumber b,
  2406. DdApaNumber diff) const
  2407. {
  2408. return Cudd_ApaSubtract(digits, a, b, diff);
  2409. } // Cudd::ApaSubtract
  2410. DdApaDigit
  2411. Cudd::ApaShortDivision(
  2412. int digits,
  2413. DdApaNumber dividend,
  2414. DdApaDigit divisor,
  2415. DdApaNumber quotient) const
  2416. {
  2417. return Cudd_ApaShortDivision(digits, dividend, divisor, quotient);
  2418. } // Cudd::ApaShortDivision
  2419. void
  2420. Cudd::ApaShiftRight(
  2421. int digits,
  2422. DdApaDigit in,
  2423. DdApaNumber a,
  2424. DdApaNumber b) const
  2425. {
  2426. Cudd_ApaShiftRight(digits, in, a, b);
  2427. } // Cudd::ApaShiftRight
  2428. void
  2429. Cudd::ApaSetToLiteral(
  2430. int digits,
  2431. DdApaNumber number,
  2432. DdApaDigit literal) const
  2433. {
  2434. Cudd_ApaSetToLiteral(digits, number, literal);
  2435. } // Cudd::ApaSetToLiteral
  2436. void
  2437. Cudd::ApaPowerOfTwo(
  2438. int digits,
  2439. DdApaNumber number,
  2440. int power) const
  2441. {
  2442. Cudd_ApaPowerOfTwo(digits, number, power);
  2443. } // Cudd::ApaPowerOfTwo
  2444. void
  2445. Cudd::ApaPrintHex(
  2446. int digits,
  2447. DdApaNumber number,
  2448. FILE * fp) const
  2449. {
  2450. cout.flush();
  2451. int result = Cudd_ApaPrintHex(fp, digits, number);
  2452. checkReturnValue(result);
  2453. } // Cudd::ApaPrintHex
  2454. void
  2455. Cudd::ApaPrintDecimal(
  2456. int digits,
  2457. DdApaNumber number,
  2458. FILE * fp) const
  2459. {
  2460. cout.flush();
  2461. int result = Cudd_ApaPrintDecimal(fp, digits, number);
  2462. checkReturnValue(result);
  2463. } // Cudd::ApaPrintDecimal
  2464. std::string
  2465. Cudd::ApaStringDecimal(
  2466. int digits,
  2467. DdApaNumber number) const
  2468. {
  2469. char * result = Cudd_ApaStringDecimal(digits, number);
  2470. checkReturnValue(result);
  2471. std::string ret = std::string(result);
  2472. free(result);
  2473. return ret;
  2474. } // Cudd::ApaStringDecimal
  2475. void
  2476. Cudd::ApaPrintExponential(
  2477. int digits,
  2478. DdApaNumber number,
  2479. int precision,
  2480. FILE * fp) const
  2481. {
  2482. cout.flush();
  2483. int result = Cudd_ApaPrintExponential(fp, digits, number, precision);
  2484. checkReturnValue(result);
  2485. } // Cudd::ApaPrintExponential
  2486. DdApaNumber
  2487. ABDD::ApaCountMinterm(
  2488. int nvars,
  2489. int * digits) const
  2490. {
  2491. DdManager *mgr = p->manager;
  2492. return Cudd_ApaCountMinterm(mgr, node, nvars, digits);
  2493. } // ABDD::ApaCountMinterm
  2494. void
  2495. ABDD::ApaPrintMinterm(
  2496. int nvars,
  2497. FILE * fp) const
  2498. {
  2499. cout.flush();
  2500. DdManager *mgr = p->manager;
  2501. int result = Cudd_ApaPrintMinterm(fp, mgr, node, nvars);
  2502. checkReturnValue(result);
  2503. } // ABDD::ApaPrintMinterm
  2504. void
  2505. ABDD::ApaPrintMintermExp(
  2506. int nvars,
  2507. int precision,
  2508. FILE * fp) const
  2509. {
  2510. cout.flush();
  2511. DdManager *mgr = p->manager;
  2512. int result = Cudd_ApaPrintMintermExp(fp, mgr, node, nvars, precision);
  2513. checkReturnValue(result);
  2514. } // ABDD::ApaPrintMintermExp
  2515. void
  2516. ABDD::EpdPrintMinterm(
  2517. int nvars,
  2518. FILE * fp) const
  2519. {
  2520. EpDouble count;
  2521. char str[24];
  2522. cout.flush();
  2523. DdManager *mgr = p->manager;
  2524. int result = Cudd_EpdCountMinterm(mgr, node, nvars, &count);
  2525. checkReturnValue(result,0);
  2526. EpdGetString(&count, str);
  2527. fprintf(fp, "%s", str);
  2528. } // ABDD::EpdPrintMinterm
  2529. long double
  2530. ABDD::LdblCountMinterm(
  2531. int nvars) const
  2532. {
  2533. cout.flush();
  2534. DdManager *mgr = p->manager;
  2535. long double result = Cudd_LdblCountMinterm(mgr, node, nvars);
  2536. checkReturnValue(result != (long double) CUDD_OUT_OF_MEM);
  2537. return result;
  2538. } // ABDD::LdblCountMinterm
  2539. BDD
  2540. BDD::UnderApprox(
  2541. int numVars,
  2542. int threshold,
  2543. bool safe,
  2544. double quality) const
  2545. {
  2546. DdManager *mgr = p->manager;
  2547. DdNode *result = Cudd_UnderApprox(mgr, node, numVars, threshold, safe, quality);
  2548. checkReturnValue(result);
  2549. return BDD(p, result);
  2550. } // BDD::UnderApprox
  2551. BDD
  2552. BDD::OverApprox(
  2553. int numVars,
  2554. int threshold,
  2555. bool safe,
  2556. double quality) const
  2557. {
  2558. DdManager *mgr = p->manager;
  2559. DdNode *result = Cudd_OverApprox(mgr, node, numVars, threshold, safe, quality);
  2560. checkReturnValue(result);
  2561. return BDD(p, result);
  2562. } // BDD::OverApprox
  2563. BDD
  2564. BDD::RemapUnderApprox(
  2565. int numVars,
  2566. int threshold,
  2567. double quality) const
  2568. {
  2569. DdManager *mgr = p->manager;
  2570. DdNode *result = Cudd_RemapUnderApprox(mgr, node, numVars, threshold, quality);
  2571. checkReturnValue(result);
  2572. return BDD(p, result);
  2573. } // BDD::RemapUnderApprox
  2574. BDD
  2575. BDD::RemapOverApprox(
  2576. int numVars,
  2577. int threshold,
  2578. double quality) const
  2579. {
  2580. DdManager *mgr = p->manager;
  2581. DdNode *result = Cudd_RemapOverApprox(mgr, node, numVars, threshold, quality);
  2582. checkReturnValue(result);
  2583. return BDD(p, result);
  2584. } // BDD::RemapOverApprox
  2585. BDD
  2586. BDD::BiasedUnderApprox(
  2587. const BDD& bias,
  2588. int numVars,
  2589. int threshold,
  2590. double quality1,
  2591. double quality0) const
  2592. {
  2593. DdManager *mgr = p->manager;
  2594. DdNode *result = Cudd_BiasedUnderApprox(mgr, node, bias.node, numVars,
  2595. threshold, quality1, quality0);
  2596. checkReturnValue(result);
  2597. return BDD(p, result);
  2598. } // BDD::BiasedUnderApprox
  2599. BDD
  2600. BDD::BiasedOverApprox(
  2601. const BDD& bias,
  2602. int numVars,
  2603. int threshold,
  2604. double quality1,
  2605. double quality0) const
  2606. {
  2607. DdManager *mgr = p->manager;
  2608. DdNode *result = Cudd_BiasedOverApprox(mgr, node, bias.node, numVars,
  2609. threshold, quality1, quality0);
  2610. checkReturnValue(result);
  2611. return BDD(p, result);
  2612. } // BDD::BiasedOverApprox
  2613. BDD
  2614. BDD::ExistAbstract(
  2615. const BDD& cube,
  2616. unsigned int limit) const
  2617. {
  2618. DdManager *mgr = checkSameManager(cube);
  2619. DdNode *result;
  2620. if (limit == 0)
  2621. result = Cudd_bddExistAbstract(mgr, node, cube.node);
  2622. else
  2623. result = Cudd_bddExistAbstractLimit(mgr, node, cube.node, limit);
  2624. checkReturnValue(result);
  2625. return BDD(p, result);
  2626. } // BDD::ExistAbstract
  2627. BDD
  2628. BDD::ExistAbstractRepresentative(const BDD& cube) const {
  2629. DdManager *mgr = checkSameManager(cube);
  2630. DdNode *result;
  2631. result = Cudd_bddExistAbstractRepresentative(mgr, node, cube.node);
  2632. checkReturnValue(result);
  2633. return BDD(p, result);
  2634. } // BDD::ExistAbstractRepresentative
  2635. BDD
  2636. BDD::XorExistAbstract(
  2637. const BDD& g,
  2638. const BDD& cube) const
  2639. {
  2640. DdManager *mgr = checkSameManager(g);
  2641. checkSameManager(cube);
  2642. DdNode *result = Cudd_bddXorExistAbstract(mgr, node, g.node, cube.node);
  2643. checkReturnValue(result);
  2644. return BDD(p, result);
  2645. } // BDD::XorExistAbstract
  2646. BDD
  2647. BDD::UnivAbstract(
  2648. const BDD& cube) const
  2649. {
  2650. DdManager *mgr = checkSameManager(cube);
  2651. DdNode *result = Cudd_bddUnivAbstract(mgr, node, cube.node);
  2652. checkReturnValue(result);
  2653. return BDD(p, result);
  2654. } // BDD::UnivAbstract
  2655. BDD
  2656. BDD::BooleanDiff(
  2657. int x) const
  2658. {
  2659. DdManager *mgr = p->manager;
  2660. DdNode *result = Cudd_bddBooleanDiff(mgr, node, x);
  2661. checkReturnValue(result);
  2662. return BDD(p, result);
  2663. } // BDD::BooleanDiff
  2664. bool
  2665. BDD::VarIsDependent(
  2666. const BDD& var) const
  2667. {
  2668. DdManager *mgr = p->manager;
  2669. return Cudd_bddVarIsDependent(mgr, node, var.node);
  2670. } // BDD::VarIsDependent
  2671. double
  2672. BDD::Correlation(
  2673. const BDD& g) const
  2674. {
  2675. DdManager *mgr = checkSameManager(g);
  2676. return Cudd_bddCorrelation(mgr, node, g.node);
  2677. } // BDD::Correlation
  2678. double
  2679. BDD::CorrelationWeights(
  2680. const BDD& g,
  2681. double * prob) const
  2682. {
  2683. DdManager *mgr = checkSameManager(g);
  2684. return Cudd_bddCorrelationWeights(mgr, node, g.node, prob);
  2685. } // BDD::CorrelationWeights
  2686. BDD
  2687. BDD::Ite(
  2688. const BDD& g,
  2689. const BDD& h,
  2690. unsigned int limit) const
  2691. {
  2692. DdManager *mgr = checkSameManager(g);
  2693. checkSameManager(h);
  2694. DdNode *result;
  2695. if (limit == 0)
  2696. result = Cudd_bddIte(mgr, node, g.node, h.node);
  2697. else
  2698. result = Cudd_bddIteLimit(mgr, node, g.node, h.node, limit);
  2699. checkReturnValue(result);
  2700. return BDD(p, result);
  2701. } // BDD::Ite
  2702. BDD
  2703. BDD::IteConstant(
  2704. const BDD& g,
  2705. const BDD& h) const
  2706. {
  2707. DdManager *mgr = checkSameManager(g);
  2708. checkSameManager(h);
  2709. DdNode *result = Cudd_bddIteConstant(mgr, node, g.node, h.node);
  2710. checkReturnValue(result);
  2711. return BDD(p, result);
  2712. } // BDD::IteConstant
  2713. BDD
  2714. BDD::Intersect(
  2715. const BDD& g) const
  2716. {
  2717. DdManager *mgr = checkSameManager(g);
  2718. DdNode *result = Cudd_bddIntersect(mgr, node, g.node);
  2719. checkReturnValue(result);
  2720. return BDD(p, result);
  2721. } // BDD::Intersect
  2722. BDD
  2723. BDD::And(
  2724. const BDD& g,
  2725. unsigned int limit) const
  2726. {
  2727. DdManager *mgr = checkSameManager(g);
  2728. DdNode *result;
  2729. if (limit == 0)
  2730. result = Cudd_bddAnd(mgr, node, g.node);
  2731. else
  2732. result = Cudd_bddAndLimit(mgr, node, g.node, limit);
  2733. checkReturnValue(result);
  2734. return BDD(p, result);
  2735. } // BDD::And
  2736. BDD
  2737. BDD::Or(
  2738. const BDD& g,
  2739. unsigned int limit) const
  2740. {
  2741. DdManager *mgr = checkSameManager(g);
  2742. DdNode *result;
  2743. if (limit == 0)
  2744. result = Cudd_bddOr(mgr, node, g.node);
  2745. else
  2746. result = Cudd_bddOrLimit(mgr, node, g.node, limit);
  2747. checkReturnValue(result);
  2748. return BDD(p, result);
  2749. } // BDD::Or
  2750. BDD
  2751. BDD::Nand(
  2752. const BDD& g) const
  2753. {
  2754. DdManager *mgr = checkSameManager(g);
  2755. DdNode *result = Cudd_bddNand(mgr, node, g.node);
  2756. checkReturnValue(result);
  2757. return BDD(p, result);
  2758. } // BDD::Nand
  2759. BDD
  2760. BDD::Nor(
  2761. const BDD& g) const
  2762. {
  2763. DdManager *mgr = checkSameManager(g);
  2764. DdNode *result = Cudd_bddNor(mgr, node, g.node);
  2765. checkReturnValue(result);
  2766. return BDD(p, result);
  2767. } // BDD::Nor
  2768. BDD
  2769. BDD::Xor(
  2770. const BDD& g) const
  2771. {
  2772. DdManager *mgr = checkSameManager(g);
  2773. DdNode *result = Cudd_bddXor(mgr, node, g.node);
  2774. checkReturnValue(result);
  2775. return BDD(p, result);
  2776. } // BDD::Xor
  2777. BDD
  2778. BDD::Xnor(
  2779. const BDD& g,
  2780. unsigned int limit) const
  2781. {
  2782. DdManager *mgr = checkSameManager(g);
  2783. DdNode *result;
  2784. if (limit == 0)
  2785. result = Cudd_bddXnor(mgr, node, g.node);
  2786. else
  2787. result = Cudd_bddXnorLimit(mgr, node, g.node, limit);
  2788. checkReturnValue(result);
  2789. return BDD(p, result);
  2790. } // BDD::Xnor
  2791. bool
  2792. BDD::Leq(
  2793. const BDD& g) const
  2794. {
  2795. DdManager *mgr = checkSameManager(g);
  2796. return Cudd_bddLeq(mgr, node, g.node);
  2797. } // BDD::Leq
  2798. BDD
  2799. ADD::BddThreshold(
  2800. CUDD_VALUE_TYPE value) const
  2801. {
  2802. DdManager *mgr = p->manager;
  2803. DdNode *result = Cudd_addBddThreshold(mgr, node, value);
  2804. checkReturnValue(result);
  2805. return BDD(p, result);
  2806. } // ADD::BddThreshold
  2807. BDD
  2808. ADD::BddStrictThreshold(
  2809. CUDD_VALUE_TYPE value) const
  2810. {
  2811. DdManager *mgr = p->manager;
  2812. DdNode *result = Cudd_addBddStrictThreshold(mgr, node, value);
  2813. checkReturnValue(result);
  2814. return BDD(p, result);
  2815. } // ADD::BddStrictThreshold
  2816. BDD
  2817. ADD::BddInterval(
  2818. CUDD_VALUE_TYPE lower,
  2819. CUDD_VALUE_TYPE upper) const
  2820. {
  2821. DdManager *mgr = p->manager;
  2822. DdNode *result = Cudd_addBddInterval(mgr, node, lower, upper);
  2823. checkReturnValue(result);
  2824. return BDD(p, result);
  2825. } // ADD::BddInterval
  2826. BDD
  2827. ADD::BddIthBit(
  2828. int bit) const
  2829. {
  2830. DdManager *mgr = p->manager;
  2831. DdNode *result = Cudd_addBddIthBit(mgr, node, bit);
  2832. checkReturnValue(result);
  2833. return BDD(p, result);
  2834. } // ADD::BddIthBit
  2835. ADD
  2836. BDD::Add() const
  2837. {
  2838. DdManager *mgr = p->manager;
  2839. DdNode *result = Cudd_BddToAdd(mgr, node);
  2840. checkReturnValue(result);
  2841. return ADD(p, result);
  2842. } // BDD::Add
  2843. BDD
  2844. ADD::BddPattern() const
  2845. {
  2846. DdManager *mgr = p->manager;
  2847. DdNode *result = Cudd_addBddPattern(mgr, node);
  2848. checkReturnValue(result);
  2849. return BDD(p, result);
  2850. } // ADD::BddPattern
  2851. BDD
  2852. BDD::Transfer(
  2853. Cudd& destination) const
  2854. {
  2855. DdManager *mgr = p->manager;
  2856. DdNode *result = Cudd_bddTransfer(mgr, destination.p->manager, node);
  2857. checkReturnValue(result);
  2858. return BDD(destination.p, result);
  2859. } // BDD::Transfer
  2860. void
  2861. Cudd::DebugCheck() const
  2862. {
  2863. int result = Cudd_DebugCheck(p->manager);
  2864. checkReturnValue(result == 0);
  2865. } // Cudd::DebugCheck
  2866. void
  2867. Cudd::CheckKeys() const
  2868. {
  2869. int result = Cudd_CheckKeys(p->manager);
  2870. checkReturnValue(result == 0);
  2871. } // Cudd::CheckKeys
  2872. BDD
  2873. BDD::ClippingAnd(
  2874. const BDD& g,
  2875. int maxDepth,
  2876. int direction) const
  2877. {
  2878. DdManager *mgr = checkSameManager(g);
  2879. DdNode *result = Cudd_bddClippingAnd(mgr, node, g.node, maxDepth,
  2880. direction);
  2881. checkReturnValue(result);
  2882. return BDD(p, result);
  2883. } // BDD::ClippingAnd
  2884. BDD
  2885. BDD::ClippingAndAbstract(
  2886. const BDD& g,
  2887. const BDD& cube,
  2888. int maxDepth,
  2889. int direction) const
  2890. {
  2891. DdManager *mgr = checkSameManager(g);
  2892. checkSameManager(cube);
  2893. DdNode *result = Cudd_bddClippingAndAbstract(mgr, node, g.node, cube.node,
  2894. maxDepth, direction);
  2895. checkReturnValue(result);
  2896. return BDD(p, result);
  2897. } // BDD::ClippingAndAbstract
  2898. ADD
  2899. ADD::Cofactor(
  2900. const ADD& g) const
  2901. {
  2902. DdManager *mgr = checkSameManager(g);
  2903. DdNode *result = Cudd_Cofactor(mgr, node, g.node);
  2904. checkReturnValue(result);
  2905. return ADD(p, result);
  2906. } // ADD::Cofactor
  2907. BDD
  2908. BDD::Cofactor(
  2909. const BDD& g) const
  2910. {
  2911. DdManager *mgr = checkSameManager(g);
  2912. DdNode *result = Cudd_Cofactor(mgr, node, g.node);
  2913. checkReturnValue(result);
  2914. return BDD(p, result);
  2915. } // BDD::Cofactor
  2916. bool
  2917. BDD::VarAreSymmetric(int index1, int index2) const
  2918. {
  2919. return Cudd_VarsAreSymmetric(p->manager, node, index1, index2);
  2920. } // BDD::VarAreSymmetric
  2921. BDD
  2922. BDD::Compose(
  2923. const BDD& g,
  2924. int v) const
  2925. {
  2926. DdManager *mgr = checkSameManager(g);
  2927. DdNode *result = Cudd_bddCompose(mgr, node, g.node, v);
  2928. checkReturnValue(result);
  2929. return BDD(p, result);
  2930. } // BDD::Compose
  2931. ADD
  2932. ADD::Compose(
  2933. const ADD& g,
  2934. int v) const
  2935. {
  2936. DdManager *mgr = checkSameManager(g);
  2937. DdNode *result = Cudd_addCompose(mgr, node, g.node, v);
  2938. checkReturnValue(result);
  2939. return ADD(p, result);
  2940. } // ADD::Compose
  2941. ADD
  2942. ADD::Permute(
  2943. int * permut) const
  2944. {
  2945. DdManager *mgr = p->manager;
  2946. DdNode *result = Cudd_addPermute(mgr, node, permut);
  2947. checkReturnValue(result);
  2948. return ADD(p, result);
  2949. } // ADD::Permute
  2950. ADD
  2951. ADD::SwapVariables(
  2952. std::vector<ADD> x,
  2953. std::vector<ADD> y) const
  2954. {
  2955. size_t n = x.size();
  2956. DdManager *mgr = p->manager;
  2957. DdNode **X = new DdNode *[n];
  2958. DdNode **Y = new DdNode *[n];
  2959. for (size_t i = 0; i < n; i++) {
  2960. X[i] = x[i].node;
  2961. Y[i] = y[i].node;
  2962. }
  2963. DdNode *result = Cudd_addSwapVariables(mgr, node, X, Y, (int) n);
  2964. delete [] X;
  2965. delete [] Y;
  2966. checkReturnValue(result);
  2967. return ADD(p, result);
  2968. } // ADD::SwapVariables
  2969. BDD
  2970. BDD::Permute(
  2971. int * permut) const
  2972. {
  2973. DdManager *mgr = p->manager;
  2974. DdNode *result = Cudd_bddPermute(mgr, node, permut);
  2975. checkReturnValue(result);
  2976. return BDD(p, result);
  2977. } // BDD::Permute
  2978. BDD
  2979. BDD::SwapVariables(
  2980. std::vector<BDD> x,
  2981. std::vector<BDD> y) const
  2982. {
  2983. size_t n = x.size();
  2984. DdManager *mgr = p->manager;
  2985. DdNode **X = new DdNode *[n];
  2986. DdNode **Y = new DdNode *[n];
  2987. for (size_t i = 0; i < n; i++) {
  2988. X[i] = x[i].node;
  2989. Y[i] = y[i].node;
  2990. }
  2991. DdNode *result = Cudd_bddSwapVariables(mgr, node, X, Y, (int) n);
  2992. delete [] X;
  2993. delete [] Y;
  2994. checkReturnValue(result);
  2995. return BDD(p, result);
  2996. } // BDD::SwapVariables
  2997. BDD
  2998. BDD::AdjPermuteX(
  2999. std::vector<BDD> x) const
  3000. {
  3001. size_t n = x.size();
  3002. DdManager *mgr = p->manager;
  3003. DdNode **X = new DdNode *[n];
  3004. for (size_t i = 0; i < n; i++) {
  3005. X[i] = x[i].node;
  3006. }
  3007. DdNode *result = Cudd_bddAdjPermuteX(mgr, node, X, (int) n);
  3008. delete [] X;
  3009. checkReturnValue(result);
  3010. return BDD(p, result);
  3011. } // BDD::AdjPermuteX
  3012. ADD
  3013. ADD::VectorCompose(
  3014. std::vector<ADD> vect) const
  3015. {
  3016. DdManager *mgr = p->manager;
  3017. size_t n = (size_t) Cudd_ReadSize(mgr);
  3018. DdNode **X = new DdNode *[n];
  3019. for (size_t i = 0; i < n; i++) {
  3020. X[i] = vect[i].node;
  3021. }
  3022. DdNode *result = Cudd_addVectorCompose(mgr, node, X);
  3023. delete [] X;
  3024. checkReturnValue(result);
  3025. return ADD(p, result);
  3026. } // ADD::VectorCompose
  3027. ADD
  3028. ADD::NonSimCompose(
  3029. std::vector<ADD> vect) const
  3030. {
  3031. DdManager *mgr = p->manager;
  3032. size_t n = (size_t) Cudd_ReadSize(mgr);
  3033. DdNode **X = new DdNode *[n];
  3034. for (size_t i = 0; i < n; i++) {
  3035. X[i] = vect[i].node;
  3036. }
  3037. DdNode *result = Cudd_addNonSimCompose(mgr, node, X);
  3038. delete [] X;
  3039. checkReturnValue(result);
  3040. return ADD(p, result);
  3041. } // ADD::NonSimCompose
  3042. BDD
  3043. BDD::VectorCompose(
  3044. std::vector<BDD> vect) const
  3045. {
  3046. DdManager *mgr = p->manager;
  3047. size_t n = (size_t) Cudd_ReadSize(mgr);
  3048. DdNode **X = new DdNode *[n];
  3049. for (size_t i = 0; i < n; i++) {
  3050. X[i] = vect[i].node;
  3051. }
  3052. DdNode *result = Cudd_bddVectorCompose(mgr, node, X);
  3053. delete [] X;
  3054. checkReturnValue(result);
  3055. return BDD(p, result);
  3056. } // BDD::VectorCompose
  3057. void
  3058. BDD::ApproxConjDecomp(
  3059. BDD* g,
  3060. BDD* h) const
  3061. {
  3062. DdManager *mgr = p->manager;
  3063. DdNode **pieces;
  3064. int result = Cudd_bddApproxConjDecomp(mgr, node, &pieces);
  3065. checkReturnValue(result == 2);
  3066. *g = BDD(p, pieces[0]);
  3067. *h = BDD(p, pieces[1]);
  3068. Cudd_RecursiveDeref(mgr,pieces[0]);
  3069. Cudd_RecursiveDeref(mgr,pieces[1]);
  3070. free(pieces);
  3071. } // BDD::ApproxConjDecomp
  3072. void
  3073. BDD::ApproxDisjDecomp(
  3074. BDD* g,
  3075. BDD* h) const
  3076. {
  3077. DdManager *mgr = p->manager;
  3078. DdNode **pieces;
  3079. int result = Cudd_bddApproxDisjDecomp(mgr, node, &pieces);
  3080. checkReturnValue(result == 2);
  3081. *g = BDD(p, pieces[0]);
  3082. *h = BDD(p, pieces[1]);
  3083. Cudd_RecursiveDeref(mgr,pieces[0]);
  3084. Cudd_RecursiveDeref(mgr,pieces[1]);
  3085. free(pieces);
  3086. } // BDD::ApproxDisjDecomp
  3087. void
  3088. BDD::IterConjDecomp(
  3089. BDD* g,
  3090. BDD* h) const
  3091. {
  3092. DdManager *mgr = p->manager;
  3093. DdNode **pieces;
  3094. int result = Cudd_bddIterConjDecomp(mgr, node, &pieces);
  3095. checkReturnValue(result == 2);
  3096. *g = BDD(p, pieces[0]);
  3097. *h = BDD(p, pieces[1]);
  3098. Cudd_RecursiveDeref(mgr,pieces[0]);
  3099. Cudd_RecursiveDeref(mgr,pieces[1]);
  3100. free(pieces);
  3101. } // BDD::IterConjDecomp
  3102. void
  3103. BDD::IterDisjDecomp(
  3104. BDD* g,
  3105. BDD* h) const
  3106. {
  3107. DdManager *mgr = p->manager;
  3108. DdNode **pieces;
  3109. int result = Cudd_bddIterDisjDecomp(mgr, node, &pieces);
  3110. checkReturnValue(result == 2);
  3111. *g = BDD(p, pieces[0]);
  3112. *h = BDD(p, pieces[1]);
  3113. Cudd_RecursiveDeref(mgr,pieces[0]);
  3114. Cudd_RecursiveDeref(mgr,pieces[1]);
  3115. free(pieces);
  3116. } // BDD::IterDisjDecomp
  3117. void
  3118. BDD::GenConjDecomp(
  3119. BDD* g,
  3120. BDD* h) const
  3121. {
  3122. DdManager *mgr = p->manager;
  3123. DdNode **pieces;
  3124. int result = Cudd_bddGenConjDecomp(mgr, node, &pieces);
  3125. checkReturnValue(result == 2);
  3126. *g = BDD(p, pieces[0]);
  3127. *h = BDD(p, pieces[1]);
  3128. Cudd_RecursiveDeref(mgr,pieces[0]);
  3129. Cudd_RecursiveDeref(mgr,pieces[1]);
  3130. free(pieces);
  3131. } // BDD::GenConjDecomp
  3132. void
  3133. BDD::GenDisjDecomp(
  3134. BDD* g,
  3135. BDD* h) const
  3136. {
  3137. DdManager *mgr = p->manager;
  3138. DdNode **pieces;
  3139. int result = Cudd_bddGenDisjDecomp(mgr, node, &pieces);
  3140. checkReturnValue(result == 2);
  3141. *g = BDD(p, pieces[0]);
  3142. *h = BDD(p, pieces[1]);
  3143. Cudd_RecursiveDeref(mgr,pieces[0]);
  3144. Cudd_RecursiveDeref(mgr,pieces[1]);
  3145. free(pieces);
  3146. } // BDD::GenDisjDecomp
  3147. void
  3148. BDD::VarConjDecomp(
  3149. BDD* g,
  3150. BDD* h) const
  3151. {
  3152. DdManager *mgr = p->manager;
  3153. DdNode **pieces;
  3154. int result = Cudd_bddVarConjDecomp(mgr, node, &pieces);
  3155. checkReturnValue(result == 2);
  3156. *g = BDD(p, pieces[0]);
  3157. *h = BDD(p, pieces[1]);
  3158. Cudd_RecursiveDeref(mgr,pieces[0]);
  3159. Cudd_RecursiveDeref(mgr,pieces[1]);
  3160. free(pieces);
  3161. } // BDD::VarConjDecomp
  3162. void
  3163. BDD::VarDisjDecomp(
  3164. BDD* g,
  3165. BDD* h) const
  3166. {
  3167. DdManager *mgr = p->manager;
  3168. DdNode **pieces;
  3169. int result = Cudd_bddVarDisjDecomp(mgr, node, &pieces);
  3170. checkReturnValue(result == 2);
  3171. *g = BDD(p, pieces[0]);
  3172. *h = BDD(p, pieces[1]);
  3173. Cudd_RecursiveDeref(mgr,pieces[0]);
  3174. Cudd_RecursiveDeref(mgr,pieces[1]);
  3175. free(pieces);
  3176. } // BDD::VarDisjDecomp
  3177. bool
  3178. ABDD::IsCube() const
  3179. {
  3180. DdManager *mgr = p->manager;
  3181. return Cudd_CheckCube(mgr, node);
  3182. } // ABDD::IsCube
  3183. BDD
  3184. ABDD::FindEssential() const
  3185. {
  3186. DdManager *mgr = p->manager;
  3187. DdNode *result = Cudd_FindEssential(mgr, node);
  3188. checkReturnValue(result);
  3189. return BDD(p, result);
  3190. } // ABDD::FindEssential
  3191. bool
  3192. BDD::IsVarEssential(
  3193. int id,
  3194. int phase) const
  3195. {
  3196. DdManager *mgr = p->manager;
  3197. return Cudd_bddIsVarEssential(mgr, node, id, phase);
  3198. } // BDD::IsVarEssential
  3199. void
  3200. ABDD::PrintTwoLiteralClauses(
  3201. char **names,
  3202. FILE *fp) const
  3203. {
  3204. DdManager *mgr = p->manager;
  3205. int result = Cudd_PrintTwoLiteralClauses(mgr, node, names, fp);
  3206. checkReturnValue(result);
  3207. } // ABDD::PrintTwoLiteralClauses
  3208. void
  3209. Cudd::DumpBlif(
  3210. const std::vector<BDD>& nodes,
  3211. char const * const * inames,
  3212. char const * const * onames,
  3213. char * mname,
  3214. FILE * fp,
  3215. int mv) const
  3216. {
  3217. DdManager *mgr = p->manager;
  3218. size_t n = nodes.size();
  3219. DdNode **F = new DdNode *[n];
  3220. for (size_t i = 0; i < n; i ++) {
  3221. F[i] = nodes[i].getNode();
  3222. }
  3223. int result = Cudd_DumpBlif(mgr, (int) n, F, inames, onames, mname, fp, mv);
  3224. delete [] F;
  3225. checkReturnValue(result);
  3226. } // Cudd::DumpBlif
  3227. void
  3228. Cudd::DumpDot(
  3229. const std::vector<BDD>& nodes,
  3230. char const * const * inames,
  3231. char const * const * onames,
  3232. FILE * fp) const
  3233. {
  3234. DdManager *mgr = p->manager;
  3235. size_t n = nodes.size();
  3236. DdNode **F = new DdNode *[n];
  3237. for (size_t i = 0; i < n; i ++) {
  3238. F[i] = nodes[i].getNode();
  3239. }
  3240. int result = Cudd_DumpDot(mgr, (int) n, F, inames, onames, fp);
  3241. delete [] F;
  3242. checkReturnValue(result);
  3243. } // Cudd::DumpDot
  3244. void
  3245. Cudd::DumpDot(
  3246. const std::vector<ADD>& nodes,
  3247. char const * const * inames,
  3248. char const * const * onames,
  3249. FILE * fp) const
  3250. {
  3251. DdManager *mgr = p->manager;
  3252. size_t n = nodes.size();
  3253. DdNode **F = new DdNode *[n];
  3254. for (size_t i = 0; i < n; i ++) {
  3255. F[i] = nodes[i].getNode();
  3256. }
  3257. int result = Cudd_DumpDot(mgr, (int) n, F, inames, onames, fp);
  3258. delete [] F;
  3259. checkReturnValue(result);
  3260. } // Cudd::DumpDot
  3261. void
  3262. Cudd::DumpDaVinci(
  3263. const std::vector<BDD>& nodes,
  3264. char const * const * inames,
  3265. char const * const * onames,
  3266. FILE * fp) const
  3267. {
  3268. DdManager *mgr = p->manager;
  3269. size_t n = nodes.size();
  3270. DdNode **F = new DdNode *[n];
  3271. for (size_t i = 0; i < n; i ++) {
  3272. F[i] = nodes[i].getNode();
  3273. }
  3274. int result = Cudd_DumpDaVinci(mgr, (int) n, F, inames, onames, fp);
  3275. delete [] F;
  3276. checkReturnValue(result);
  3277. } // Cudd::DumpDaVinci
  3278. void
  3279. Cudd::DumpDaVinci(
  3280. const std::vector<ADD>& nodes,
  3281. char const * const * inames,
  3282. char const * const * onames,
  3283. FILE * fp) const
  3284. {
  3285. DdManager *mgr = p->manager;
  3286. size_t n = nodes.size();
  3287. DdNode **F = new DdNode *[n];
  3288. for (size_t i = 0; i < n; i ++) {
  3289. F[i] = nodes[i].getNode();
  3290. }
  3291. int result = Cudd_DumpDaVinci(mgr, (int) n, F, inames, onames, fp);
  3292. delete [] F;
  3293. checkReturnValue(result);
  3294. } // Cudd::DumpDaVinci
  3295. void
  3296. Cudd::DumpDDcal(
  3297. const std::vector<BDD>& nodes,
  3298. char const * const * inames,
  3299. char const * const * onames,
  3300. FILE * fp) const
  3301. {
  3302. DdManager *mgr = p->manager;
  3303. size_t n = nodes.size();
  3304. DdNode **F = new DdNode *[n];
  3305. for (size_t i = 0; i < n; i ++) {
  3306. F[i] = nodes[i].getNode();
  3307. }
  3308. int result = Cudd_DumpDDcal(mgr, (int) n, F, inames, onames, fp);
  3309. delete [] F;
  3310. checkReturnValue(result);
  3311. } // Cudd::DumpDDcal
  3312. void
  3313. Cudd::DumpFactoredForm(
  3314. const std::vector<BDD>& nodes,
  3315. char const * const * inames,
  3316. char const * const * onames,
  3317. FILE * fp) const
  3318. {
  3319. DdManager *mgr = p->manager;
  3320. size_t n = nodes.size();
  3321. DdNode **F = new DdNode *[n];
  3322. for (size_t i = 0; i < n; i ++) {
  3323. F[i] = nodes[i].getNode();
  3324. }
  3325. int result = Cudd_DumpFactoredForm(mgr, (int) n, F, inames, onames, fp);
  3326. delete [] F;
  3327. checkReturnValue(result);
  3328. } // Cudd::DumpFactoredForm
  3329. void
  3330. BDD::PrintFactoredForm(
  3331. char const * const * inames,
  3332. FILE * fp) const
  3333. {
  3334. DdManager *mgr = p->manager;
  3335. DdNode *f = node;
  3336. int result = Cudd_DumpFactoredForm(mgr, 0, &f, inames, 0, fp);
  3337. checkReturnValue(result);
  3338. } // BDD::PrintFactoredForm
  3339. string
  3340. BDD::FactoredFormString(char const * const * inames) const
  3341. {
  3342. DdManager *mgr = p->manager;
  3343. DdNode *f = node;
  3344. char *cstr = Cudd_FactoredFormString(mgr, f, inames);
  3345. checkReturnValue(cstr);
  3346. string str(cstr);
  3347. free(cstr);
  3348. return str;
  3349. } // BDD::FactoredFormString
  3350. BDD
  3351. BDD::Constrain(
  3352. const BDD& c) const
  3353. {
  3354. DdManager *mgr = checkSameManager(c);
  3355. DdNode *result = Cudd_bddConstrain(mgr, node, c.node);
  3356. checkReturnValue(result);
  3357. return BDD(p, result);
  3358. } // BDD::Constrain
  3359. BDD
  3360. BDD::Restrict(
  3361. const BDD& c) const
  3362. {
  3363. DdManager *mgr = checkSameManager(c);
  3364. DdNode *result = Cudd_bddRestrict(mgr, node, c.node);
  3365. checkReturnValue(result);
  3366. return BDD(p, result);
  3367. } // BDD::Restrict
  3368. BDD
  3369. BDD::NPAnd(
  3370. const BDD& g) const
  3371. {
  3372. DdManager *mgr = checkSameManager(g);
  3373. DdNode *result = Cudd_bddNPAnd(mgr, node, g.node);
  3374. checkReturnValue(result);
  3375. return BDD(p, result);
  3376. } // BDD::NPAnd
  3377. ADD
  3378. ADD::Constrain(
  3379. const ADD& c) const
  3380. {
  3381. DdManager *mgr = checkSameManager(c);
  3382. DdNode *result = Cudd_addConstrain(mgr, node, c.node);
  3383. checkReturnValue(result);
  3384. return ADD(p, result);
  3385. } // ADD::Constrain
  3386. std::vector<BDD>
  3387. BDD::ConstrainDecomp() const
  3388. {
  3389. DdManager *mgr = p->manager;
  3390. DdNode **result = Cudd_bddConstrainDecomp(mgr, node);
  3391. checkReturnValue(result);
  3392. int size = Cudd_ReadSize(mgr);
  3393. vector<BDD> vect;
  3394. for (int i = 0; i < size; i++) {
  3395. Cudd_Deref(result[i]);
  3396. vect.push_back(BDD(p, result[i]));
  3397. }
  3398. free(result);
  3399. return vect;
  3400. } // BDD::ConstrainDecomp
  3401. ADD
  3402. ADD::Restrict(
  3403. const ADD& c) const
  3404. {
  3405. DdManager *mgr = checkSameManager(c);
  3406. DdNode *result = Cudd_addRestrict(mgr, node, c.node);
  3407. checkReturnValue(result);
  3408. return ADD(p, result);
  3409. } // ADD::Restrict
  3410. std::vector<BDD>
  3411. BDD::CharToVect() const
  3412. {
  3413. DdManager *mgr = p->manager;
  3414. DdNode **result = Cudd_bddCharToVect(mgr, node);
  3415. checkReturnValue(result);
  3416. int size = Cudd_ReadSize(mgr);
  3417. vector<BDD> vect;
  3418. for (int i = 0; i < size; i++) {
  3419. Cudd_Deref(result[i]);
  3420. vect.push_back(BDD(p, result[i]));
  3421. }
  3422. free(result);
  3423. return vect;
  3424. } // BDD::CharToVect
  3425. BDD
  3426. BDD::LICompaction(
  3427. const BDD& c) const
  3428. {
  3429. DdManager *mgr = checkSameManager(c);
  3430. DdNode *result = Cudd_bddLICompaction(mgr, node, c.node);
  3431. checkReturnValue(result);
  3432. return BDD(p, result);
  3433. } // BDD::LICompaction
  3434. BDD
  3435. BDD::Squeeze(
  3436. const BDD& u) const
  3437. {
  3438. DdManager *mgr = checkSameManager(u);
  3439. DdNode *result = Cudd_bddSqueeze(mgr, node, u.node);
  3440. checkReturnValue(result);
  3441. return BDD(p, result);
  3442. } // BDD::Squeeze
  3443. BDD
  3444. BDD::Interpolate(
  3445. const BDD& u) const
  3446. {
  3447. DdManager *mgr = checkSameManager(u);
  3448. DdNode *result = Cudd_bddInterpolate(mgr, node, u.node);
  3449. checkReturnValue(result);
  3450. return BDD(p, result);
  3451. } // BDD::Interpolate
  3452. BDD
  3453. BDD::Minimize(
  3454. const BDD& c) const
  3455. {
  3456. DdManager *mgr = checkSameManager(c);
  3457. DdNode *result = Cudd_bddMinimize(mgr, node, c.node);
  3458. checkReturnValue(result);
  3459. return BDD(p, result);
  3460. } // BDD::Minimize
  3461. BDD
  3462. BDD::SubsetCompress(
  3463. int nvars,
  3464. int threshold) const
  3465. {
  3466. DdManager *mgr = p->manager;
  3467. DdNode *result = Cudd_SubsetCompress(mgr, node, nvars, threshold);
  3468. checkReturnValue(result);
  3469. return BDD(p, result);
  3470. } // BDD::SubsetCompress
  3471. BDD
  3472. BDD::SupersetCompress(
  3473. int nvars,
  3474. int threshold) const
  3475. {
  3476. DdManager *mgr = p->manager;
  3477. DdNode *result = Cudd_SupersetCompress(mgr, node, nvars, threshold);
  3478. checkReturnValue(result);
  3479. return BDD(p, result);
  3480. } // BDD::SupersetCompress
  3481. MtrNode *
  3482. Cudd::MakeTreeNode(
  3483. unsigned int low,
  3484. unsigned int size,
  3485. unsigned int type) const
  3486. {
  3487. return Cudd_MakeTreeNode(p->manager, low, size, type);
  3488. } // Cudd::MakeTreeNode
  3489. ADD
  3490. Cudd::Harwell(
  3491. FILE * fp,
  3492. std::vector<ADD>& x,
  3493. std::vector<ADD>& y,
  3494. std::vector<ADD>& xn,
  3495. std::vector<ADD>& yn_,
  3496. int * m,
  3497. int * n,
  3498. int bx,
  3499. int sx,
  3500. int by,
  3501. int sy,
  3502. int pr) const
  3503. {
  3504. DdManager *mgr = p->manager;
  3505. DdNode *E;
  3506. DdNode **xa = 0, **ya = 0, **xna = 0, **yna = 0;
  3507. int nx = x.size(), ny = y.size();
  3508. if (nx > 0) {
  3509. xa = (DdNode **) malloc(nx * sizeof(DdNode *));
  3510. if (!xa) {
  3511. p->errorHandler("Out of memory.");
  3512. }
  3513. xna = (DdNode **) malloc(nx * sizeof(DdNode *));
  3514. if (!xna) {
  3515. free(xa);
  3516. p->errorHandler("Out of memory.");
  3517. }
  3518. for (int i = 0; i < nx; ++i) {
  3519. xa[i] = x.at(i).node;
  3520. xna[i] = xn.at(i).node;
  3521. }
  3522. }
  3523. if (ny > 0) {
  3524. ya = (DdNode **) malloc(ny * sizeof(DdNode *));
  3525. if (!ya) {
  3526. free(xa);
  3527. free(xna);
  3528. p->errorHandler("Out of memory.");
  3529. }
  3530. yna = (DdNode **) malloc(ny * sizeof(DdNode *));
  3531. if (!yna) {
  3532. free(xa);
  3533. free(xna);
  3534. free(ya);
  3535. p->errorHandler("Out of memory.");
  3536. }
  3537. for (int j = 0; j < ny; ++j) {
  3538. ya[j] = y.at(j).node;
  3539. yna[j] = yn_.at(j).node;
  3540. }
  3541. }
  3542. int result = Cudd_addHarwell(fp, mgr, &E, &xa, &ya, &xna, &yna, &nx, &ny,
  3543. m, n, bx, sx, by, sy, pr);
  3544. checkReturnValue(result);
  3545. for (int i = x.size(); i < nx; ++i) {
  3546. x.push_back(ADD(p, xa[i]));
  3547. xn.push_back(ADD(p, xna[i]));
  3548. }
  3549. free(xa);
  3550. free(xna);
  3551. for (int j = y.size(); j < ny; ++j) {
  3552. y.push_back(ADD(p, ya[j]));
  3553. yn_.push_back(ADD(p, yna[j]));
  3554. }
  3555. free(ya);
  3556. free(yna);
  3557. Cudd_Deref(E);
  3558. return ADD(p, E);
  3559. } // Cudd::Harwell
  3560. void
  3561. Cudd::PrintLinear(void) const
  3562. {
  3563. cout.flush();
  3564. int result = Cudd_PrintLinear(p->manager);
  3565. checkReturnValue(result);
  3566. } // Cudd::PrintLinear
  3567. int
  3568. Cudd::ReadLinear(
  3569. int x,
  3570. int y) const
  3571. {
  3572. return Cudd_ReadLinear(p->manager, x, y);
  3573. } // Cudd::ReadLinear
  3574. BDD
  3575. BDD::LiteralSetIntersection(
  3576. const BDD& g) const
  3577. {
  3578. DdManager *mgr = checkSameManager(g);
  3579. DdNode *result = Cudd_bddLiteralSetIntersection(mgr, node, g.node);
  3580. checkReturnValue(result);
  3581. return BDD(p, result);
  3582. } // BDD::LiteralSetIntersection
  3583. ADD
  3584. ADD::MatrixMultiply(
  3585. const ADD& B,
  3586. std::vector<ADD> z) const
  3587. {
  3588. size_t nz = z.size();
  3589. DdManager *mgr = checkSameManager(B);
  3590. DdNode **Z = new DdNode *[nz];
  3591. for (size_t i = 0; i < nz; i++) {
  3592. Z[i] = z[i].node;
  3593. }
  3594. DdNode *result = Cudd_addMatrixMultiply(mgr, node, B.node, Z, (int) nz);
  3595. delete [] Z;
  3596. checkReturnValue(result);
  3597. return ADD(p, result);
  3598. } // ADD::MatrixMultiply
  3599. ADD
  3600. ADD::TimesPlus(
  3601. const ADD& B,
  3602. std::vector<ADD> z) const
  3603. {
  3604. size_t nz = z.size();
  3605. DdManager *mgr = checkSameManager(B);
  3606. DdNode **Z = new DdNode *[nz];
  3607. for (size_t i = 0; i < nz; i++) {
  3608. Z[i] = z[i].node;
  3609. }
  3610. DdNode *result = Cudd_addTimesPlus(mgr, node, B.node, Z, (int) nz);
  3611. delete [] Z;
  3612. checkReturnValue(result);
  3613. return ADD(p, result);
  3614. } // ADD::TimesPlus
  3615. ADD
  3616. ADD::Triangle(
  3617. const ADD& g,
  3618. std::vector<ADD> z) const
  3619. {
  3620. size_t nz = z.size();
  3621. DdManager *mgr = checkSameManager(g);
  3622. DdNode **Z = new DdNode *[nz];
  3623. for (size_t i = 0; i < nz; i++) {
  3624. Z[i] = z[i].node;
  3625. }
  3626. DdNode *result = Cudd_addTriangle(mgr, node, g.node, Z, (int) nz);
  3627. delete [] Z;
  3628. checkReturnValue(result);
  3629. return ADD(p, result);
  3630. } // ADD::Triangle
  3631. BDD
  3632. BDD::PrioritySelect(
  3633. std::vector<BDD> x,
  3634. std::vector<BDD> y,
  3635. std::vector<BDD> z,
  3636. const BDD& Pi,
  3637. DD_PRFP Pifunc) const
  3638. {
  3639. size_t n = x.size();
  3640. DdManager *mgr = p->manager;
  3641. DdNode **X = new DdNode *[n];
  3642. DdNode **Y = new DdNode *[n];
  3643. DdNode **Z = new DdNode *[n];
  3644. for (size_t i = 0; i < n; i++) {
  3645. X[i] = x[i].node;
  3646. Y[i] = y[i].node;
  3647. Z[i] = z[i].node;
  3648. }
  3649. DdNode *result = Cudd_PrioritySelect(mgr, node, X, Y, Z, Pi.node,
  3650. (int) n, Pifunc);
  3651. delete [] X;
  3652. delete [] Y;
  3653. delete [] Z;
  3654. checkReturnValue(result);
  3655. return BDD(p, result);
  3656. } // BDD::PrioritySelect
  3657. BDD
  3658. Cudd::Xgty(
  3659. std::vector<BDD> z,
  3660. std::vector<BDD> x,
  3661. std::vector<BDD> y) const
  3662. {
  3663. size_t N = z.size();
  3664. DdManager *mgr = p->manager;
  3665. DdNode **X = new DdNode *[N];
  3666. DdNode **Y = new DdNode *[N];
  3667. DdNode **Z = new DdNode *[N];
  3668. for (size_t i = 0; i < N; i++) {
  3669. X[i] = x[i].getNode();
  3670. Y[i] = y[i].getNode();
  3671. Z[i] = z[i].getNode();
  3672. }
  3673. DdNode *result = Cudd_Xgty(mgr, (int) N, Z, X, Y);
  3674. delete [] X;
  3675. delete [] Y;
  3676. delete [] Z;
  3677. checkReturnValue(result);
  3678. return BDD(p, result);
  3679. } // Cudd::Xgty
  3680. BDD
  3681. Cudd::Xeqy(
  3682. std::vector<BDD> x,
  3683. std::vector<BDD> y) const
  3684. {
  3685. size_t N = x.size();
  3686. DdManager *mgr = p->manager;
  3687. DdNode **X = new DdNode *[N];
  3688. DdNode **Y = new DdNode *[N];
  3689. for (size_t i = 0; i < N; i++) {
  3690. X[i] = x[i].getNode();
  3691. Y[i] = y[i].getNode();
  3692. }
  3693. DdNode *result = Cudd_Xeqy(mgr, (int) N, X, Y);
  3694. delete [] X;
  3695. delete [] Y;
  3696. checkReturnValue(result);
  3697. return BDD(p, result);
  3698. } // BDD::Xeqy
  3699. ADD
  3700. Cudd::Xeqy(
  3701. std::vector<ADD> x,
  3702. std::vector<ADD> y) const
  3703. {
  3704. size_t N = x.size();
  3705. DdManager *mgr = p->manager;
  3706. DdNode **X = new DdNode *[N];
  3707. DdNode **Y = new DdNode *[N];
  3708. for (size_t i = 0; i < N; i++) {
  3709. X[i] = x[i].getNode();
  3710. Y[i] = y[i].getNode();
  3711. }
  3712. DdNode *result = Cudd_addXeqy(mgr, (int) N, X, X);
  3713. delete [] X;
  3714. delete [] Y;
  3715. checkReturnValue(result);
  3716. return ADD(p, result);
  3717. } // ADD::Xeqy
  3718. BDD
  3719. Cudd::Dxygtdxz(
  3720. std::vector<BDD> x,
  3721. std::vector<BDD> y,
  3722. std::vector<BDD> z) const
  3723. {
  3724. size_t N = x.size();
  3725. DdManager *mgr = p->manager;
  3726. DdNode **X = new DdNode *[N];
  3727. DdNode **Y = new DdNode *[N];
  3728. DdNode **Z = new DdNode *[N];
  3729. for (size_t i = 0; i < N; i++) {
  3730. X[i] = x[i].getNode();
  3731. Y[i] = y[i].getNode();
  3732. Z[i] = z[i].getNode();
  3733. }
  3734. DdNode *result = Cudd_Dxygtdxz(mgr, (int) N, X, Y, Z);
  3735. delete [] X;
  3736. delete [] Y;
  3737. delete [] Z;
  3738. checkReturnValue(result);
  3739. return BDD(p, result);
  3740. } // Cudd::Dxygtdxz
  3741. BDD
  3742. Cudd::Dxygtdyz(
  3743. std::vector<BDD> x,
  3744. std::vector<BDD> y,
  3745. std::vector<BDD> z) const
  3746. {
  3747. size_t N = x.size();
  3748. DdManager *mgr = p->manager;
  3749. DdNode **X = new DdNode *[N];
  3750. DdNode **Y = new DdNode *[N];
  3751. DdNode **Z = new DdNode *[N];
  3752. for (size_t i = 0; i < N; i++) {
  3753. X[i] = x[i].getNode();
  3754. Y[i] = y[i].getNode();
  3755. Z[i] = z[i].getNode();
  3756. }
  3757. DdNode *result = Cudd_Dxygtdyz(mgr, (int) N, X, Y, Z);
  3758. delete [] X;
  3759. delete [] Y;
  3760. delete [] Z;
  3761. checkReturnValue(result);
  3762. return BDD(p, result);
  3763. } // Cudd::Dxygtdyz
  3764. BDD
  3765. Cudd::Inequality(
  3766. int c,
  3767. std::vector<BDD> x,
  3768. std::vector<BDD> y) const
  3769. {
  3770. size_t N = x.size();
  3771. DdManager *mgr = p->manager;
  3772. DdNode **X = new DdNode *[N];
  3773. DdNode **Y = new DdNode *[N];
  3774. for (size_t i = 0; i < N; i++) {
  3775. X[i] = x[i].getNode();
  3776. Y[i] = y[i].getNode();
  3777. }
  3778. DdNode *result = Cudd_Inequality(mgr, (int) N, c, X, Y);
  3779. delete [] X;
  3780. delete [] Y;
  3781. checkReturnValue(result);
  3782. return BDD(p, result);
  3783. } // Cudd::Inequality
  3784. BDD
  3785. Cudd::Disequality(
  3786. int c,
  3787. std::vector<BDD> x,
  3788. std::vector<BDD> y) const
  3789. {
  3790. size_t N = x.size();
  3791. DdManager *mgr = p->manager;
  3792. DdNode **X = new DdNode *[N];
  3793. DdNode **Y = new DdNode *[N];
  3794. for (size_t i = 0; i < N; i++) {
  3795. X[i] = x[i].getNode();
  3796. Y[i] = y[i].getNode();
  3797. }
  3798. DdNode *result = Cudd_Disequality(mgr, (int) N, c, X, Y);
  3799. delete [] X;
  3800. delete [] Y;
  3801. checkReturnValue(result);
  3802. return BDD(p, result);
  3803. } // Cudd::Disequality
  3804. BDD
  3805. Cudd::Interval(
  3806. std::vector<BDD> x,
  3807. unsigned int lowerB,
  3808. unsigned int upperB) const
  3809. {
  3810. size_t N = x.size();
  3811. DdManager *mgr = p->manager;
  3812. DdNode **X = new DdNode *[N];
  3813. for (size_t i = 0; i < N; i++) {
  3814. X[i] = x[i].getNode();
  3815. }
  3816. DdNode *result = Cudd_bddInterval(mgr, (int) N, X, lowerB, upperB);
  3817. delete [] X;
  3818. checkReturnValue(result);
  3819. return BDD(p, result);
  3820. } // Cudd::Interval
  3821. BDD
  3822. BDD::CProjection(
  3823. const BDD& Y) const
  3824. {
  3825. DdManager *mgr = checkSameManager(Y);
  3826. DdNode *result = Cudd_CProjection(mgr, node, Y.node);
  3827. checkReturnValue(result);
  3828. return BDD(p, result);
  3829. } // BDD::CProjection
  3830. int
  3831. BDD::MinHammingDist(
  3832. int *minterm,
  3833. int upperBound) const
  3834. {
  3835. DdManager *mgr = p->manager;
  3836. int result = Cudd_MinHammingDist(mgr, node, minterm, upperBound);
  3837. return result;
  3838. } // BDD::MinHammingDist
  3839. ADD
  3840. Cudd::Hamming(
  3841. std::vector<ADD> xVars,
  3842. std::vector<ADD> yVars) const
  3843. {
  3844. size_t nVars = xVars.size();
  3845. DdManager *mgr = p->manager;
  3846. DdNode **X = new DdNode *[nVars];
  3847. DdNode **Y = new DdNode *[nVars];
  3848. for (size_t i = 0; i < nVars; i++) {
  3849. X[i] = xVars[i].getNode();
  3850. Y[i] = yVars[i].getNode();
  3851. }
  3852. DdNode *result = Cudd_addHamming(mgr, X, Y, (int) nVars);
  3853. delete [] X;
  3854. delete [] Y;
  3855. checkReturnValue(result);
  3856. return ADD(p, result);
  3857. } // Cudd::Hamming
  3858. ADD
  3859. Cudd::Read(
  3860. FILE * fp,
  3861. std::vector<ADD>& x,
  3862. std::vector<ADD>& y,
  3863. std::vector<ADD>& xn,
  3864. std::vector<ADD>& yn_,
  3865. int * m,
  3866. int * n,
  3867. int bx,
  3868. int sx,
  3869. int by,
  3870. int sy) const
  3871. {
  3872. DdManager *mgr = p->manager;
  3873. DdNode *E;
  3874. DdNode **xa = 0, **ya = 0, **xna = 0, **yna = 0;
  3875. int nx = x.size(), ny = y.size();
  3876. if (nx > 0) {
  3877. xa = (DdNode **) malloc(nx * sizeof(DdNode *));
  3878. if (!xa) {
  3879. p->errorHandler("Out of memory.");
  3880. }
  3881. xna = (DdNode **) malloc(nx * sizeof(DdNode *));
  3882. if (!xna) {
  3883. free(xa);
  3884. p->errorHandler("Out of memory.");
  3885. }
  3886. for (int i = 0; i < nx; ++i) {
  3887. xa[i] = x.at(i).node;
  3888. xna[i] = xn.at(i).node;
  3889. }
  3890. }
  3891. if (ny > 0) {
  3892. ya = (DdNode **) malloc(ny * sizeof(DdNode *));
  3893. if (!ya) {
  3894. free(xa);
  3895. free(xna);
  3896. p->errorHandler("Out of memory.");
  3897. }
  3898. yna = (DdNode **) malloc(ny * sizeof(DdNode *));
  3899. if (!yna) {
  3900. free(xa);
  3901. free(xna);
  3902. free(ya);
  3903. p->errorHandler("Out of memory.");
  3904. }
  3905. for (int j = 0; j < ny; ++j) {
  3906. ya[j] = y.at(j).node;
  3907. yna[j] = yn_.at(j).node;
  3908. }
  3909. }
  3910. int result = Cudd_addRead(fp, mgr, &E, &xa, &ya, &xna, &yna, &nx, &ny,
  3911. m, n, bx, sx, by, sy);
  3912. checkReturnValue(result);
  3913. for (int i = x.size(); i < nx; ++i) {
  3914. x.push_back(ADD(p, xa[i]));
  3915. xn.push_back(ADD(p, xna[i]));
  3916. }
  3917. free(xa);
  3918. free(xna);
  3919. for (int j = y.size(); j < ny; ++j) {
  3920. y.push_back(ADD(p, ya[j]));
  3921. yn_.push_back(ADD(p, yna[j]));
  3922. }
  3923. free(ya);
  3924. free(yna);
  3925. Cudd_Deref(E);
  3926. return ADD(p, E);
  3927. } // Cudd::Read
  3928. BDD
  3929. Cudd::Read(
  3930. FILE * fp,
  3931. std::vector<BDD>& x,
  3932. std::vector<BDD>& y,
  3933. int * m,
  3934. int * n,
  3935. int bx,
  3936. int sx,
  3937. int by,
  3938. int sy) const
  3939. {
  3940. DdManager *mgr = p->manager;
  3941. DdNode *E;
  3942. DdNode **xa = 0, **ya = 0;
  3943. int nx = x.size(), ny = y.size();
  3944. if (nx > 0) {
  3945. xa = (DdNode **) malloc(nx * sizeof(DdNode *));
  3946. if (!xa) {
  3947. p->errorHandler("Out of memory.");
  3948. }
  3949. for (int i = 0; i < nx; ++i) {
  3950. xa[i] = x.at(i).node;
  3951. }
  3952. }
  3953. if (ny > 0) {
  3954. ya = (DdNode **) malloc(ny * sizeof(DdNode *));
  3955. if (!ya) {
  3956. free(xa);
  3957. p->errorHandler("Out of memory.");
  3958. }
  3959. for (int j = 0; j < nx; ++j) {
  3960. ya[j] = y.at(j).node;
  3961. }
  3962. }
  3963. int result = Cudd_bddRead(fp, mgr, &E, &xa, &ya, &nx, &ny,
  3964. m, n, bx, sx, by, sy);
  3965. checkReturnValue(result);
  3966. for (int i = x.size(); i < nx; ++i) {
  3967. x.push_back(BDD(p, xa[i]));
  3968. }
  3969. free(xa);
  3970. for (int j = y.size(); j < ny; ++j) {
  3971. y.push_back(BDD(p, ya[j]));
  3972. }
  3973. free(ya);
  3974. Cudd_Deref(E);
  3975. return BDD(p, E);
  3976. } // Cudd::Read
  3977. void
  3978. Cudd::ReduceHeap(
  3979. Cudd_ReorderingType heuristic,
  3980. int minsize) const
  3981. {
  3982. int result = Cudd_ReduceHeap(p->manager, heuristic, minsize);
  3983. checkReturnValue(result);
  3984. } // Cudd::ReduceHeap
  3985. void
  3986. Cudd::ShuffleHeap(
  3987. int * permutation) const
  3988. {
  3989. int result = Cudd_ShuffleHeap(p->manager, permutation);
  3990. checkReturnValue(result);
  3991. } // Cudd::ShuffleHeap
  3992. ADD
  3993. ADD::Eval(
  3994. int * inputs) const
  3995. {
  3996. DdManager *mgr = p->manager;
  3997. DdNode *result = Cudd_Eval(mgr, node, inputs);
  3998. checkReturnValue(result);
  3999. return ADD(p, result);
  4000. } // ADD::Eval
  4001. BDD
  4002. BDD::Eval(
  4003. int * inputs) const
  4004. {
  4005. DdManager *mgr = p->manager;
  4006. DdNode *result = Cudd_Eval(mgr, node, inputs);
  4007. checkReturnValue(result);
  4008. return BDD(p, result);
  4009. } // BDD::Eval
  4010. BDD
  4011. ABDD::ShortestPath(
  4012. int * weight,
  4013. int * support,
  4014. int * length) const
  4015. {
  4016. DdManager *mgr = p->manager;
  4017. DdNode *result = Cudd_ShortestPath(mgr, node, weight, support, length);
  4018. checkReturnValue(result);
  4019. return BDD(p, result);
  4020. } // ABDD::ShortestPath
  4021. BDD
  4022. ABDD::LargestCube(
  4023. int * length) const
  4024. {
  4025. DdManager *mgr = p->manager;
  4026. DdNode *result = Cudd_LargestCube(mgr, node, length);
  4027. checkReturnValue(result);
  4028. return BDD(p, result);
  4029. } // ABDD::LargestCube
  4030. int
  4031. ABDD::ShortestLength(
  4032. int * weight) const
  4033. {
  4034. DdManager *mgr = p->manager;
  4035. int result = Cudd_ShortestLength(mgr, node, weight);
  4036. checkReturnValue(result != CUDD_OUT_OF_MEM);
  4037. return result;
  4038. } // ABDD::ShortestLength
  4039. BDD
  4040. BDD::Decreasing(
  4041. int i) const
  4042. {
  4043. DdManager *mgr = p->manager;
  4044. DdNode *result = Cudd_Decreasing(mgr, node, i);
  4045. checkReturnValue(result);
  4046. return BDD(p, result);
  4047. } // BDD::Decreasing
  4048. BDD
  4049. BDD::Increasing(
  4050. int i) const
  4051. {
  4052. DdManager *mgr = p->manager;
  4053. DdNode *result = Cudd_Increasing(mgr, node, i);
  4054. checkReturnValue(result);
  4055. return BDD(p, result);
  4056. } // BDD::Increasing
  4057. bool
  4058. ABDD::EquivDC(
  4059. const ABDD& G,
  4060. const ABDD& D) const
  4061. {
  4062. DdManager *mgr = checkSameManager(G);
  4063. checkSameManager(D);
  4064. return Cudd_EquivDC(mgr, node, G.node, D.node);
  4065. } // ABDD::EquivDC
  4066. bool
  4067. BDD::LeqUnless(
  4068. const BDD& G,
  4069. const BDD& D) const
  4070. {
  4071. DdManager *mgr = checkSameManager(G);
  4072. checkSameManager(D);
  4073. int res = Cudd_bddLeqUnless(mgr, node, G.node, D.node);
  4074. return res;
  4075. } // BDD::LeqUnless
  4076. bool
  4077. ADD::EqualSupNorm(
  4078. const ADD& g,
  4079. CUDD_VALUE_TYPE tolerance,
  4080. int pr) const
  4081. {
  4082. DdManager *mgr = checkSameManager(g);
  4083. return Cudd_EqualSupNorm(mgr, node, g.node, tolerance, pr);
  4084. } // ADD::EqualSupNorm
  4085. bool
  4086. ADD::EqualSupNormRel(
  4087. const ADD& g,
  4088. CUDD_VALUE_TYPE tolerance,
  4089. int pr) const
  4090. {
  4091. DdManager *mgr = checkSameManager(g);
  4092. return Cudd_EqualSupNormRel(mgr, node, g.node, tolerance, pr) != 0;
  4093. } // ADD::EqualSupNormRel
  4094. BDD
  4095. BDD::MakePrime(
  4096. const BDD& F) const
  4097. {
  4098. DdManager *mgr = checkSameManager(F);
  4099. if (!Cudd_CheckCube(mgr, node)) {
  4100. p->errorHandler("Invalid argument.");
  4101. }
  4102. DdNode *result = Cudd_bddMakePrime(mgr, node, F.node);
  4103. checkReturnValue(result);
  4104. return BDD(p, result);
  4105. } // BDD:MakePrime
  4106. BDD
  4107. BDD::MaximallyExpand(
  4108. const BDD& ub,
  4109. const BDD& f)
  4110. {
  4111. DdManager *mgr = checkSameManager(ub);
  4112. checkSameManager(f);
  4113. DdNode *result = Cudd_bddMaximallyExpand(mgr, node, ub.node, f.node);
  4114. checkReturnValue(result);
  4115. return BDD(p, result);
  4116. } // BDD::MaximallyExpand
  4117. BDD
  4118. BDD::LargestPrimeUnate(
  4119. const BDD& phases)
  4120. {
  4121. DdManager *mgr = checkSameManager(phases);
  4122. DdNode *result = Cudd_bddLargestPrimeUnate(mgr, node, phases.node);
  4123. checkReturnValue(result);
  4124. return BDD(p, result);
  4125. } // BDD::LargestPrimeUnate
  4126. double *
  4127. ABDD::CofMinterm() const
  4128. {
  4129. DdManager *mgr = p->manager;
  4130. double *result = Cudd_CofMinterm(mgr, node);
  4131. checkReturnValue(result);
  4132. return result;
  4133. } // ABDD::CofMinterm
  4134. BDD
  4135. BDD::SolveEqn(
  4136. const BDD& Y,
  4137. std::vector<BDD> & G,
  4138. int ** yIndex,
  4139. int n) const
  4140. {
  4141. DdManager *mgr = checkSameManager(Y);
  4142. DdNode **g = new DdNode *[n];
  4143. DdNode *result = Cudd_SolveEqn(mgr, node, Y.node, g, yIndex, n);
  4144. checkReturnValue(result);
  4145. for (int i = 0; i < n; i++) {
  4146. G.push_back(BDD(p, g[i]));
  4147. Cudd_RecursiveDeref(mgr,g[i]);
  4148. }
  4149. delete [] g;
  4150. return BDD(p, result);
  4151. } // BDD::SolveEqn
  4152. BDD
  4153. BDD::VerifySol(
  4154. std::vector<BDD> const & G,
  4155. int * yIndex) const
  4156. {
  4157. size_t n = G.size();
  4158. DdManager *mgr = p->manager;
  4159. DdNode **g = new DdNode *[n];
  4160. for (size_t i = 0; i < n; i++) {
  4161. g[i] = G[i].node;
  4162. }
  4163. DdNode *result = Cudd_VerifySol(mgr, node, g, yIndex, (int) n);
  4164. delete [] g;
  4165. checkReturnValue(result);
  4166. return BDD(p, result);
  4167. } // BDD::VerifySol
  4168. BDD
  4169. BDD::SplitSet(
  4170. std::vector<BDD> xVars,
  4171. double m) const
  4172. {
  4173. size_t n = xVars.size();
  4174. DdManager *mgr = p->manager;
  4175. DdNode **X = new DdNode *[n];
  4176. for (size_t i = 0; i < n; i++) {
  4177. X[i] = xVars[i].node;
  4178. }
  4179. DdNode *result = Cudd_SplitSet(mgr, node, X, (int) n, m);
  4180. delete [] X;
  4181. checkReturnValue(result);
  4182. return BDD(p, result);
  4183. } // BDD::SplitSet
  4184. BDD
  4185. BDD::SubsetHeavyBranch(
  4186. int numVars,
  4187. int threshold) const
  4188. {
  4189. DdManager *mgr = p->manager;
  4190. DdNode *result = Cudd_SubsetHeavyBranch(mgr, node, numVars, threshold);
  4191. checkReturnValue(result);
  4192. return BDD(p, result);
  4193. } // BDD::SubsetHeavyBranch
  4194. BDD
  4195. BDD::SupersetHeavyBranch(
  4196. int numVars,
  4197. int threshold) const
  4198. {
  4199. DdManager *mgr = p->manager;
  4200. DdNode *result = Cudd_SupersetHeavyBranch(mgr, node, numVars, threshold);
  4201. checkReturnValue(result);
  4202. return BDD(p, result);
  4203. } // BDD::SupersetHeavyBranch
  4204. BDD
  4205. BDD::SubsetShortPaths(
  4206. int numVars,
  4207. int threshold,
  4208. bool hardlimit) const
  4209. {
  4210. DdManager *mgr = p->manager;
  4211. DdNode *result = Cudd_SubsetShortPaths(mgr, node, numVars, threshold, hardlimit);
  4212. checkReturnValue(result);
  4213. return BDD(p, result);
  4214. } // BDD::SubsetShortPaths
  4215. BDD
  4216. BDD::SupersetShortPaths(
  4217. int numVars,
  4218. int threshold,
  4219. bool hardlimit) const
  4220. {
  4221. DdManager *mgr = p->manager;
  4222. DdNode *result = Cudd_SupersetShortPaths(mgr, node, numVars, threshold, hardlimit);
  4223. checkReturnValue(result);
  4224. return BDD(p, result);
  4225. } // BDD::SupersetShortPaths
  4226. void
  4227. Cudd::SymmProfile(
  4228. int lower,
  4229. int upper) const
  4230. {
  4231. Cudd_SymmProfile(p->manager, lower, upper);
  4232. } // Cudd::SymmProfile
  4233. unsigned int
  4234. Cudd::Prime(
  4235. unsigned int pr) const
  4236. {
  4237. return Cudd_Prime(pr);
  4238. } // Cudd::Prime
  4239. void
  4240. Cudd::Reserve(
  4241. int amount) const
  4242. {
  4243. int result = Cudd_Reserve(p->manager, amount);
  4244. checkReturnValue(result);
  4245. } // Cudd::Reserve
  4246. void
  4247. ABDD::PrintMinterm() const
  4248. {
  4249. cout.flush();
  4250. DdManager *mgr = p->manager;
  4251. int result = Cudd_PrintMinterm(mgr, node);
  4252. checkReturnValue(result);
  4253. } // ABDD::PrintMinterm
  4254. void
  4255. BDD::PrintCover() const
  4256. {
  4257. cout.flush();
  4258. DdManager *mgr = p->manager;
  4259. int result = Cudd_bddPrintCover(mgr, node, node);
  4260. checkReturnValue(result);
  4261. } // BDD::PrintCover
  4262. void
  4263. BDD::PrintCover(
  4264. const BDD& u) const
  4265. {
  4266. checkSameManager(u);
  4267. cout.flush();
  4268. DdManager *mgr = p->manager;
  4269. int result = Cudd_bddPrintCover(mgr, node, u.node);
  4270. checkReturnValue(result);
  4271. } // BDD::PrintCover
  4272. int
  4273. BDD::EstimateCofactor(
  4274. int i,
  4275. int phase) const
  4276. {
  4277. DdManager *mgr = p->manager;
  4278. int result = Cudd_EstimateCofactor(mgr, node, i, phase);
  4279. checkReturnValue(result != CUDD_OUT_OF_MEM);
  4280. return result;
  4281. } // BDD::EstimateCofactor
  4282. int
  4283. BDD::EstimateCofactorSimple(
  4284. int i) const
  4285. {
  4286. int result = Cudd_EstimateCofactorSimple(node, i);
  4287. return result;
  4288. } // BDD::EstimateCofactorSimple
  4289. int
  4290. Cudd::SharingSize(
  4291. DD* nodes,
  4292. int n) const
  4293. {
  4294. DdNode **nodeArray = new DdNode *[n];
  4295. for (int i = 0; i < n; i++) {
  4296. nodeArray[i] = nodes[i].getNode();
  4297. }
  4298. int result = Cudd_SharingSize(nodeArray, n);
  4299. delete [] nodeArray;
  4300. checkReturnValue(n == 0 || result > 0);
  4301. return result;
  4302. } // Cudd::SharingSize
  4303. int
  4304. Cudd::SharingSize(
  4305. const std::vector<BDD>& v) const
  4306. {
  4307. vector<BDD>::size_type n = v.size();
  4308. DdNode **nodeArray = new DdNode *[n];
  4309. for (vector<BDD>::size_type i = 0; i != n; ++i) {
  4310. nodeArray[i] = v[i].getNode();
  4311. }
  4312. int result = Cudd_SharingSize(nodeArray, (int) n);
  4313. delete [] nodeArray;
  4314. checkReturnValue(n == 0 || result > 0);
  4315. return result;
  4316. } // Cudd::SharingSize
  4317. double
  4318. ABDD::CountMinterm(
  4319. int nvars) const
  4320. {
  4321. DdManager *mgr = p->manager;
  4322. double result = Cudd_CountMinterm(mgr, node, nvars);
  4323. checkReturnValue(result != (double) CUDD_OUT_OF_MEM);
  4324. return result;
  4325. } // ABDD::CountMinterm
  4326. double
  4327. ABDD::CountPath() const
  4328. {
  4329. double result = Cudd_CountPath(node);
  4330. checkReturnValue(result != (double) CUDD_OUT_OF_MEM);
  4331. return result;
  4332. } // ABDD::CountPath
  4333. BDD
  4334. ABDD::Support() const
  4335. {
  4336. DdManager *mgr = p->manager;
  4337. DdNode *result = Cudd_Support(mgr, node);
  4338. checkReturnValue(result);
  4339. return BDD(p, result);
  4340. } // ABDD::Support
  4341. int
  4342. ABDD::SupportSize() const
  4343. {
  4344. DdManager *mgr = p->manager;
  4345. int result = Cudd_SupportSize(mgr, node);
  4346. checkReturnValue(result != CUDD_OUT_OF_MEM);
  4347. return result;
  4348. } // ABDD::SupportSize
  4349. BDD
  4350. Cudd::VectorSupport(const std::vector<BDD>& roots) const
  4351. {
  4352. size_t n = roots.size();
  4353. DdManager *mgr = p->manager;
  4354. DdNode **F = new DdNode *[n];
  4355. for (size_t i = 0; i < n; i++) {
  4356. F[i] = roots[i].getNode();
  4357. }
  4358. DdNode *result = Cudd_VectorSupport(mgr, F, (int) n);
  4359. delete [] F;
  4360. checkReturnValue(result);
  4361. return BDD(p, result);
  4362. } // Cudd::VectorSupport
  4363. std::vector<unsigned int>
  4364. ABDD::SupportIndices() const
  4365. {
  4366. unsigned int *support;
  4367. DdManager *mgr = p->manager;
  4368. int size = Cudd_SupportIndices(mgr, node, (int **)&support);
  4369. checkReturnValue(size >= 0);
  4370. // size could be 0, in which case support is 0 too!
  4371. vector<unsigned int> indices(support, support+size);
  4372. if (support) free(support);
  4373. return indices;
  4374. } // ABDD::SupportIndices
  4375. std::vector<unsigned int>
  4376. Cudd::SupportIndices(const std::vector<BDD>& roots) const
  4377. {
  4378. unsigned int *support;
  4379. size_t n = roots.size();
  4380. DdManager *mgr = p->manager;
  4381. DdNode **F = new DdNode *[n];
  4382. for (size_t i = 0; i < n; i++) {
  4383. F[i] = roots[i].getNode();
  4384. }
  4385. int size = Cudd_VectorSupportIndices(mgr, F, (int) n, (int **)&support);
  4386. delete [] F;
  4387. checkReturnValue(size >= 0);
  4388. // size could be 0, in which case support is 0 too!
  4389. vector<unsigned int> indices(support, support+size);
  4390. if (support) free(support);
  4391. return indices;
  4392. } // Cudd::SupportIndices
  4393. std::vector<unsigned int>
  4394. Cudd::SupportIndices(const std::vector<ADD>& roots) const
  4395. {
  4396. unsigned int *support;
  4397. size_t n = roots.size();
  4398. DdManager *mgr = p->manager;
  4399. DdNode **F = new DdNode *[n];
  4400. for (size_t i = 0; i < n; i++) {
  4401. F[i] = roots[i].getNode();
  4402. }
  4403. int size = Cudd_VectorSupportIndices(mgr, F, (int) n, (int **)&support);
  4404. delete [] F;
  4405. checkReturnValue(size >= 0);
  4406. // size could be 0, in which case support is 0 too!
  4407. vector<unsigned int> indices(support, support+size);
  4408. if (support) free(support);
  4409. return indices;
  4410. } // Cudd::SupportIndices
  4411. int
  4412. Cudd::nodeCount(const std::vector<BDD>& roots) const
  4413. {
  4414. size_t n = roots.size();
  4415. DdNode **nodeArray = new DdNode *[n];
  4416. for (size_t i = 0; i < n; i++) {
  4417. nodeArray[i] = roots[i].getNode();
  4418. }
  4419. int result = Cudd_SharingSize(nodeArray, (int) n);
  4420. delete [] nodeArray;
  4421. checkReturnValue(result > 0);
  4422. return result;
  4423. } // Cudd::nodeCount
  4424. BDD
  4425. Cudd::VectorSupport(const std::vector<ADD>& roots) const
  4426. {
  4427. size_t n = roots.size();
  4428. DdManager *mgr = p->manager;
  4429. DdNode **F = new DdNode *[n];
  4430. for (size_t i = 0; i < n; i++) {
  4431. F[i] = roots[i].getNode();
  4432. }
  4433. DdNode *result = Cudd_VectorSupport(mgr, F, (int) n);
  4434. delete [] F;
  4435. checkReturnValue(result);
  4436. return BDD(p, result);
  4437. } // Cudd::VectorSupport
  4438. int
  4439. Cudd::VectorSupportSize(const std::vector<BDD>& roots) const
  4440. {
  4441. size_t n = roots.size();
  4442. DdManager *mgr = p->manager;
  4443. DdNode **F = new DdNode *[n];
  4444. for (size_t i = 0; i < n; i++) {
  4445. F[i] = roots[i].getNode();
  4446. }
  4447. int result = Cudd_VectorSupportSize(mgr, F, (int) n);
  4448. delete [] F;
  4449. checkReturnValue(result != CUDD_OUT_OF_MEM);
  4450. return result;
  4451. } // Cudd::VectorSupportSize
  4452. int
  4453. Cudd::VectorSupportSize(const std::vector<ADD>& roots) const
  4454. {
  4455. size_t n = roots.size();
  4456. DdManager *mgr = p->manager;
  4457. DdNode **F = new DdNode *[n];
  4458. for (size_t i = 0; i < n; i++) {
  4459. F[i] = roots[i].getNode();
  4460. }
  4461. int result = Cudd_VectorSupportSize(mgr, F, (int) n);
  4462. delete [] F;
  4463. checkReturnValue(result != CUDD_OUT_OF_MEM);
  4464. return result;
  4465. } // Cudd::VectorSupportSize
  4466. void
  4467. ABDD::ClassifySupport(
  4468. const ABDD& g,
  4469. BDD* common,
  4470. BDD* onlyF,
  4471. BDD* onlyG) const
  4472. {
  4473. DdManager *mgr = checkSameManager(g);
  4474. DdNode *C, *F, *G;
  4475. int result = Cudd_ClassifySupport(mgr, node, g.node, &C, &F, &G);
  4476. checkReturnValue(result);
  4477. *common = BDD(p, C);
  4478. *onlyF = BDD(p, F);
  4479. *onlyG = BDD(p, G);
  4480. } // ABDD::ClassifySupport
  4481. int
  4482. ABDD::CountLeaves() const
  4483. {
  4484. return Cudd_CountLeaves(node);
  4485. } // ABDD::CountLeaves
  4486. DdGen *
  4487. ABDD::FirstCube(
  4488. int ** cube,
  4489. CUDD_VALUE_TYPE * value) const
  4490. {
  4491. DdManager *mgr = p->manager;
  4492. DdGen *result = Cudd_FirstCube(mgr, node, cube, value);
  4493. checkReturnValue((DdNode *)result);
  4494. return result;
  4495. } // ABDD::FirstCube
  4496. int
  4497. ABDD::NextCube(
  4498. DdGen * gen,
  4499. int ** cube,
  4500. CUDD_VALUE_TYPE * value)
  4501. {
  4502. return Cudd_NextCube(gen, cube, value);
  4503. } // ABDD::NextCube
  4504. void
  4505. BDD::PickOneCube(
  4506. char * string) const
  4507. {
  4508. DdManager *mgr = p->manager;
  4509. int result = Cudd_bddPickOneCube(mgr, node, string);
  4510. checkReturnValue(result);
  4511. } // BDD::PickOneCube
  4512. BDD
  4513. BDD::PickOneMinterm(
  4514. std::vector<BDD> vars) const
  4515. {
  4516. size_t n = vars.size();
  4517. DdManager *mgr = p->manager;
  4518. DdNode **V = new DdNode *[n];
  4519. for (size_t i = 0; i < n; i++) {
  4520. V[i] = vars[i].node;
  4521. }
  4522. DdNode *result = Cudd_bddPickOneMinterm(mgr, node, V, (int) n);
  4523. delete [] V;
  4524. checkReturnValue(result);
  4525. return BDD(p, result);
  4526. } // BDD::PickOneMinterm
  4527. BDD
  4528. Cudd::bddComputeCube(
  4529. BDD * vars,
  4530. int * phase,
  4531. int n) const
  4532. {
  4533. DdManager *mgr = p->manager;
  4534. DdNode **V = new DdNode *[n];
  4535. for (int i = 0; i < n; i++) {
  4536. V[i] = vars[i].getNode();
  4537. }
  4538. DdNode *result = Cudd_bddComputeCube(mgr, V, phase, n);
  4539. delete [] V;
  4540. checkReturnValue(result);
  4541. return BDD(p, result);
  4542. } // Cudd::bddComputeCube
  4543. BDD
  4544. Cudd::computeCube(
  4545. std::vector<BDD> const & vars) const
  4546. {
  4547. DdManager *mgr = p->manager;
  4548. size_t n = vars.size();
  4549. DdNode **V = new DdNode *[n];
  4550. for (size_t i = 0; i < n; i++) {
  4551. V[i] = vars[i].getNode();
  4552. }
  4553. DdNode *result = Cudd_bddComputeCube(mgr, V, 0, n);
  4554. delete [] V;
  4555. checkReturnValue(result);
  4556. return BDD(p, result);
  4557. } // Cudd::computeCube
  4558. ADD
  4559. Cudd::addComputeCube(
  4560. ADD * vars,
  4561. int * phase,
  4562. int n) const
  4563. {
  4564. DdManager *mgr = p->manager;
  4565. DdNode **V = new DdNode *[n];
  4566. for (int i = 0; i < n; i++) {
  4567. V[i] = vars[i].getNode();
  4568. }
  4569. DdNode *result = Cudd_addComputeCube(mgr, V, phase, n);
  4570. delete [] V;
  4571. checkReturnValue(result);
  4572. return ADD(p, result);
  4573. } // Cudd::addComputeCube
  4574. ADD
  4575. Cudd::computeCube(
  4576. std::vector<ADD> const & vars) const
  4577. {
  4578. DdManager *mgr = p->manager;
  4579. size_t n = vars.size();
  4580. DdNode **V = new DdNode *[n];
  4581. for (size_t i = 0; i < n; i++) {
  4582. V[i] = vars[i].getNode();
  4583. }
  4584. DdNode *result = Cudd_addComputeCube(mgr, V, 0, n);
  4585. delete [] V;
  4586. checkReturnValue(result);
  4587. return ADD(p, result);
  4588. } // Cudd::computeCube
  4589. BDD
  4590. Cudd::IndicesToCube(
  4591. int * array,
  4592. int n) const
  4593. {
  4594. DdNode *result = Cudd_IndicesToCube(p->manager, array, n);
  4595. checkReturnValue(result);
  4596. return BDD(p, result);
  4597. } // Cudd::IndicesToCube
  4598. void
  4599. Cudd::PrintVersion(
  4600. FILE * fp) const
  4601. {
  4602. cout.flush();
  4603. Cudd_PrintVersion(fp);
  4604. } // Cudd::PrintVersion
  4605. double
  4606. Cudd::AverageDistance() const
  4607. {
  4608. return Cudd_AverageDistance(p->manager);
  4609. } // Cudd::AverageDistance
  4610. int32_t
  4611. Cudd::Random() const
  4612. {
  4613. return Cudd_Random(p->manager);
  4614. } // Cudd::Random
  4615. void
  4616. Cudd::Srandom(
  4617. int32_t seed) const
  4618. {
  4619. Cudd_Srandom(p->manager,seed);
  4620. } // Cudd::Srandom
  4621. double
  4622. ABDD::Density(
  4623. int nvars) const
  4624. {
  4625. DdManager *mgr = p->manager;
  4626. double result = Cudd_Density(mgr, node, nvars);
  4627. checkReturnValue(result != (double) CUDD_OUT_OF_MEM);
  4628. return result;
  4629. } // ABDD::Density
  4630. int
  4631. ZDD::Count() const
  4632. {
  4633. DdManager *mgr = p->manager;
  4634. int result = Cudd_zddCount(mgr, node);
  4635. checkReturnValue(result != CUDD_OUT_OF_MEM);
  4636. return result;
  4637. } // ZDD::Count
  4638. double
  4639. ZDD::CountDouble() const
  4640. {
  4641. DdManager *mgr = p->manager;
  4642. double result = Cudd_zddCountDouble(mgr, node);
  4643. checkReturnValue(result != (double) CUDD_OUT_OF_MEM);
  4644. return result;
  4645. } // ZDD::CountDouble
  4646. ZDD
  4647. ZDD::Product(
  4648. const ZDD& g) const
  4649. {
  4650. DdManager *mgr = checkSameManager(g);
  4651. DdNode *result = Cudd_zddProduct(mgr, node, g.node);
  4652. checkReturnValue(result);
  4653. return ZDD(p, result);
  4654. } // ZDD::Product
  4655. ZDD
  4656. ZDD::UnateProduct(
  4657. const ZDD& g) const
  4658. {
  4659. DdManager *mgr = checkSameManager(g);
  4660. DdNode *result = Cudd_zddUnateProduct(mgr, node, g.node);
  4661. checkReturnValue(result);
  4662. return ZDD(p, result);
  4663. } // ZDD::UnateProduct
  4664. ZDD
  4665. ZDD::WeakDiv(
  4666. const ZDD& g) const
  4667. {
  4668. DdManager *mgr = checkSameManager(g);
  4669. DdNode *result = Cudd_zddWeakDiv(mgr, node, g.node);
  4670. checkReturnValue(result);
  4671. return ZDD(p, result);
  4672. } // ZDD::WeakDiv
  4673. ZDD
  4674. ZDD::Divide(
  4675. const ZDD& g) const
  4676. {
  4677. DdManager *mgr = checkSameManager(g);
  4678. DdNode *result = Cudd_zddDivide(mgr, node, g.node);
  4679. checkReturnValue(result);
  4680. return ZDD(p, result);
  4681. } // ZDD::Divide
  4682. ZDD
  4683. ZDD::WeakDivF(
  4684. const ZDD& g) const
  4685. {
  4686. DdManager *mgr = checkSameManager(g);
  4687. DdNode *result = Cudd_zddWeakDivF(mgr, node, g.node);
  4688. checkReturnValue(result);
  4689. return ZDD(p, result);
  4690. } // ZDD::WeakDivF
  4691. ZDD
  4692. ZDD::DivideF(
  4693. const ZDD& g) const
  4694. {
  4695. DdManager *mgr = checkSameManager(g);
  4696. DdNode *result = Cudd_zddDivideF(mgr, node, g.node);
  4697. checkReturnValue(result);
  4698. return ZDD(p, result);
  4699. } // ZDD::DivideF
  4700. MtrNode *
  4701. Cudd::MakeZddTreeNode(
  4702. unsigned int low,
  4703. unsigned int size,
  4704. unsigned int type) const
  4705. {
  4706. return Cudd_MakeZddTreeNode(p->manager, low, size, type);
  4707. } // Cudd::MakeZddTreeNode
  4708. BDD
  4709. BDD::zddIsop(
  4710. const BDD& U,
  4711. ZDD* zdd_I) const
  4712. {
  4713. DdManager *mgr = checkSameManager(U);
  4714. DdNode *Z;
  4715. DdNode *result = Cudd_zddIsop(mgr, node, U.node, &Z);
  4716. checkReturnValue(result);
  4717. *zdd_I = ZDD(p, Z);
  4718. return BDD(p, result);
  4719. } // BDD::Isop
  4720. BDD
  4721. BDD::Isop(
  4722. const BDD& U) const
  4723. {
  4724. DdManager *mgr = checkSameManager(U);
  4725. DdNode *result = Cudd_bddIsop(mgr, node, U.node);
  4726. checkReturnValue(result);
  4727. return BDD(p, result);
  4728. } // BDD::Isop
  4729. double
  4730. ZDD::CountMinterm(
  4731. int path) const
  4732. {
  4733. DdManager *mgr = p->manager;
  4734. double result = Cudd_zddCountMinterm(mgr, node, path);
  4735. checkReturnValue(result != (double) CUDD_OUT_OF_MEM);
  4736. return result;
  4737. } // ZDD::CountMinterm
  4738. void
  4739. Cudd::zddPrintSubtable() const
  4740. {
  4741. cout.flush();
  4742. Cudd_zddPrintSubtable(p->manager);
  4743. } // Cudd::zddPrintSubtable
  4744. ZDD
  4745. BDD::PortToZdd() const
  4746. {
  4747. DdManager *mgr = p->manager;
  4748. DdNode *result = Cudd_zddPortFromBdd(mgr, node);
  4749. checkReturnValue(result);
  4750. return ZDD(p, result);
  4751. } // BDD::PortToZdd
  4752. BDD
  4753. ZDD::PortToBdd() const
  4754. {
  4755. DdManager *mgr = p->manager;
  4756. DdNode *result = Cudd_zddPortToBdd(mgr, node);
  4757. checkReturnValue(result);
  4758. return BDD(p, result);
  4759. } // ZDD::PortToBdd
  4760. void
  4761. Cudd::zddReduceHeap(
  4762. Cudd_ReorderingType heuristic,
  4763. int minsize) const
  4764. {
  4765. int result = Cudd_zddReduceHeap(p->manager, heuristic, minsize);
  4766. checkReturnValue(result);
  4767. } // Cudd::zddReduceHeap
  4768. void
  4769. Cudd::zddShuffleHeap(
  4770. int * permutation) const
  4771. {
  4772. int result = Cudd_zddShuffleHeap(p->manager, permutation);
  4773. checkReturnValue(result);
  4774. } // Cudd::zddShuffleHeap
  4775. ZDD
  4776. ZDD::Ite(
  4777. const ZDD& g,
  4778. const ZDD& h) const
  4779. {
  4780. DdManager *mgr = checkSameManager(g);
  4781. checkSameManager(h);
  4782. DdNode *result = Cudd_zddIte(mgr, node, g.node, h.node);
  4783. checkReturnValue(result);
  4784. return ZDD(p, result);
  4785. } // ZDD::Ite
  4786. ZDD
  4787. ZDD::Union(
  4788. const ZDD& Q) const
  4789. {
  4790. DdManager *mgr = checkSameManager(Q);
  4791. DdNode *result = Cudd_zddUnion(mgr, node, Q.node);
  4792. checkReturnValue(result);
  4793. return ZDD(p, result);
  4794. } // ZDD::Union
  4795. ZDD
  4796. ZDD::Intersect(
  4797. const ZDD& Q) const
  4798. {
  4799. DdManager *mgr = checkSameManager(Q);
  4800. DdNode *result = Cudd_zddIntersect(mgr, node, Q.node);
  4801. checkReturnValue(result);
  4802. return ZDD(p, result);
  4803. } // ZDD::Intersect
  4804. ZDD
  4805. ZDD::Diff(
  4806. const ZDD& Q) const
  4807. {
  4808. DdManager *mgr = checkSameManager(Q);
  4809. DdNode *result = Cudd_zddDiff(mgr, node, Q.node);
  4810. checkReturnValue(result);
  4811. return ZDD(p, result);
  4812. } // ZDD::Diff
  4813. ZDD
  4814. ZDD::DiffConst(
  4815. const ZDD& Q) const
  4816. {
  4817. DdManager *mgr = checkSameManager(Q);
  4818. DdNode *result = Cudd_zddDiffConst(mgr, node, Q.node);
  4819. checkReturnValue(result);
  4820. return ZDD(p, result);
  4821. } // ZDD::DiffConst
  4822. ZDD
  4823. ZDD::Subset1(
  4824. int var) const
  4825. {
  4826. DdManager *mgr = p->manager;
  4827. DdNode *result = Cudd_zddSubset1(mgr, node, var);
  4828. checkReturnValue(result);
  4829. return ZDD(p, result);
  4830. } // ZDD::Subset1
  4831. ZDD
  4832. ZDD::Subset0(
  4833. int var) const
  4834. {
  4835. DdManager *mgr = p->manager;
  4836. DdNode *result = Cudd_zddSubset0(mgr, node, var);
  4837. checkReturnValue(result);
  4838. return ZDD(p, result);
  4839. } // ZDD::Subset0
  4840. ZDD
  4841. ZDD::Change(
  4842. int var) const
  4843. {
  4844. DdManager *mgr = p->manager;
  4845. DdNode *result = Cudd_zddChange(mgr, node, var);
  4846. checkReturnValue(result);
  4847. return ZDD(p, result);
  4848. } // ZDD::Change
  4849. void
  4850. Cudd::zddSymmProfile(
  4851. int lower,
  4852. int upper) const
  4853. {
  4854. Cudd_zddSymmProfile(p->manager, lower, upper);
  4855. } // Cudd::zddSymmProfile
  4856. void
  4857. ZDD::PrintMinterm() const
  4858. {
  4859. cout.flush();
  4860. DdManager *mgr = p->manager;
  4861. int result = Cudd_zddPrintMinterm(mgr, node);
  4862. checkReturnValue(result);
  4863. } // ZDD::PrintMinterm
  4864. void
  4865. ZDD::PrintCover() const
  4866. {
  4867. cout.flush();
  4868. DdManager *mgr = p->manager;
  4869. int result = Cudd_zddPrintCover(mgr, node);
  4870. checkReturnValue(result);
  4871. } // ZDD::PrintCover
  4872. BDD
  4873. ZDD::Support() const
  4874. {
  4875. DdManager *mgr = p->manager;
  4876. DdNode *result = Cudd_zddSupport(mgr, node);
  4877. checkReturnValue(result);
  4878. return BDD(p, result);
  4879. } // ZDD::Support
  4880. void
  4881. Cudd::DumpDot(
  4882. const std::vector<ZDD>& nodes,
  4883. char const * const * inames,
  4884. char const * const * onames,
  4885. FILE * fp) const
  4886. {
  4887. DdManager *mgr = p->manager;
  4888. size_t n = nodes.size();
  4889. DdNode **F = new DdNode *[n];
  4890. for (size_t i = 0; i < n; i++) {
  4891. F[i] = nodes[i].getNode();
  4892. }
  4893. int result = Cudd_zddDumpDot(mgr, (int) n, F, inames, onames, fp);
  4894. delete [] F;
  4895. checkReturnValue(result);
  4896. } // vector<ZDD>::DumpDot
  4897. std::string
  4898. Cudd::OrderString(void) const
  4899. {
  4900. DdManager * mgr = p->manager;
  4901. int nvars = Cudd_ReadSize(mgr);
  4902. bool hasNames = p->varnames.size() == (size_t) nvars;
  4903. std::ostringstream oss;
  4904. std::string separ = "";
  4905. for (int level = 0; level != nvars; ++level) {
  4906. oss << separ;
  4907. separ = " ";
  4908. int index = Cudd_ReadInvPerm(mgr, level);
  4909. if (hasNames) {
  4910. oss << p->varnames.at(index);
  4911. } else {
  4912. oss << "x" << index;
  4913. }
  4914. }
  4915. return oss.str();
  4916. } // Cudd::OrderString
  4917. } // end namespace storm