PySDD 1.0.7__cp315-cp315-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. pysdd/__init__.py +1 -0
  2. pysdd/__main__.py +19 -0
  3. pysdd/cli.py +261 -0
  4. pysdd/compiler_c.pxd +37 -0
  5. pysdd/fnf_c.pxd +17 -0
  6. pysdd/io_c.pxd +22 -0
  7. pysdd/iterator.py +223 -0
  8. pysdd/lib/libsdd-2.0/include/iterators.h +243 -0
  9. pysdd/lib/libsdd-2.0/include/macros.h +273 -0
  10. pysdd/lib/libsdd-2.0/include/parameters.h +71 -0
  11. pysdd/lib/libsdd-2.0/include/sdd.h +823 -0
  12. pysdd/lib/libsdd-2.0/include/stacks.h +86 -0
  13. pysdd/lib/libsdd-2.0/src/basic/computed.c +91 -0
  14. pysdd/lib/libsdd-2.0/src/basic/count_and_size.c +173 -0
  15. pysdd/lib/libsdd-2.0/src/basic/gc.c +104 -0
  16. pysdd/lib/libsdd-2.0/src/basic/hash.c +221 -0
  17. pysdd/lib/libsdd-2.0/src/basic/memory.c +180 -0
  18. pysdd/lib/libsdd-2.0/src/basic/multiply.c +209 -0
  19. pysdd/lib/libsdd-2.0/src/basic/nodes.c +174 -0
  20. pysdd/lib/libsdd-2.0/src/basic/partitions.c +351 -0
  21. pysdd/lib/libsdd-2.0/src/basic/references.c +79 -0
  22. pysdd/lib/libsdd-2.0/src/basic/replace.c +91 -0
  23. pysdd/lib/libsdd-2.0/src/basic/shadows.c +384 -0
  24. pysdd/lib/libsdd-2.0/src/basic/sort.c +148 -0
  25. pysdd/lib/libsdd-2.0/src/manager/copy.c +84 -0
  26. pysdd/lib/libsdd-2.0/src/manager/interface.c +411 -0
  27. pysdd/lib/libsdd-2.0/src/manager/manager.c +308 -0
  28. pysdd/lib/libsdd-2.0/src/manager/stats.c +121 -0
  29. pysdd/lib/libsdd-2.0/src/manager/variables.c +267 -0
  30. pysdd/lib/libsdd-2.0/src/sdds/apply.c +396 -0
  31. pysdd/lib/libsdd-2.0/src/sdds/bits.c +156 -0
  32. pysdd/lib/libsdd-2.0/src/sdds/cardinality.c +313 -0
  33. pysdd/lib/libsdd-2.0/src/sdds/condition.c +107 -0
  34. pysdd/lib/libsdd-2.0/src/sdds/copy.c +117 -0
  35. pysdd/lib/libsdd-2.0/src/sdds/count.c +78 -0
  36. pysdd/lib/libsdd-2.0/src/sdds/essential_vars.c +128 -0
  37. pysdd/lib/libsdd-2.0/src/sdds/exists.c +29 -0
  38. pysdd/lib/libsdd-2.0/src/sdds/exists_multiple.c +311 -0
  39. pysdd/lib/libsdd-2.0/src/sdds/exists_multiple_static.c +165 -0
  40. pysdd/lib/libsdd-2.0/src/sdds/forall.c +28 -0
  41. pysdd/lib/libsdd-2.0/src/sdds/io.c +448 -0
  42. pysdd/lib/libsdd-2.0/src/sdds/model_count.c +146 -0
  43. pysdd/lib/libsdd-2.0/src/sdds/rename_vars.c +113 -0
  44. pysdd/lib/libsdd-2.0/src/sdds/size.c +65 -0
  45. pysdd/lib/libsdd-2.0/src/sdds/wmc.c +412 -0
  46. pysdd/lib/libsdd-2.0/src/util.c +255 -0
  47. pysdd/lib/libsdd-2.0/src/verify.c +236 -0
  48. pysdd/lib/libsdd-2.0/src/version.c +14 -0
  49. pysdd/lib/libsdd-2.0/src/vtree_fragments/construction.c +329 -0
  50. pysdd/lib/libsdd-2.0/src/vtree_fragments/moves.c +100 -0
  51. pysdd/lib/libsdd-2.0/src/vtree_fragments/operations.c +302 -0
  52. pysdd/lib/libsdd-2.0/src/vtree_operations/cartesian_product.c +166 -0
  53. pysdd/lib/libsdd-2.0/src/vtree_operations/dissect.c +78 -0
  54. pysdd/lib/libsdd-2.0/src/vtree_operations/limits.c +237 -0
  55. pysdd/lib/libsdd-2.0/src/vtree_operations/op_left_rotate.c +143 -0
  56. pysdd/lib/libsdd-2.0/src/vtree_operations/op_right_rotate.c +150 -0
  57. pysdd/lib/libsdd-2.0/src/vtree_operations/op_swap.c +112 -0
  58. pysdd/lib/libsdd-2.0/src/vtree_operations/rollback.c +68 -0
  59. pysdd/lib/libsdd-2.0/src/vtree_operations/split.c +180 -0
  60. pysdd/lib/libsdd-2.0/src/vtree_operations/vtree_ops.h +48 -0
  61. pysdd/lib/libsdd-2.0/src/vtree_search/auto.c +186 -0
  62. pysdd/lib/libsdd-2.0/src/vtree_search/search.c +332 -0
  63. pysdd/lib/libsdd-2.0/src/vtree_search/state.c +127 -0
  64. pysdd/lib/libsdd-2.0/src/vtrees/compare.c +138 -0
  65. pysdd/lib/libsdd-2.0/src/vtrees/edit.c +199 -0
  66. pysdd/lib/libsdd-2.0/src/vtrees/io.c +207 -0
  67. pysdd/lib/libsdd-2.0/src/vtrees/maps.c +42 -0
  68. pysdd/lib/libsdd-2.0/src/vtrees/moves.c +156 -0
  69. pysdd/lib/libsdd-2.0/src/vtrees/static.c +270 -0
  70. pysdd/lib/libsdd-2.0/src/vtrees/vtree.c +197 -0
  71. pysdd/lib/sdd-2.0/include/compiler.h +104 -0
  72. pysdd/lib/sdd-2.0/include/fnf.h +13 -0
  73. pysdd/lib/sdd-2.0/include/io.h +11 -0
  74. pysdd/lib/sdd-2.0/include/sddapi.h +341 -0
  75. pysdd/lib/sdd-2.0/src/fnf/compiler.c +120 -0
  76. pysdd/lib/sdd-2.0/src/fnf/fnf.c +57 -0
  77. pysdd/lib/sdd-2.0/src/fnf/io.c +201 -0
  78. pysdd/lib/sdd-2.0/src/fnf/utils.c +72 -0
  79. pysdd/lib/sdd_extra/include/sddapi_extra.h +22 -0
  80. pysdd/sdd.cp315-win_amd64.pyd +0 -0
  81. pysdd/sdd.pyx +1808 -0
  82. pysdd/sddapi_c.pxd +241 -0
  83. pysdd/util.py +450 -0
  84. pysdd/wmcstochastic.py +188 -0
  85. pysdd-1.0.7.dist-info/METADATA +216 -0
  86. pysdd-1.0.7.dist-info/RECORD +90 -0
  87. pysdd-1.0.7.dist-info/WHEEL +5 -0
  88. pysdd-1.0.7.dist-info/entry_points.txt +2 -0
  89. pysdd-1.0.7.dist-info/licenses/LICENSE +13 -0
  90. pysdd-1.0.7.dist-info/top_level.txt +1 -0
@@ -0,0 +1,243 @@
1
+ /****************************************************************************************
2
+ * The Sentential Decision Diagram Package
3
+ * sdd version 2.0, January 8, 2018
4
+ * http://reasoning.cs.ucla.edu/sdd
5
+ ****************************************************************************************/
6
+
7
+ #ifndef ITERATORS_H_
8
+ #define ITERATORS_H_
9
+
10
+ /****************************************************************************************
11
+ * iterator over ALL vtree nodes (linked using ->next, ->prev, ->first and ->last)
12
+ ****************************************************************************************/
13
+
14
+ //iterates over each node V in a vtree rooted at R, executing code B for each node
15
+ //
16
+ //V: vtree node
17
+ //R: vtree root
18
+ //B: code
19
+ #define FOR_each_vtree_node(V,R,B) {\
20
+ Vtree* V = (R)->first; /* head of linked list */\
21
+ Vtree* _out = (R)->last->next; /* node following last node of vtree (can be NULL) */\
22
+ while(V!=_out) {\
23
+ assert(V);\
24
+ B; /* execute code */\
25
+ V = V->next; /* next node of vtree */\
26
+ }\
27
+ }
28
+
29
+ /****************************************************************************************
30
+ * iterator over INTERNAL vtree nodes (linked using ->next, ->prev, ->first and ->last)
31
+ *
32
+ * the nodes of a vtree linked list alternate between leaf and internal nodes, with
33
+ * the first and last nodes being leaves
34
+ ****************************************************************************************/
35
+
36
+ //iterates over each internal node V in a vtree rooted at R, executing code B for each node
37
+ //
38
+ //V: vtree node
39
+ //R: vtree root
40
+ //B: code
41
+ #define FOR_each_internal_vtree_node(V,R,B) {\
42
+ Vtree* V = (R)->first; /* first leaf node of vtree */\
43
+ Vtree* _last_leaf = (R)->last; /* last leaf node of vtree */\
44
+ while(V!=_last_leaf) {\
45
+ V = V->next; /* V is internal */\
46
+ assert(INTERNAL(V));\
47
+ B; /* execute code */\
48
+ V = V->next; /* V is leaf */\
49
+ assert(LEAF(V));\
50
+ }\
51
+ }
52
+
53
+ /****************************************************************************************
54
+ * iterator over LEAF vtree nodes (linked using ->next, ->prev, ->first and ->last)
55
+ *
56
+ * the nodes of a vtree linked list alternate between leaf and internal nodes, with
57
+ * the first and last nodes being leaves
58
+ ****************************************************************************************/
59
+
60
+ //iterates over each leaf node V in a vtree rooted at R, executing code B for each node
61
+ //
62
+ //V: vtree node
63
+ //R: vtree root
64
+ //B: code
65
+ #define FOR_each_leaf_vtree_node(V,R,B) {\
66
+ Vtree* V = (R)->first; /* first leaf node of vtree */\
67
+ Vtree* _last_leaf = (R)->last; /* last leaf node of vtree */\
68
+ while(V!=_last_leaf) {\
69
+ assert(LEAF(V));\
70
+ B; /* execute code */\
71
+ V = V->next->next; /* V is leaf */\
72
+ }\
73
+ assert(LEAF(V));\
74
+ B; /* execute code on last leaf */\
75
+ }
76
+
77
+ /****************************************************************************************
78
+ * iterator over ANCESTOR vtree nodes (visiting children before parents)
79
+ ****************************************************************************************/
80
+
81
+ //iterates over each ancestor V in a vtree rooted at R, executing code B for each node
82
+ //
83
+ //V: vtree node
84
+ //R: vtree root
85
+ //B: code
86
+ #define FOR_each_ancestral_vtree_node(V,R,B) {\
87
+ Vtree* V = (R)->parent;\
88
+ while(V) {\
89
+ B; /* execute code */\
90
+ V = V->parent;\
91
+ }\
92
+ }
93
+
94
+
95
+ /****************************************************************************************
96
+ * iterator over nodes normalized for a vtree
97
+ * (linked using the ->vtree_next and ->vtree_prev fields)
98
+ ****************************************************************************************/
99
+
100
+ //iterate over the sdd nodes normalized for vtree node V, executing code B for each node
101
+ //this iterator allows freeing sdd nodes or changing their ->vtree_next and ->vtree_prev
102
+ //fields in code B
103
+ //
104
+ //N: node
105
+ //V: vtree
106
+ //B: code
107
+ #define FOR_each_sdd_node_normalized_for(N,V,B) {\
108
+ SddNode* N = (V)->nodes; /* head of linked list */\
109
+ while(N) {\
110
+ /* save N->vtree_next in case N is freed or N->vtree_next is changed in code B */\
111
+ SddNode* _next = N->vtree_next;\
112
+ /* execute code */\
113
+ B;\
114
+ /* advance to next node */\
115
+ N = _next;\
116
+ }\
117
+ }
118
+
119
+ /****************************************************************************************
120
+ * iterator over sdd nodes normalized for nodes in vtree
121
+ ****************************************************************************************/
122
+
123
+ //N: node
124
+ //V: vtree
125
+ //B: code
126
+ #define FOR_each_decomposition_in(N,V,B) FOR_each_internal_vtree_node(v,V,FOR_each_sdd_node_normalized_for(N,v,B))
127
+ #define FOR_each_decomposition_above(N,V,B) FOR_each_ancestral_vtree_node(v,V,FOR_each_sdd_node_normalized_for(N,v,B))
128
+ #define FOR_each_literal_in(N,V,B) FOR_each_leaf_vtree_node(v,V,FOR_each_sdd_node_normalized_for(N,v,B))
129
+
130
+ /****************************************************************************************
131
+ * iterator for sdd nodes (linked using the ->next field)
132
+ ****************************************************************************************/
133
+
134
+ //this iterator allows freeing nodes or changing their ->next field in code B
135
+ //
136
+ //N: node
137
+ //L: head of linked list (node)
138
+ //B: code
139
+ #define FOR_each_linked_node(N,L,B) {\
140
+ SddNode* N = L; /* head of linked list */\
141
+ while(N) {\
142
+ /* save N->next in case N is freed or N->next is changed in code B */\
143
+ SddNode* _next = N->next;\
144
+ /* execute code */\
145
+ B;\
146
+ /* advance to next node */\
147
+ N = _next;\
148
+ }\
149
+ }
150
+
151
+ /****************************************************************************************
152
+ * iterator for unique nodes
153
+ ****************************************************************************************/
154
+
155
+ //iterates over unique nodes of manager, executing a bit of code for each node
156
+ //this iterator allows freeing nodes or changing their ->next field in code B
157
+ //
158
+ //N: node
159
+ //M: manager
160
+ //B: code to be executed for each node (references the variable E)
161
+ #define FOR_each_unique_node(N,M,B) {\
162
+ SddHash* H = M->unique_nodes;\
163
+ if(H->count) {\
164
+ SddSize _size = H->size;\
165
+ SddNode** _clists = H->clists;\
166
+ while(_size--) {\
167
+ SddNode* N = *_clists++;\
168
+ while(N) {\
169
+ /* save next in case N is freed or N->next is changed in code B */\
170
+ SddNode* _next = N->next;\
171
+ /* execute code */\
172
+ B;\
173
+ /* advance to next entry in hash table */\
174
+ N = _next;\
175
+ }\
176
+ }\
177
+ }\
178
+ }
179
+
180
+ /****************************************************************************************
181
+ * macros for iterating over primes, subs and elements of an sdd node
182
+ ****************************************************************************************/
183
+
184
+ //iterate over elements, executing code B for each element
185
+ //
186
+ //P: prime
187
+ //S: sub
188
+ //C: element count
189
+ //ES: elements array
190
+ //B: code
191
+ #define FOR_each_prime_sub_of_elements(P,S,C,ES,B) {\
192
+ for(SddElement* _e=ES; _e<(ES)+(C); _e++) {\
193
+ SddNode* P = _e->prime;\
194
+ SddNode* S = _e->sub;\
195
+ /* execute code */\
196
+ B;\
197
+ }\
198
+ }
199
+
200
+ //iterate over primes and subs P/S of sdd node N, executing code B for each P/S pair
201
+ //
202
+ //P: prime
203
+ //S: sub
204
+ //N: sdd node
205
+ //B: code
206
+ #define FOR_each_prime_sub_of_node(P,S,N,B) {\
207
+ assert(IS_DECOMPOSITION(N));\
208
+ FOR_each_prime_sub_of_elements(P,S,(N)->size,ELEMENTS_OF(N),B)\
209
+ }
210
+
211
+ //iterate over primes P of sdd node N, executing code B for each prime
212
+ //
213
+ //P: prime
214
+ //N: sdd node
215
+ //B: code
216
+ #define FOR_each_prime_of_node(P,N,B) {\
217
+ assert(IS_DECOMPOSITION(N));\
218
+ for(SddElement* _e=ELEMENTS_OF(N); _e<ELEMENTS_OF(N)+(N)->size; _e++) {\
219
+ SddNode* P = _e->prime;\
220
+ /* execute code */\
221
+ B;\
222
+ }\
223
+ }
224
+
225
+ //iterate over subs S of sdd node N, executing code B for each sub
226
+ //
227
+ //S: sub
228
+ //N: sdd node
229
+ //B: code
230
+ #define FOR_each_sub_of_node(S,N,B) {\
231
+ assert(IS_DECOMPOSITION(N));\
232
+ for(SddElement* _e=ELEMENTS_OF(N); _e<ELEMENTS_OF(N)+(N)->size; _e++) {\
233
+ SddNode* S = _e->sub;\
234
+ /* execute code */\
235
+ B;\
236
+ }\
237
+ }
238
+
239
+ #endif // ITERATORS_H_
240
+
241
+ /****************************************************************************************
242
+ * end
243
+ ****************************************************************************************/
@@ -0,0 +1,273 @@
1
+ /****************************************************************************************
2
+ * The Sentential Decision Diagram Package
3
+ * sdd version 2.0, January 8, 2018
4
+ * http://reasoning.cs.ucla.edu/sdd
5
+ * Modified by DTAI.
6
+ ****************************************************************************************/
7
+
8
+ #ifndef MACROS_H_
9
+ #define MACROS_H_
10
+
11
+ /****************************************************************************************
12
+ * error checks and messages
13
+ ****************************************************************************************/
14
+
15
+ #define ERR_MSG_GC "\nerror in %s: accessing sdd node that has been garbage collected\n"
16
+ #define ERR_MSG_DEREF "\nerror in %s: more dereferences than references to an sdd node\n"
17
+ #define ERR_MSG_INVALID_VAR "\nerror in %s: invalid var index\n"
18
+ #define ERR_MSG_VTREE "\nerror in %s: unrecognized vtree type\n"
19
+ #define ERR_MSG_INPUT_VTREE "\nerror in %s: must supply a vtree\n"
20
+ #define ERR_MSG_ONE_VAR "\nerror in %s: manager must have at least one variable\n"
21
+ #define ERR_MSG_TWO_VARS "\nerror in %s: manager must have at least two variables\n"
22
+ #define ERR_MSG_REM_VAR "\nerror in %s: removing a variable that is currently being used\n"
23
+ #define ERR_MSG_MOV_VAR "\nerror in %s: moving a variable that is currently being used\n"
24
+ #define ERR_MSG_NODE_ITR "\nerror in %s: argument not a decision node\n"
25
+ #define ERR_MSG_NODE_LIT "\nerror in %s: argument not a literal node\n"
26
+ #define ERR_MSG_WMC "\nerror in %s: WMC manager is no longer valid due to automatic SDD minimization\n"
27
+ #define ERR_MSG_FRG_N "\nerror in %s: fragment cannot be moved to the next state while in goto mode\n"
28
+ #define ERR_MSG_FRG_G "\nerror in %s: fragment cannot by moved to the given state while in next mode\n"
29
+ #define ERR_MSG_FRG_R "\nerror in %s: fragment cannot be rewinded while in goto mode\n"
30
+ #define FULL_DEBUG FALSE
31
+
32
+ //if condition C is met, print error message M that materialized in function F
33
+ #define CHECK_ERROR(C,M,F) if(C) { fprintf(stderr,M,F); exit(1); }
34
+
35
+ /****************************************************************************************
36
+ * tests and lookups
37
+ ****************************************************************************************/
38
+
39
+ //OP: constant, which is either CONJOIN or DISJOIN
40
+ //M: manager
41
+ #define ZERO(M,OP) (OP==CONJOIN? (M)->false_sdd: (M)->true_sdd)
42
+ #define ONE(M,OP) (OP==CONJOIN? (M)->true_sdd: (M)->false_sdd)
43
+
44
+ //OP: constant, which is either CONJOIN or DISJOIN
45
+ //N: node
46
+ #define IS_ZERO(N,OP) (OP==CONJOIN? (N)->type==FALSE: (N)->type==TRUE)
47
+ #define IS_ONE(N,OP) (OP==CONJOIN? (N)->type==TRUE: (N)->type==FALSE)
48
+
49
+ //OP: constant, which is either CONJOIN or DISJOIN
50
+ //N: sdd node
51
+ #define IS_FALSE(N) ((N)->type==FALSE)
52
+ #define IS_TRUE(N) ((N)->type==TRUE)
53
+ #define IS_LITERAL(N) ((N)->type==LITERAL)
54
+ #define IS_DECOMPOSITION(N) ((N)->type==DECOMPOSITION)
55
+
56
+ //checks that an sdd node is neither true nor false
57
+ //N: sdd node
58
+ #define NON_TRIVIAL(N) ((N)->type!=FALSE && (N)->type!=TRUE)
59
+ #define TRIVIAL(N) ((N)->type==FALSE || (N)->type==TRUE)
60
+
61
+ //checks whether node is on the gc_list (i.e., has been garbage collected)
62
+ //N: Sdd node
63
+ #define GC_NODE(N) (N->id==0)
64
+
65
+ //recovering fields of nodes
66
+ #define ELEMENTS_OF(N) (N)->alpha.elements
67
+ #define LITERAL_OF(N) (N)->alpha.literal
68
+ #define VAR_OF(N) llabs((N)->alpha.literal)
69
+
70
+ //checking whether an sdd node is live
71
+ //terminal sdds are always live
72
+ #define LIVE(N) ((N)->type!=DECOMPOSITION || (N)->ref_count)
73
+ #define DEAD(N) ((N)->type==DECOMPOSITION && (N)->ref_count==0)
74
+
75
+ //tests whether a variable index is valid
76
+ //V: var index
77
+ //M: manager
78
+ #define VALID_VAR(V,M) (1 <= V && V <= M->var_count)
79
+
80
+ //a function is provided for this in the sddapi, but a macro is used internally for efficiency
81
+ #define LEAF(V) ((V)->left==NULL)
82
+ #define INTERNAL(V) ((V)->left)
83
+
84
+ //checks whether an sdd node N could be a valid prime/sub for vtree V
85
+ #define OK_PRIME(P,V) (NON_TRIVIAL(P) && sdd_vtree_is_sub((P)->vtree,(V)->left))
86
+ #define OK_SUB(S,V) (TRIVIAL(S) || sdd_vtree_is_sub((S)->vtree,(V)->right))
87
+
88
+ #define Assert(C)\
89
+ if(!(C)) {\
90
+ void print_trace ();\
91
+ print_trace();\
92
+ assert(C);\
93
+ }
94
+
95
+ /****************************************************************************************
96
+ * macro for constructing sdd nodes (see basic/partitions.c)
97
+ ****************************************************************************************/
98
+
99
+ //sets N to sdd node with a compression of the elements added in code B
100
+ //if sdd node has form T.n, set N to n (trimming rule 1)
101
+ //if sdd node has form n.T + ~n.F, set N to n (trimming rule 2)
102
+ //
103
+ //the resulting node will be normalized to vtree V unless one of the trimming rules applies
104
+ //
105
+ //N: node
106
+ //V: vtree
107
+ //M: manager
108
+ //B: code (uses DECLARE_element(prime,sub,manager) to add elements)
109
+ //
110
+ //this macro may invoke apply
111
+ #define GET_node_from_partition(N,V,M,B) {\
112
+ void START_partition(struct sdd_manager_t* manager);\
113
+ void DECLARE_element(struct sdd_node_t* prime, struct sdd_node_t* sub, struct vtree_t* vtree, struct sdd_manager_t* manager);\
114
+ SddNode* GET_node_of_partition(struct vtree_t* vtree, struct sdd_manager_t* manager, int limited);\
115
+ START_partition(M);\
116
+ B; /* execute code */\
117
+ N = GET_node_of_partition(V,M,0);\
118
+ assert(N);\
119
+ }
120
+
121
+ //this is used ONLY inside GET_node_from_partition_limited
122
+ //C: test for exceeding limit and aborting GET_node_from_partition_limited
123
+ #define ABORT_partition_if(C) if(C) goto abort
124
+
125
+ //T: time limit
126
+ //this macro may invoke apply
127
+ #define GET_node_from_partition_limited(N,V,M,T,B) {\
128
+ void START_partition(struct sdd_manager_t* manager);\
129
+ void DECLARE_element(struct sdd_node_t* prime, struct sdd_node_t* sub, struct vtree_t* vtree, struct sdd_manager_t* manager);\
130
+ void ABORT_partition(struct sdd_manager_t* manager);\
131
+ SddNode* GET_node_of_partition(struct vtree_t* vtree, struct sdd_manager_t* manager, int limited);\
132
+ START_partition(M);\
133
+ B; /* execute code: may jump to abort */\
134
+ N = GET_node_of_partition(V,M,T); /* N may be NULL */\
135
+ goto done;\
136
+ abort:\
137
+ N = NULL;\
138
+ ABORT_partition(M);\
139
+ done:\
140
+ /* N may or may not be NULL */\
141
+ ;\
142
+ }
143
+
144
+ //sets N to sdd node with elements declared in code B
145
+ //assumes elements already compressed, cannot be trimmed and normalized for vtree
146
+ //
147
+ //N: node
148
+ //V: vtree
149
+ //M: manager
150
+ //B: code (uses DECLARE_compressed_element(prime,sub,manager) to add elements)
151
+ //
152
+ //this macro will not invoke apply
153
+ #define GET_node_from_compressed_partition(N,V,M,B) {\
154
+ void START_partition(struct sdd_manager_t* manager);\
155
+ void DECLARE_compressed_element(struct sdd_node_t* prime, struct sdd_node_t* sub, struct vtree_t* vtree, struct sdd_manager_t* manager);\
156
+ SddNode* GET_node_of_compressed_partition(struct vtree_t* vtree, struct sdd_manager_t* manager);\
157
+ START_partition(M);\
158
+ B; /* execute code */\
159
+ N = GET_node_of_compressed_partition(V,M);\
160
+ }
161
+
162
+ /****************************************************************************************
163
+ * macro for auto gc and search
164
+ ****************************************************************************************/
165
+
166
+ //ensures that code B of manager M will run without ever invoking vtree search
167
+ //
168
+ //M: manager
169
+ //B: code
170
+ #define WITH_no_auto_mode(M,B) {\
171
+ int _mode = M->auto_gc_and_search_on; /* save auto-search mode */\
172
+ M->auto_gc_and_search_on = 0; /* deactivate auto-search */\
173
+ B; /* execute code */\
174
+ M->auto_gc_and_search_on = _mode; /* recover auto-search mode */\
175
+ }
176
+
177
+ //ensures that if code B of manager M invokes gc or vtree search, then gc/search
178
+ //will only take place locally (and not globally)
179
+ //
180
+ //M: manager
181
+ //B: code
182
+ #define WITH_local_auto_mode(M,B) {\
183
+ int _mode = M->auto_local_gc_and_search_on;\
184
+ M->auto_local_gc_and_search_on = 1;\
185
+ B; /* execute code */\
186
+ M->auto_local_gc_and_search_on = _mode;\
187
+ }
188
+
189
+ /****************************************************************************************
190
+ * macro for timing code
191
+ ****************************************************************************************/
192
+
193
+ //C: variable that accumulates time
194
+ //B: code
195
+ #define WITH_timing(C,B) {\
196
+ clock_t start_time = clock();\
197
+ B; /* execute code */\
198
+ C += (clock()-start_time); /* accumulate time*/\
199
+ }
200
+
201
+ /****************************************************************************************
202
+ * memory allocation, with error catching
203
+ ****************************************************************************************/
204
+
205
+ //catching malloc and calloc errors
206
+ #define MALLOC(variable,type,message) {\
207
+ variable = (type*) malloc(sizeof(type));\
208
+ if(variable==NULL) {\
209
+ fprintf(stderr,"\nmalloc failed in %s\n",message);\
210
+ exit(1);\
211
+ }\
212
+ }
213
+
214
+ #define CALLOC(variable,type,count,message) {\
215
+ if(count==0) variable = NULL;\
216
+ else {\
217
+ if((variable=(type*) calloc(count,sizeof(type)))==NULL) {\
218
+ fprintf(stderr,"\ncalloc failed in %s\n",message);\
219
+ exit(1);\
220
+ }\
221
+ }\
222
+ }
223
+
224
+ #define REALLOC(variable,type,count,message) {\
225
+ variable = (type*) realloc(variable,(count)*sizeof(type));\
226
+ if(variable==NULL) {\
227
+ fprintf(stderr,"\nrealloc failed in %s\n",message);\
228
+ exit(1);\
229
+ }\
230
+ }
231
+
232
+
233
+ /****************************************************************************************
234
+ * general utilities
235
+ ****************************************************************************************/
236
+
237
+ //compute max of A and B
238
+ //
239
+ //A: number
240
+ //B: number
241
+ #define MAX(A,B) (((A)>(B))?(A):(B))
242
+
243
+ //compute min of A and B
244
+ //
245
+ //A: number
246
+ //B: number
247
+ #define MIN(A,B) (((A)<(B))?(A):(B))
248
+
249
+ //swapping the values of two variables
250
+ //
251
+ //T: type of vars
252
+ //V1: first var
253
+ //V2: second var
254
+ #define SWAP(T,V1,V2) { T V = V1; V1 = V2; V2 = V; }
255
+
256
+ //compute the space in megabytes for N members of type T
257
+ //
258
+ //N: number of elements of type T
259
+ //T: type
260
+ #define TYPE2MB(N,T) (((float)(N)*sizeof(T))/(1024*1024))
261
+
262
+ //add value to array whose elements are of type and has size
263
+ #define ADD_TO_ARRAY(type,value,array,size) {\
264
+ ++(size);\
265
+ REALLOC(array,type,size,"ADD_TO_ARRAY");\
266
+ array[(size)-1] = value;\
267
+ }
268
+
269
+ #endif // MACROS_H_
270
+
271
+ /****************************************************************************************
272
+ * end
273
+ ****************************************************************************************/
@@ -0,0 +1,71 @@
1
+ /****************************************************************************************
2
+ * The Sentential Decision Diagram Package
3
+ * sdd version 2.0, January 8, 2018
4
+ * http://reasoning.cs.ucla.edu/sdd
5
+ ****************************************************************************************/
6
+
7
+ #ifndef PARAMETERS_H_
8
+ #define PARAMETERS_H_
9
+
10
+ /****************************************************************************************
11
+ * garbage collection
12
+ ****************************************************************************************/
13
+
14
+ //buckets for storing gc'd nodes according to their size
15
+ #define GC_BUCKETS_COUNT 4
16
+
17
+ /****************************************************************************************
18
+ * manager stacks
19
+ ****************************************************************************************/
20
+
21
+ #define INITIAL_SIZE_ELEMENT_STACK 2048
22
+ #define INITIAL_SIZE_COMPRESSION_STACK 2048
23
+ #define INITIAL_SIZE_NODE_BUFFER 2048
24
+
25
+ /****************************************************************************************
26
+ * hash table parameters (for unique nodes)
27
+ ****************************************************************************************/
28
+
29
+ //default qsize of unique node table
30
+ #define INITIAL_SIZE_UNIQUE_NODE_TABLE 0
31
+
32
+ //number of lookups to trigger check for resize
33
+ #define AGE_BEFORE_HASH_RESIZE_CHECK 100
34
+ //number of entries over size that would trigger an increase of hash size
35
+ #define LOAD_TO_INCREASE_HASH_SIZE 0.80
36
+ //number of entries over size that would trigger a decrease of hash size
37
+ #define LOAD_TO_DECREASE_HASH_SIZE 0.05
38
+
39
+ /****************************************************************************************
40
+ * computation cache parameters
41
+ ****************************************************************************************/
42
+
43
+ //640007, 1280023, 2560021, 5000011
44
+ #define COMPUTED_CACHE_SIZE 2560021
45
+
46
+ /****************************************************************************************
47
+ * vtree search options
48
+ ****************************************************************************************/
49
+
50
+ //these parameters haver setter functions
51
+ #define VTREE_SEARCH_TIME_LIMIT (clock_t) 180*CLOCKS_PER_SEC
52
+ #define VTREE_FRAGMENT_TIME_LIMIT (clock_t) 60*CLOCKS_PER_SEC
53
+ #define VTREE_OP_TIME_LIMIT (clock_t) 30*CLOCKS_PER_SEC
54
+ #define VTREE_APPLY_TIME_LIMIT (clock_t) 10*CLOCKS_PER_SEC
55
+ #define VTREE_OP_SIZE_LIMIT 1.2
56
+ #define VTREE_OP_MEMORY_LIMIT 3.0
57
+ #define INITIAL_CONVERGENCE_THRESHOLD 1.0
58
+ #define CARTESIAN_PRODUCT_LIMIT 8*1024
59
+
60
+ //these parameters do not have setter functions
61
+ #define LIMITS_CHECK_FREQUENCY 100
62
+ #define VTREE_OP_SIZE_MIN 16
63
+ #define VTREE_OP_MEMORY_MIN 100.0
64
+
65
+ #define FRAGMENT_SEARCH_BACKWARD 0
66
+
67
+ #endif // PARAMETERS_H_
68
+
69
+ /****************************************************************************************
70
+ * end
71
+ ****************************************************************************************/