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.

283 lines
12 KiB

  1. /**CHeaderFile*****************************************************************
  2. FileName [ntr.h]
  3. PackageName [ntr]
  4. Synopsis [Simple-minded package to do traversal.]
  5. Description []
  6. SeeAlso []
  7. Author [Fabio Somenzi]
  8. Copyright [Copyright (c) 1995-2012, Regents of the University of Colorado
  9. All rights reserved.
  10. Redistribution and use in source and binary forms, with or without
  11. modification, are permitted provided that the following conditions
  12. are met:
  13. Redistributions of source code must retain the above copyright
  14. notice, this list of conditions and the following disclaimer.
  15. Redistributions in binary form must reproduce the above copyright
  16. notice, this list of conditions and the following disclaimer in the
  17. documentation and/or other materials provided with the distribution.
  18. Neither the name of the University of Colorado nor the names of its
  19. contributors may be used to endorse or promote products derived from
  20. this software without specific prior written permission.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  28. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. POSSIBILITY OF SUCH DAMAGE.]
  33. Revision [$Id: ntr.h,v 1.28 2012/02/05 01:53:01 fabio Exp fabio $]
  34. ******************************************************************************/
  35. #ifndef _NTR
  36. #define _NTR
  37. /*---------------------------------------------------------------------------*/
  38. /* Nested includes */
  39. /*---------------------------------------------------------------------------*/
  40. #include "dddmp.h"
  41. #include "bnet.h"
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45. /*---------------------------------------------------------------------------*/
  46. /* Constant declarations */
  47. /*---------------------------------------------------------------------------*/
  48. #define PI_PS_FROM_FILE 0
  49. #define PI_PS_DFS 1
  50. #define PI_PS_GIVEN 2
  51. #define NTR_IMAGE_MONO 0
  52. #define NTR_IMAGE_PART 1
  53. #define NTR_IMAGE_CLIP 2
  54. #define NTR_IMAGE_DEPEND 3
  55. #define NTR_UNDER_APPROX 0
  56. #define NTR_OVER_APPROX 1
  57. #define NTR_FROM_NEW 0
  58. #define NTR_FROM_REACHED 1
  59. #define NTR_FROM_RESTRICT 2
  60. #define NTR_FROM_COMPACT 3
  61. #define NTR_FROM_SQUEEZE 4
  62. #define NTR_FROM_UNDERAPPROX 5
  63. #define NTR_FROM_OVERAPPROX 6
  64. #define NTR_GROUP_NONE 0
  65. #define NTR_GROUP_DEFAULT 1
  66. #define NTR_GROUP_FIXED 2
  67. #define NTR_SHORT_NONE 0
  68. #define NTR_SHORT_BELLMAN 1
  69. #define NTR_SHORT_FLOYD 2
  70. #define NTR_SHORT_SQUARE 3
  71. /*---------------------------------------------------------------------------*/
  72. /* Stucture declarations */
  73. /*---------------------------------------------------------------------------*/
  74. /*---------------------------------------------------------------------------*/
  75. /* Type declarations */
  76. /*---------------------------------------------------------------------------*/
  77. typedef struct NtrOptions {
  78. long initialTime; /* this is here for convenience */
  79. int verify; /* read two networks and compare them */
  80. char *file1; /* first network file name */
  81. char *file2; /* second network file name */
  82. int second; /* a second network is given */
  83. int traverse; /* do reachability analysis */
  84. int depend; /* do latch dependence analysis */
  85. int image; /* monolithic, partitioned, or clip */
  86. double imageClip; /* clipping depth in image computation */
  87. int approx; /* under or over approximation */
  88. int threshold; /* approximation threshold */
  89. int from; /* method to compute from states */
  90. int groupnsps; /* group present state and next state vars */
  91. int closure; /* use transitive closure */
  92. double closureClip; /* clipping depth in closure computation */
  93. int envelope; /* compute outer envelope */
  94. int scc; /* compute strongly connected components */
  95. int zddtest; /* do zdd test */
  96. int printcover; /* print ISOP covers when testing ZDDs */
  97. int maxflow; /* compute maximum flow in network */
  98. int shortPath; /* compute shortest paths in network */
  99. int selectiveTrace; /* use selective trace in shortest paths */
  100. char *sinkfile; /* file for externally provided sink node */
  101. int partition; /* test McMillan conjunctive partitioning */
  102. int char2vect; /* test char-to-vect decomposition */
  103. int density; /* test density-related functions */
  104. double quality; /* quality parameter for density functions */
  105. int decomp; /* test decomposition functions */
  106. int cofest; /* test cofactor estimation */
  107. double clip; /* test clipping functions */
  108. int dontcares; /* test equivalence and containment with DCs */
  109. int closestCube; /* test Cudd_bddClosestCube */
  110. int clauses; /* test extraction of two-literal clauses */
  111. int noBuild; /* do not build BDDs; just echo order */
  112. int stateOnly; /* ignore primary outputs */
  113. char *node; /* only node for which to build BDD */
  114. int locGlob; /* build global or local BDDs */
  115. int progress; /* report output names while building BDDs */
  116. int cacheSize; /* computed table initial size */
  117. unsigned long maxMemory; /* target maximum memory */
  118. unsigned long maxMemHard; /* maximum allowed memory */
  119. unsigned int maxLive; /* maximum number of nodes */
  120. int slots; /* unique subtable initial slots */
  121. int ordering; /* FANIN DFS ... */
  122. char *orderPiPs; /* file for externally provided order */
  123. Cudd_ReorderingType reordering; /* NONE RANDOM PIVOT SIFTING ... */
  124. int autoDyn; /* ON OFF */
  125. Cudd_ReorderingType autoMethod; /* RANDOM PIVOT SIFTING CONVERGE ... */
  126. char *treefile; /* file name for variable tree */
  127. int firstReorder; /* when to do first reordering */
  128. int countDead; /* count dead nodes toward triggering
  129. reordering */
  130. int maxGrowth; /* maximum growth during reordering (%) */
  131. Cudd_AggregationType groupcheck; /* grouping function */
  132. int arcviolation; /* percent violation of arcs in
  133. extended symmetry check */
  134. int symmviolation; /* percent symm violation in
  135. extended symmetry check */
  136. int recomb; /* recombination parameter for grouping */
  137. int nodrop; /* don't drop intermediate BDDs ASAP */
  138. int signatures; /* computation of signatures */
  139. int gaOnOff; /* whether to run GA at the end */
  140. int populationSize; /* population size for GA */
  141. int numberXovers; /* number of crossovers for GA */
  142. int bdddump; /* ON OFF */
  143. int dumpFmt; /* 0 -> dot 1 -> blif 2 ->daVinci 3 -> DDcal
  144. ** 4 -> factored form */
  145. char *dumpfile; /* filename for dump */
  146. int store; /* iteration at which to store Reached */
  147. char *storefile; /* filename for storing Reached */
  148. int load; /* load initial states from file */
  149. char *loadfile; /* filename for loading states */
  150. int verb; /* level of verbosity */
  151. } NtrOptions;
  152. typedef struct NtrHeapSlot {
  153. void *item;
  154. int key;
  155. } NtrHeapSlot;
  156. typedef struct NtrHeap {
  157. int size;
  158. int nslots;
  159. NtrHeapSlot *slots;
  160. } NtrHeap;
  161. typedef struct NtrPartTR {
  162. int nparts; /* number of parts */
  163. DdNode **part; /* array of parts */
  164. DdNode **icube; /* quantification cubes for image */
  165. DdNode **pcube; /* quantification cubes for preimage */
  166. DdNode **nscube; /* next state variables in each part */
  167. DdNode *preiabs; /* present state vars and inputs in no part */
  168. DdNode *prepabs; /* inputs in no part */
  169. DdNode *xw; /* cube of all present states and PIs */
  170. NtrHeap *factors; /* factors extracted from the image */
  171. int nlatches; /* number of latches */
  172. DdNode **x; /* array of present state variables */
  173. DdNode **y; /* array of next state variables */
  174. } NtrPartTR;
  175. /*---------------------------------------------------------------------------*/
  176. /* Variable declarations */
  177. /*---------------------------------------------------------------------------*/
  178. /*---------------------------------------------------------------------------*/
  179. /* Macro declarations */
  180. /*---------------------------------------------------------------------------*/
  181. #ifndef TRUE
  182. # define TRUE 1
  183. #endif
  184. #ifndef FALSE
  185. # define FALSE 0
  186. #endif
  187. /**Macro***********************************************************************
  188. Synopsis [Returns 1 if the two arguments are identical strings.]
  189. Description []
  190. SideEffects [none]
  191. SeeAlso []
  192. ******************************************************************************/
  193. #define STRING_EQUAL(s1,s2) (strcmp((s1),(s2)) == 0)
  194. /**AutomaticStart*************************************************************/
  195. /*---------------------------------------------------------------------------*/
  196. /* Function prototypes */
  197. /*---------------------------------------------------------------------------*/
  198. extern int Ntr_buildDDs (BnetNetwork *net, DdManager *dd, NtrOptions *option, BnetNetwork *net2);
  199. extern NtrPartTR * Ntr_buildTR (DdManager *dd, BnetNetwork *net, NtrOptions *option, int image);
  200. extern DdNode * Ntr_TransitiveClosure (DdManager *dd, NtrPartTR *TR, NtrOptions *option);
  201. extern int Ntr_Trav (DdManager *dd, BnetNetwork *net, NtrOptions *option);
  202. extern int Ntr_SCC (DdManager *dd, BnetNetwork *net, NtrOptions *option);
  203. extern int Ntr_ClosureTrav (DdManager *dd, BnetNetwork *net, NtrOptions *option);
  204. extern void Ntr_freeTR (DdManager *dd, NtrPartTR *TR);
  205. extern NtrPartTR * Ntr_cloneTR (NtrPartTR *TR);
  206. extern DdNode * Ntr_initState (DdManager *dd, BnetNetwork *net, NtrOptions *option);
  207. extern DdNode * Ntr_getStateCube (DdManager *dd, BnetNetwork *net, char *filename, int pr);
  208. extern int Ntr_Envelope (DdManager *dd, NtrPartTR *TR, FILE *dfp, NtrOptions *option);
  209. extern int Ntr_TestMinimization (DdManager *dd, BnetNetwork *net1, BnetNetwork *net2, NtrOptions *option);
  210. extern int Ntr_TestDensity (DdManager *dd, BnetNetwork *net1, NtrOptions *option);
  211. extern int Ntr_TestDecomp (DdManager *dd, BnetNetwork *net1, NtrOptions *option);
  212. extern int Ntr_VerifyEquivalence (DdManager *dd, BnetNetwork *net1, BnetNetwork *net2, NtrOptions *option);
  213. extern int Ntr_TestCofactorEstimate (DdManager * dd, BnetNetwork * net, NtrOptions * option);
  214. extern int Ntr_TestClipping (DdManager *dd, BnetNetwork *net1, BnetNetwork *net2, NtrOptions *option);
  215. extern int Ntr_TestEquivAndContain (DdManager *dd, BnetNetwork *net1, BnetNetwork *net2, NtrOptions *option);
  216. extern int Ntr_TestClosestCube (DdManager * dd, BnetNetwork * net, NtrOptions * option);
  217. extern int Ntr_TestTwoLiteralClauses (DdManager * dd, BnetNetwork * net1, NtrOptions * option);
  218. extern int Ntr_TestCharToVect(DdManager * dd, BnetNetwork * net1, NtrOptions * option);
  219. extern int Ntr_maxflow (DdManager *dd, BnetNetwork *net, NtrOptions *option);
  220. extern double Ntr_maximum01Flow (DdManager *bdd, DdNode *sx, DdNode *ty, DdNode *E, DdNode **F, DdNode **cut, DdNode **x, DdNode **y, DdNode **z, int n, int pr);
  221. extern int Ntr_testZDD (DdManager *dd, BnetNetwork *net, NtrOptions *option);
  222. extern int Ntr_testISOP (DdManager *dd, BnetNetwork *net, NtrOptions *option);
  223. extern NtrHeap * Ntr_InitHeap (int size);
  224. extern void Ntr_FreeHeap (NtrHeap *heap);
  225. extern int Ntr_HeapInsert (NtrHeap *heap, void *item, int key);
  226. extern int Ntr_HeapExtractMin (NtrHeap *heap, void *item, int *key);
  227. extern int Ntr_HeapCount (NtrHeap *heap);
  228. extern NtrHeap * Ntr_HeapClone (NtrHeap *source);
  229. extern int Ntr_TestHeap (NtrHeap *heap, int i);
  230. extern int Ntr_ShortestPaths (DdManager *dd, BnetNetwork *net, NtrOptions *option);
  231. /**AutomaticEnd***************************************************************/
  232. #ifdef __cplusplus
  233. }
  234. #endif
  235. #endif /* _NTR */