Debian Codegraph @

libbrial/include/polybori/routines/pbori_algo_int.h

raw symbols SCIP
1 // -*- c++ -*-cxx . . $ `<file>/libbrial/include/polybori/routines/pbori_algo_int.h`/
2 //*****************************************************************************
3 /** @file pbori_algo_int.h
4 *
5 * @author Alexander Dreyer
6 * @date 2006-04-07
7 *
8 * This file includes some templates of simple transformations and similar
9 * procedures.
10 *
11 * @par Copyright:
12 * (c) 2006 by The PolyBoRi Team
13 **/
14 //*****************************************************************************
15
16 #ifndef polybori_routines_pbori_algo_int_h_
17 #define polybori_routines_pbori_algo_int_h_cxx . . $ `libbrial/include/polybori/routines/pbori_algo_int.h:17:9`!
18
19 // include polybori's definitions
20 #include <polybori/pbori_defs.h>cxx . . $ `<file>/libbrial/include/polybori/pbori_defs.h`/
21
22 // get polybori's functionals
23 #include "pbori_func.h"cxx . . $ `<file>/libbrial/include/polybori/routines/pbori_func.h`/
24 #include <polybori/iterators/CCuddNavigator.h>cxx . . $ `<file>/libbrial/include/polybori/iterators/CCuddNavigator.h`/
25 #include <polybori/cudd/cudd.h>cxx . . $ `<file>/libbrial/include/polybori/cudd/cudd.h`/
26
27 BEGIN_NAMESPACE_PBORIcxx . . $ `libbrial/include/polybori/pbori_defs.h:74:11`!
28
29
30
31 inline void
32 inc_refcxx . . $ polybori/inc_ref(bd0a81bf0c53af16).(DdNode* node) {
33 PBORI_PREFIXcxx . . $ `libbrial/include/polybori/cudd/prefix.h:27:9`!(Cudd_Ref)(node);
34 }
35
36 template<class NaviType>
37 inline void
38 inc_refcxx . . $ polybori/inc_ref(77d9f17553126ecb).(const NaviType & navi) {
39 navi.incRef();
40 }
41
42 inline void
43 dec_refcxx . . $ polybori/dec_ref(bd0a81bf0c53af16).(DdNode* node) {
44 PBORI_PREFIXcxx . . $ `libbrial/include/polybori/cudd/prefix.h:27:9`!(Cudd_Deref)(node);
45 }
46
47 template<class NaviType>
48 inline void
49 dec_refcxx . . $ polybori/dec_ref(77d9f17553126ecb).(const NaviType & navi) {
50 navi.decRef();
51 }
52
53 inline DdNode*
54 do_get_nodecxx . . $ polybori/do_get_node(ccac6ba3ddc18f4d).(DdNode* node) {
55 return node;
56 }
57
58 template<class NaviType>
59 inline DdNode*
60 do_get_nodecxx . . $ polybori/do_get_node(f71d95c4d8e51049).(const NaviType & navi) {
61 return navi.getNode();
62 }
63
64 template <class MgrType>
65 inline void
66 recursive_dec_refcxx . . $ polybori/recursive_dec_ref(8235aa10ba6f612a).(const MgrType& mgr, DdNode* node) {
67 PBORI_PREFIXcxx . . $ `libbrial/include/polybori/cudd/prefix.h:27:9`!(Cudd_RecursiveDerefZdd)(mgr, node);
68 }
69
70 template <class MgrType, class NaviType>
71 inline void
72 recursive_dec_refcxx . . $ polybori/recursive_dec_ref(13c11f7bd0e7e3d2).(const MgrType& mgr, const NaviType & navi) {
73 navi.recursiveDecRef(mgr);
74 }
75
76 // template<class NaviType, class SizeType, class ManagerType>
77 // NaviType
78 // multiples_of_one_term(NaviType navi, SizeType nmax, ManagerType& man){
79
80
81 // std::vector<int> indices (PBORI_PREFIX(Cudd_SupportSize)(man,navi));
82 // std::vector<int>::iterator iter(indices.begin());
83
84 // NaviType multiples = navi;
85
86 // while(!multiples.isConstant()) {
87 // *iter = *multiples;
88 // multiples.incrementThen();
89 // ++iter;
90 // }
91
92 // std::vector<int>::const_reverse_iterator start(indices.rbegin()),
93 // finish(indices.rend());
94
95 // // int nmax = dd.nVariables();
96
97 // PBORI_PREFIX(Cudd_Ref)(multiples);
98 // NaviType emptyset = navi.elseBranch();
99
100 // NaviType tmp;
101 // SizeType i = nmax-1;
102
103 // while(start != finish){
104
105 // while ((idxStart != idxFinish) && (*idxStart > *start))
106 // // while(i > *start) {
107
108 // tmp = cuddZddGetNode(man, i, multiples, multiples);
109 // PBORI_PREFIX(Cudd_Ref)(tmp);
110 // PBORI_PREFIX(Cudd_Deref)(multiples);
111 // multiples = tmp;
112 // --i;
113 // }
114 // tmp = cuddZddGetNode(man, i, multiples, emptyset);
115 // PBORI_PREFIX(Cudd_Ref)(tmp);
116 // PBORI_PREFIX(Cudd_Deref)(multiples);
117 // multiples = tmp;
118 // --i;
119 // ++start;
120 // }
121
122 // return multiples;
123 // }
124
125
126 template<class NaviType, class ReverseIterator, class DDOperations>
127 NaviType
128 indexed_term_multiplescxx . . $ polybori/indexed_term_multiples(8ca39c9653f9db3c).(NaviType navi,
129 ReverseIterator idxStart, ReverseIterator idxFinish,
130 const DDOperations& apply){
131
132 typedef typename NaviType::value_type idx_typecxx . . $ polybori/indexed_term_multiples(8ca39c9653f9db3c).idx_type#;
133 typedef typename stdcxx . . $ std/::vectorcxx . . $ std/vector#<idx_typecxx . . $ polybori/indexed_term_multiples(8ca39c9653f9db3c).idx_type#> vector_typecxx . . $ polybori/indexed_term_multiples(8ca39c9653f9db3c).vector_type#;
134 typedef typename vector_typecxx . . $ polybori/indexed_term_multiples(8ca39c9653f9db3c).vector_type#::iterator iteratorcxx . . $ polybori/indexed_term_multiples(8ca39c9653f9db3c).iterator#;
135 typedef typename vector_typecxx . . $ polybori/indexed_term_multiples(8ca39c9653f9db3c).vector_type#::const_reverse_iterator const_reverse_iteratorcxx . . $ polybori/indexed_term_multiples(8ca39c9653f9db3c).const_reverse_iterator#;
136
137 vector_typecxx . . $ polybori/indexed_term_multiples(8ca39c9653f9db3c).vector_type# indices(apply.nSupport(navi));
138 iteratorcxx . . $ polybori/indexed_term_multiples(8ca39c9653f9db3c).iterator# iter(indices.begincxx . . $ std/vector#begin(55a6de06420d4903).());
139
140 NaviType multiples = navi;
141
142 while(!multiples.isConstant()) {
143 *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).iter = *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).multiples;
144 multiples.incrementThen();
145 ++iter;
146 }
147
148 const_reverse_iteratorcxx . . $ polybori/indexed_term_multiples(8ca39c9653f9db3c).const_reverse_iterator# start(indices.rbegincxx . . $ std/vector#rbegin(4f1ab9f89f58444d).()),
149 finish(indices.rendcxx . . $ std/vector#rend(4f1ab9f89f58444d).());
150
151
152 inc_refcxx . . $ polybori/inc_ref(77d9f17553126ecb).(multiples);
153
154 while(start !=cxx . . $ polybori/`operator!=`(166981e292dfc570). finish){
155
156 while( (idxStart !=cxx . . $ polybori/`operator!=`(166981e292dfc570). idxFinish) && (*cxx . . $ polybori/`operator*`(d630c30f8681b4d2).idxStart >cxx . . $ polybori/`operator>`(677edc2de9f9cb19). *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).start) ) {
157 apply.multiplesAssign(multiples, *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).idxStart);
158 ++idxStart;
159 }
160 apply.productAssign(multiples, *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).start);
161 if(idxStart !=cxx . . $ polybori/`operator!=`(166981e292dfc570). idxFinish)
162 ++idxStart;
163
164 ++start;
165 }
166
167 return multiples;
168 }
169
170
171 template <class NaviType>
172 bool
173 is_reducible_bycxx . . $ polybori/is_reducible_by(780fb9bd2d2dda6f).(NaviType first, NaviType second){
174
175 while(!second.isConstant()){
176 while( (!first.isConstant()) && (*cxx . . $ polybori/`operator*`(d630c30f8681b4d2).first <cxx . . $ polybori/`operator<`(677edc2de9f9cb19). *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).second))
177 first.incrementThen();
178 if(*cxx . . $ polybori/`operator*`(d630c30f8681b4d2).first !=cxx . . $ polybori/`operator!=`(166981e292dfc570). *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).second)
179 return false;
180 second.incrementThen();
181 }
182 return true;
183 }
184
185 template<class NaviType, class ReverseIterator, class DDOperations>
186 NaviType
187 minimal_of_two_termscxx . . $ polybori/minimal_of_two_terms(dc4a053fc2f7eb4b).(NaviType navi, NaviType& multiples,
188 ReverseIterator idxStart, ReverseIterator idxFinish,
189 const DDOperations& apply){
190
191 typedef typename NaviType::value_type idx_typecxx . . $ polybori/minimal_of_two_terms(dc4a053fc2f7eb4b).idx_type#;
192 typedef typename stdcxx . . $ std/::vectorcxx . . $ std/vector#<idx_typecxx . . $ polybori/minimal_of_two_terms(dc4a053fc2f7eb4b).idx_type#> vector_typecxx . . $ polybori/minimal_of_two_terms(dc4a053fc2f7eb4b).vector_type#;
193 typedef typename vector_typecxx . . $ polybori/minimal_of_two_terms(dc4a053fc2f7eb4b).vector_type#::size_type size_typecxx . . $ polybori/minimal_of_two_terms(dc4a053fc2f7eb4b).size_type#;
194 typedef typename vector_typecxx . . $ polybori/minimal_of_two_terms(dc4a053fc2f7eb4b).vector_type#::const_reverse_iterator const_reverse_iteratorcxx . . $ polybori/minimal_of_two_terms(dc4a053fc2f7eb4b).const_reverse_iterator#;
195
196 // std::cout <<"2s ";
197
198
199 size_typecxx . . $ polybori/minimal_of_two_terms(dc4a053fc2f7eb4b).size_type# nmax = apply.nSupport(navi);
200 vector_typecxx . . $ polybori/minimal_of_two_terms(dc4a053fc2f7eb4b).vector_type# thenIdx(nmax), elseIdx(nmax);
201
202 thenIdx.resizecxx . . $ std/vector#resize(2c44cd906ae4e829).(0);
203 elseIdx.resizecxx . . $ std/vector#resize(2c44cd906ae4e829).(0);
204
205 NaviType thenNavi = navi;
206 NaviType elseNavi = navi;
207
208 // See CCuddLastIterator
209 NaviType tmp(elseNavi);
210 elseNavi.incrementElse();
211
212 while(!elseNavi.isConstant()){
213 tmp = elseNavi;
214 elseNavi.incrementElse();
215 }
216 if(elseNavi.isEmpty())
217 elseNavi = tmp;
218
219 // std::cout <<"TH "<<*thenNavi <<" "<<*elseNavi<< ":";
220
221 bool isReducible = true;
222 while (isReducible && !thenNavi.isConstant() && !elseNavi.isConstant()){
223
224 while( !thenNavi.isConstant() && (*cxx . . $ polybori/`operator*`(d630c30f8681b4d2).thenNavi <cxx . . $ polybori/`operator<`(677edc2de9f9cb19). *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).elseNavi)) {
225 // std::cout <<"th "<<*thenNavi <<" "<<*elseNavi<< ":";
226
227 // apply.print(thenNavi);
228 // apply.print(elseNavi);
229 thenIdx.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(*cxx . . $ polybori/`operator*`(d630c30f8681b4d2).thenNavi);
230 thenNavi.incrementThen();
231 }
232
233 if(!thenNavi.isConstant() && (*cxx . . $ polybori/`operator*`(d630c30f8681b4d2).thenNavi ==cxx . . $ polybori/`operator==`(166981e292dfc570). *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).elseNavi) ){
234 thenIdx.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(*cxx . . $ polybori/`operator*`(d630c30f8681b4d2).thenNavi);
235 thenNavi.incrementThen();
236 }
237 else
238 isReducible = false;
239 // std::cout <<""<<isReducible << thenNavi.isConstant()<<std::endl;
240
241 elseIdx.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(*cxx . . $ polybori/`operator*`(d630c30f8681b4d2).elseNavi);
242
243 // next on last path
244 elseNavi.incrementThen();
245 if( !elseNavi.isConstant() ) { // if still in interior of a path
246
247 tmp = elseNavi; // store copy of *this
248 elseNavi.incrementElse(); // go in direction of last term, if possible
249
250 // restore previous value, of else branch was invalid
251 if( elseNavi.isEmpty() )
252 elseNavi = tmp;
253
254 }
255 }
256
257
258 NaviType elseTail, elseMult;
259 apply.assign(elseTail, elseNavi);/// !!!!!!!!!!!!
260 /// elseTail = elseNavi;
261
262 // int initref = ((DdNode*)elseNavi)->ref;
263 // std::cout << ((DdNode*)elseNavi)->ref <<std::endl;
264 if (!elseNavi.isConstant()) {
265 isReducible = false;
266 elseMult =
267 indexed_term_multiplescxx . . $ polybori/indexed_term_multiples(8ca39c9653f9db3c).(elseTail, idxStart, idxFinish, apply);
268 // if(elseMult==elseTail)
269 // PBORI_PREFIX(Cudd_Deref)(elseMult);
270 }
271 else {
272 /// PBORI_PREFIX(Cudd_Ref)(elseTail);
273 ///!1 elseMult = elseTail;
274 apply.assign(elseMult, elseTail);///
275 }
276
277 NaviType tmp2 = prepend_multiples_wrt_indices(elseMult, *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).navi,
278 idxStart, idxFinish, apply);
279
280 tmp2.incRef();
281 elseMult.decRef();
282 elseMult = tmp2;
283 // std::cerr<< "h1"<<std::endl;
284
285 NaviType thenTail, thenMult;
286
287 if(!isReducible){
288
289 // if(!thenNavi.isConstant())
290 // std::cout << " "<<(*thenNavi)<< " "<< *idxStart<<std::endl;
291 apply.assign(thenTail, thenNavi);
292 ///!2 thenTail = thenNavi;
293
294 if (!thenNavi.isConstant()){
295
296 thenMult =
297 indexed_term_multiplescxx . . $ polybori/indexed_term_multiples(8ca39c9653f9db3c).(thenTail, idxStart, idxFinish, apply);
298 // if(thenMult==thenTail)
299 // PBORI_PREFIX(Cudd_Deref)(thenMult);
300 //PBORI_PREFIX(Cudd_Deref)(thenTail);///
301 //////// PBORI_PREFIX(Cudd_Ref)(thenMult);///
302 }
303 else{
304 ///!1 thenMult= thenTail;
305 apply.assign(thenMult, thenTail);////
306 }
307 }
308 // std::cerr<< "h2"<<std::endl;
309 // generating elsePath and multiples
310 ReverseIterator idxIter = idxStart;
311 const_reverse_iteratorcxx . . $ polybori/minimal_of_two_terms(dc4a053fc2f7eb4b).const_reverse_iterator# start(elseIdx.rbegincxx . . $ std/vector#rbegin(4f1ab9f89f58444d).()), finish(elseIdx.rendcxx . . $ std/vector#rend(4f1ab9f89f58444d).());
312
313 // PBORI_PREFIX(Cudd_Ref)(elseMult);
314 // std::cout << "isRed"<< isReducible <<std::endl;
315
316 if(!elseMult.isConstant())
317 while((idxIter !=cxx . . $ polybori/`operator!=`(166981e292dfc570). idxFinish) && (*cxx . . $ polybori/`operator*`(d630c30f8681b4d2).idxIter >=cxx . . $ polybori/`operator>=`(677edc2de9f9cb19). *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).elseMult) )
318 ++idxIter;
319
320 while(start !=cxx . . $ polybori/`operator!=`(166981e292dfc570). finish){
321
322 while((idxIter !=cxx . . $ polybori/`operator!=`(166981e292dfc570). idxFinish) && (*cxx . . $ polybori/`operator*`(d630c30f8681b4d2).idxIter >cxx . . $ polybori/`operator>`(677edc2de9f9cb19). *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).start) ) {
323
324 apply.multiplesAssign(elseMult, *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).idxIter);
325 ++idxIter;
326 }
327 apply.productAssign(elseMult, *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).start);
328
329 if (isReducible)
330 apply.productAssign(elseTail, *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).start);
331
332 if(idxIter !=cxx . . $ polybori/`operator!=`(166981e292dfc570). idxFinish)
333 ++idxIter;
334 ++start;
335 }
336 // std::cerr<< "h3"<<std::endl;
337 if (isReducible){
338 multiples = elseMult;
339
340
341 /////// PBORI_PREFIX(Cudd_Ref)(multiples); ///////
342 // PBORI_PREFIX(Cudd_Ref)(elseTail);
343 //PBORI_PREFIX(Cudd_Deref)(thenTail);
344 //PBORI_PREFIX(Cudd_Deref)(thenMult);
345
346 // std::cerr<< "h4"<<std::endl;
347 return elseTail;
348 }
349 else {
350
351 // std::cerr<< "h5"<<std::endl;
352 const_reverse_iteratorcxx . . $ polybori/minimal_of_two_terms(dc4a053fc2f7eb4b).const_reverse_iterator# start2(thenIdx.rbegincxx . . $ std/vector#rbegin(4f1ab9f89f58444d).()), finish2(thenIdx.rendcxx . . $ std/vector#rend(4f1ab9f89f58444d).());
353 ReverseIterator idxIter = idxStart;
354
355 // PBORI_PREFIX(Cudd_Ref)(thenMult);
356 // NaviType printer = thenMult; std::cout<< "thenMult"<<std::endl;
357 // while(!printer.isConstant()){
358 // std::cout<< *printer <<" & ";
359 // printer.incrementThen();
360 // }
361 if(!thenMult.isConstant())
362 while((idxIter !=cxx . . $ polybori/`operator!=`(166981e292dfc570). idxFinish) && (*cxx . . $ polybori/`operator*`(d630c30f8681b4d2).idxIter >=cxx . . $ polybori/`operator>=`(677edc2de9f9cb19). *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).thenMult) )
363 ++idxIter;
364
365
366 // std::cerr<< "h6"<<std::endl;
367
368
369 while(start2 !=cxx . . $ polybori/`operator!=`(166981e292dfc570). finish2){
370
371 while((idxIter !=cxx . . $ polybori/`operator!=`(166981e292dfc570). idxFinish) && (*cxx . . $ polybori/`operator*`(d630c30f8681b4d2).idxIter >cxx . . $ polybori/`operator>`(677edc2de9f9cb19). *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).start2) ) {
372 // std::cout<< *idxIter <<" ? ";
373 apply.multiplesAssign(thenMult, *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).idxIter);
374 ++idxIter;
375 }
376 apply.productAssign(thenMult, *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).start2);
377 // apply.productAssign(thenTail, *start);
378 if(idxIter !=cxx . . $ polybori/`operator!=`(166981e292dfc570). idxFinish)
379 ++idxIter;
380 ++start2;
381 }
382
383
384 apply.replacingUnite(multiples, elseMult, thenMult);
385
386
387
388 // std::cerr<< "h7"<<std::endl;
389 // printer = multiples; std::cout<< "mu"<<std::endl;
390 // while(!printer.isConstant()){
391 // // std::cout<< *printer <<" & ";
392 // printer.incrementThen();
393 // }
394 // std::cout<< std::endl;
395 ////////// PBORI_PREFIX(Cudd_Ref)(multiples);
396 // return apply.newNode(navi);
397 // std::cout << " "<<((DdNode*)thenTail)->ref<<std::endl;
398 // std::cerr<< "h8"<<std::endl;
399
400 apply.kill(elseTail);
401 apply.kill(thenTail);
402
403
404 return apply.newNode(navi);
405 }
406
407
408
409 // // remainder of first term
410 // while (!thenNavi.isConstant() ){
411 // thenIdx.push_back(*thenNavi);
412 // thenIdx.incrementThen();
413 // }
414
415 // // remainder of last term
416 // while (!elseNavi.isConstant()){
417 // elseIdx.push_back(*elseNavi);
418
419 // elseIdx.incrementThen();
420 // if( !elseIdx.isConstant() ) { // if still in interior of a path
421
422 // tmp = elseNavi; // store copy of *this
423 // elseNavi.incrementElse(); // go in direction of last term, if possible
424
425 // // restore previous value, of else branch was invalid
426 // if( elseNavi.isEmpty() )
427 // elseNavi = tmp;
428 // }
429 // isReducible = false;
430 // }
431
432
433
434 }
435
436
437 template <class NaviType, class SizeType, class ReverseIterator,
438 class DDOperations>
439 NaviType
440 prepend_multiples_wrt_indicescxx . . $ polybori/prepend_multiples_wrt_indices(4b54c423daeafd4b).(NaviType navi, SizeType minIdx,
441 ReverseIterator start, ReverseIterator finish,
442 const DDOperations& apply) {
443
444 if (navi.isConstant()){
445 if (!navi.terminalValue())
446 return navi;
447 }
448 else
449 while ( (start !=cxx . . $ polybori/`operator!=`(166981e292dfc570). finish) && (*cxx . . $ polybori/`operator*`(d630c30f8681b4d2).start >=cxx . . $ polybori/`operator>=`(677edc2de9f9cb19). *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).navi) )
450 ++start;
451
452 while( (start !=cxx . . $ polybori/`operator!=`(166981e292dfc570). finish) && (*cxx . . $ polybori/`operator*`(d630c30f8681b4d2).start >cxx . . $ polybori/`operator>`(677edc2de9f9cb19). minIdx) ){
453 apply.multiplesAssign(navi, *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).start);
454 ++start;
455 }
456 return navi;
457 }
458
459 template<class FunctionType, class ManagerType, class NodeType>
460 void apply_assign_cudd_functioncxx . . $ polybori/apply_assign_cudd_function(403e8e451952a0b8).(FunctionType func, ManagerType& mgr,
461 NodeType& first, const NodeType& second) {
462
463 NodeType newNode(func(mgr, do_get_nodecxx . . $ polybori/do_get_node(f71d95c4d8e51049).(first), do_get_nodecxx . . $ polybori/do_get_node(f71d95c4d8e51049).(second)));
464 inc_refcxx . . $ polybori/inc_ref(77d9f17553126ecb).(newNode);
465 recursive_dec_refcxx . . $ polybori/recursive_dec_ref(13c11f7bd0e7e3d2).(mgr, first);
466 first = newNode;
467 }
468
469
470
471 template<class FunctionType, class ManagerType, class ResultType,
472 class NodeType>
473 void apply_replacing_cudd_functioncxx . . $ polybori/apply_replacing_cudd_function(478fc756f12d949).(FunctionType func, ManagerType& mgr,
474 ResultType& newNode,
475 const NodeType& first,
476 const NodeType& second) {
477
478 newNode = NodeType(func(mgr, do_get_nodecxx . . $ polybori/do_get_node(f71d95c4d8e51049).(first), do_get_nodecxx . . $ polybori/do_get_node(f71d95c4d8e51049).(second)));
479 inc_refcxx . . $ polybori/inc_ref(77d9f17553126ecb).(newNode);
480 recursive_dec_refcxx . . $ polybori/recursive_dec_ref(13c11f7bd0e7e3d2).(mgr, first);
481 recursive_dec_refcxx . . $ polybori/recursive_dec_ref(13c11f7bd0e7e3d2).(mgr, second);
482 }
483
484 template<class FunctionType, class ManagerType, class NodeType>
485 NodeType apply_cudd_functioncxx . . $ polybori/apply_cudd_function(80ddc4dd75cc58c9).(FunctionType func, ManagerType& mgr,
486 const NodeType& first, const NodeType& second) {
487
488 NodeType newNode;
489 newNode = NodeType(func(mgr, do_get_nodecxx . . $ polybori/do_get_node(f71d95c4d8e51049).(first), do_get_nodecxx . . $ polybori/do_get_node(f71d95c4d8e51049).(second)));
490 inc_refcxx . . $ polybori/inc_ref(77d9f17553126ecb).(newNode);
491 return newNode;
492 }
493
494 template <class DDType>
495 class dd_operationscxx . . $ polybori/dd_operations#;
496
497 template<>
498 class dd_operationscxx . . $ polybori/dd_operations#<CCuddNavigatorcxx . . $ polybori/CCuddNavigator#>:
499 public CAuxTypescxx . . $ polybori/CAuxTypes# {
500 public:
501 typedef DdManagercxx . . $ polybori/DdManager#* manager_typecxx . . $ polybori/dd_operations#manager_type#;
502 typedef CCuddNavigatorcxx . . $ polybori/CCuddNavigator# navigatorcxx . . $ polybori/dd_operations#navigator#;
503
504
505 dd_operationscxx . . $ polybori/dd_operations#dd_operations(28612e251387dac0).(manager_typecxx . . $ polybori/dd_operations#manager_type# man): mgrcxx . . $ polybori/dd_operations#mgr.(man) {}
506 void replacingUnitecxx . . $ polybori/dd_operations#replacingUnite(35958b47d613398a).(navigatorcxx . . $ polybori/dd_operations#navigator#& newNode,
507 const navigatorcxx . . $ polybori/dd_operations#navigator#& first, const navigatorcxx . . $ polybori/dd_operations#navigator#& second) const {
508
509 apply_replacing_cudd_functioncxx . . $ polybori/apply_replacing_cudd_function(478fc756f12d949).(PBORI_PREFIXcxx . . $ `libbrial/include/polybori/cudd/prefix.h:27:9`!(Cudd_zddUnion), mgrcxx . . $ polybori/dd_operations#mgr., newNode, first, second);
510 }
511
512 void uniteAssigncxx . . $ polybori/dd_operations#uniteAssign(971842a6a868bd7b).(navigatorcxx . . $ polybori/dd_operations#navigator#& first, const navigatorcxx . . $ polybori/dd_operations#navigator#& second) const {
513 apply_assign_cudd_functioncxx . . $ polybori/apply_assign_cudd_function(403e8e451952a0b8).(PBORI_PREFIXcxx . . $ `libbrial/include/polybori/cudd/prefix.h:27:9`!(Cudd_zddUnion), mgrcxx . . $ polybori/dd_operations#mgr., first, second);
514 }
515 void diffAssigncxx . . $ polybori/dd_operations#diffAssign(971842a6a868bd7b).(navigatorcxx . . $ polybori/dd_operations#navigator#& first, const navigatorcxx . . $ polybori/dd_operations#navigator#& second) const {
516 apply_assign_cudd_functioncxx . . $ polybori/apply_assign_cudd_function(403e8e451952a0b8).(PBORI_PREFIXcxx . . $ `libbrial/include/polybori/cudd/prefix.h:27:9`!(Cudd_zddDiff), mgrcxx . . $ polybori/dd_operations#mgr., first, second);
517 }
518 navigatorcxx . . $ polybori/dd_operations#navigator# diffcxx . . $ polybori/dd_operations#diff(6636ae1b81599227).(const navigatorcxx . . $ polybori/dd_operations#navigator#& first, const navigatorcxx . . $ polybori/dd_operations#navigator#& second) const {
519 return apply_cudd_functioncxx . . $ polybori/apply_cudd_function(80ddc4dd75cc58c9).(PBORI_PREFIXcxx . . $ `libbrial/include/polybori/cudd/prefix.h:27:9`!(Cudd_zddDiff), mgrcxx . . $ polybori/dd_operations#mgr., first, second);
520 }
521 void replacingNodecxx . . $ polybori/dd_operations#replacingNode(346c4774856aa310).(navigatorcxx . . $ polybori/dd_operations#navigator#& newNode, idx_typecxx . . $ polybori/CAuxTypes#idx_type# idx,
522 navigatorcxx . . $ polybori/dd_operations#navigator#& first, navigatorcxx . . $ polybori/dd_operations#navigator#& second) const {
523
524 newNode =cxx . . $ polybori/CCuddNavigator#`operator=`(de77fd0764eb1c0c). navigatorcxx . . $ polybori/dd_operations#navigator#(PBORI_PREFIXcxx . . $ `libbrial/include/polybori/cudd/prefix.h:27:9`!(cuddZddGetNode)(mgrcxx . . $ polybori/dd_operations#mgr., idx, first.getNodecxx . . $ polybori/CCuddNavigator#getNode(364b1b85310f2aa3).(),
525 second.getNodecxx . . $ polybori/CCuddNavigator#getNode(364b1b85310f2aa3).()));
526 newNode.incRefcxx . . $ polybori/CCuddNavigator#incRef(83f5f38750778ac8).();
527 recursive_dec_refcxx . . $ polybori/recursive_dec_ref(13c11f7bd0e7e3d2).(mgrcxx . . $ polybori/dd_operations#mgr., first);
528 recursive_dec_refcxx . . $ polybori/recursive_dec_ref(13c11f7bd0e7e3d2).(mgrcxx . . $ polybori/dd_operations#mgr., second);
529 }
530
531 void newNodeAssigncxx . . $ polybori/dd_operations#newNodeAssign(2e19ece5e46e2d80).(idx_typecxx . . $ polybori/CAuxTypes#idx_type# idx,
532 navigatorcxx . . $ polybori/dd_operations#navigator#& thenNode, const navigatorcxx . . $ polybori/dd_operations#navigator#& elseNode) const {
533 navigatorcxx . . $ polybori/dd_operations#navigator# newNode = navigatorcxx . . $ polybori/dd_operations#navigator#(PBORI_PREFIXcxx . . $ `libbrial/include/polybori/cudd/prefix.h:27:9`!(cuddZddGetNode)(mgrcxx . . $ polybori/dd_operations#mgr., idx,
534 thenNode.getNodecxx . . $ polybori/CCuddNavigator#getNode(364b1b85310f2aa3).(),
535 elseNode.getNodecxx . . $ polybori/CCuddNavigator#getNode(364b1b85310f2aa3).()));
536 newNode.incRefcxx . . $ polybori/CCuddNavigator#incRef(83f5f38750778ac8).();
537 //PBORI_PREFIX(Cudd_Deref)(thenNode);
538 recursive_dec_refcxx . . $ polybori/recursive_dec_ref(13c11f7bd0e7e3d2).(mgrcxx . . $ polybori/dd_operations#mgr., thenNode);
539 thenNode =cxx . . $ polybori/CCuddNavigator#`operator=`(de77fd0764eb1c0c). newNode;
540 }
541
542 void multiplesAssigncxx . . $ polybori/dd_operations#multiplesAssign(983cf32536641dd3).(navigatorcxx . . $ polybori/dd_operations#navigator#& node, idx_typecxx . . $ polybori/CAuxTypes#idx_type# idx) const {
543 newNodeAssigncxx . . $ polybori/dd_operations#newNodeAssign(2e19ece5e46e2d80).(idx, node, node);
544 }
545
546 void productAssigncxx . . $ polybori/dd_operations#productAssign(983cf32536641dd3).(navigatorcxx . . $ polybori/dd_operations#navigator#& node, idx_typecxx . . $ polybori/CAuxTypes#idx_type# idx) const {
547 navigatorcxx . . $ polybori/dd_operations#navigator# emptyset = navigatorcxx . . $ polybori/dd_operations#navigator#(PBORI_PREFIXcxx . . $ `libbrial/include/polybori/cudd/prefix.h:27:9`!(Cudd_ReadZero)(mgrcxx . . $ polybori/dd_operations#mgr.));
548 newNodeAssigncxx . . $ polybori/dd_operations#newNodeAssign(2e19ece5e46e2d80).(idx, node, emptyset);
549 }
550
551 void assigncxx . . $ polybori/dd_operations#assign(971842a6a868bd7b).(navigatorcxx . . $ polybori/dd_operations#navigator#& first, const navigatorcxx . . $ polybori/dd_operations#navigator#& second) const {
552
553 first =cxx . . $ polybori/CCuddNavigator#`operator=`(de77fd0764eb1c0c). second;
554 first.incRefcxx . . $ polybori/CCuddNavigator#incRef(83f5f38750778ac8).();
555 }
556 void replacecxx . . $ polybori/dd_operations#replace(971842a6a868bd7b).(navigatorcxx . . $ polybori/dd_operations#navigator#& first, const navigatorcxx . . $ polybori/dd_operations#navigator#& second) const {
557 recursive_dec_refcxx . . $ polybori/recursive_dec_ref(13c11f7bd0e7e3d2).(mgrcxx . . $ polybori/dd_operations#mgr., first);
558 first =cxx . . $ polybori/CCuddNavigator#`operator=`(de77fd0764eb1c0c). second;
559 }
560
561 size_typecxx . . $ polybori/CAuxTypes#size_type# nSupportcxx . . $ polybori/dd_operations#nSupport(2f3ad857422ecfb2).(const navigatorcxx . . $ polybori/dd_operations#navigator#& node) const {
562 return PBORI_PREFIXcxx . . $ `libbrial/include/polybori/cudd/prefix.h:27:9`!(Cudd_SupportSize)(mgrcxx . . $ polybori/dd_operations#mgr., node.getNodecxx . . $ polybori/CCuddNavigator#getNode(364b1b85310f2aa3).());
563 }
564 size_typecxx . . $ polybori/CAuxTypes#size_type# lengthcxx . . $ polybori/dd_operations#length(2f3ad857422ecfb2).(const navigatorcxx . . $ polybori/dd_operations#navigator#& node) const {
565 return PBORI_PREFIXcxx . . $ `libbrial/include/polybori/cudd/prefix.h:27:9`!(Cudd_zddCount)(mgrcxx . . $ polybori/dd_operations#mgr., node.getNodecxx . . $ polybori/CCuddNavigator#getNode(364b1b85310f2aa3).());
566 }
567
568 navigatorcxx . . $ polybori/dd_operations#navigator#& newNodecxx . . $ polybori/dd_operations#newNode(d80be2de4a9dd3eb).(navigatorcxx . . $ polybori/dd_operations#navigator#& node) const {
569 node.incRefcxx . . $ polybori/CCuddNavigator#incRef(83f5f38750778ac8).();
570 return node;
571 }
572
573 void killcxx . . $ polybori/dd_operations#kill(a458e5f0e1ae27d2).(navigatorcxx . . $ polybori/dd_operations#navigator#& node) const {
574 recursive_dec_refcxx . . $ polybori/recursive_dec_ref(13c11f7bd0e7e3d2).(mgrcxx . . $ polybori/dd_operations#mgr., node);
575 }
576 protected:
577 manager_typecxx . . $ polybori/dd_operations#manager_type# mgrcxx . . $ polybori/dd_operations#mgr.;
578 };
579
580 /// A first version
581 /// Function templates extracting minimal elements of dd wrt. inclusion
582 /// Assumption, navi is navigator of dd
583 template <class NaviType, class DDType2, class ReverseIterator,
584 class DDOperations>
585 //DDType
586 NaviType
587 dd_minimal_elementscxx . . $ polybori/dd_minimal_elements(c7c6ce647cd1b3f3).(NaviType navi,DDType2& multiples,
588 ReverseIterator idxStart, ReverseIterator idxEnd,
589 const DDOperations& apply) {
590
591
592
593 if (!navi.isConstant()) { // Not at end of path
594
595 int nlen = apply.length(navi);
596
597 if(false&&(nlen == 2)) {
598
599 // std::cerr << "hier"<<std::endl;
600 navi = minimal_of_two_termscxx . . $ polybori/minimal_of_two_terms(dc4a053fc2f7eb4b).(navi, multiples,idxStart, idxEnd, apply);
601
602 // std::cerr << "danach"<<std::endl;
603 return navi;
604
605 #if 0
606 multiples = navi;
607
608
609 std::vector<int> indices (apply.nSupport(navi));
610 std::vector<int>::iterator iter(indices.begin()), iend(indices.end());
611 bool is_reducible = true;
612 bool reducible_tested = false;
613
614 int used = 0;
615 NaviType thenBr;
616 NaviType elseBr;
617 while( is_reducible&&(!multiples.isConstant())) {
618 *iter = *multiples;
619 used++;
620
621 thenBr = multiples.thenBranch();
622 elseBr = multiples.elseBranch();
623
624 if((elseBr.isConstant() && elseBr.terminalValue())) {
625 --iter;
626 --used;
627 multiples = elseBr;
628 }
629 else if (elseBr.isConstant() && !elseBr.terminalValue())
630 multiples = thenBr;
631 else {
632 if (!reducible_tested){
633 reducible_tested == true;
634 is_reducible = is_reducible_by(thenBr, elseBr);
635 }
636 if(is_reducible){
637 --iter;
638 --used;
639 }
640
641 multiples = elseBr;
642 }
643
644
645 ++iter;
646
647 }
648
649
650
651 indices.resize(used);
652
653 if (is_reducible) {
654
655 std::vector<int>::const_reverse_iterator start(indices.rbegin()),
656 finish(indices.rend());
657
658 // int nmax = dd.nVariables();
659
660 inc_ref(multiples);
661
662
663 NaviType tmp,tmpnavi;
664
665 apply.assign(tmpnavi, multiples);
666
667 ReverseIterator idxIter = idxStart;
668 while(start != finish){
669
670 while((idxIter != idxEnd) && (*idxIter > *start) ) {
671
672 apply.multiplesAssign(multiples, *idxIter);
673 ++idxIter;
674 }
675 apply.productAssign(multiples, *start);
676 apply.productAssign(tmpnavi, *start);
677 if(idxIter != idxEnd)
678 ++idxIter;
679 ++start;
680 }
681
682 navi = tmpnavi;
683 return navi;
684 }
685 // else { // Subcase: two proper terms
686
687 // thenBr = indexed_term_multiples(thenBr, idxStart, idxEnd, apply);
688 // elseBr = indexed_term_multiples(elseBr, idxStart, idxEnd, apply);
689
690 // }
691 #endif
692 }
693
694
695
696 if(nlen == 1) { // Special case of only one term
697 // PBORI_PREFIX(Cudd_Ref)(navi);
698 multiples = indexed_term_multiplescxx . . $ polybori/indexed_term_multiples(8ca39c9653f9db3c).(navi, idxStart, idxEnd, apply);
699 return apply.newNode(navi);
700 }
701
702
703 // treat else branch
704 NaviType elseMult;
705 NaviType elsedd = dd_minimal_elementscxx . . $ polybori/dd_minimal_elements(c7c6ce647cd1b3f3).(navi.elseBranch(),
706 elseMult, idxStart, idxEnd, apply);
707 elseMult = prepend_multiples_wrt_indicescxx . . $ polybori/prepend_multiples_wrt_indices(4b54c423daeafd4b).(elseMult, *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).navi,
708 idxStart, idxEnd, apply);
709
710 // short cut for obvious inclusion
711 if( (navi.elseBranch() ==cxx . . $ polybori/`operator==`(166981e292dfc570). navi.thenBranch()) ||
712 (elsedd.isConstant() && elsedd.terminalValue()) ){
713 multiples = elseMult;
714 return elsedd;
715 }
716
717 // remove already treated branches
718 NaviType thenNavi(apply.diff(navi.thenBranch(), elseMult));
719
720 // treat remaining parts of then branch
721 NaviType thenMult;
722 apply.replace(thenNavi, dd_minimal_elementscxx . . $ polybori/dd_minimal_elements(c7c6ce647cd1b3f3).(thenNavi, thenMult,
723 idxStart, idxEnd, apply));
724 thenMult = prepend_multiples_wrt_indicescxx . . $ polybori/prepend_multiples_wrt_indices(4b54c423daeafd4b).(thenMult, *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).navi,
725 idxStart, idxEnd, apply);
726
727 // generate node consisting of all multiples
728 apply.uniteAssign(thenMult, elseMult);
729 apply.replacingNode(multiples, *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).navi, thenMult, elseMult);
730
731 // generate result from minimal elements of then and else brach
732 NaviType result;
733 apply.replacingNode(result, *cxx . . $ polybori/`operator*`(d630c30f8681b4d2).navi, thenNavi, elsedd);
734
735 return result;
736
737 }
738
739 apply.assign(multiples, navi);
740
741 return apply.newNode(navi);
742 }
743
744 END_NAMESPACE_PBORIcxx . . $ `libbrial/include/polybori/pbori_defs.h:77:11`!
745
746 #endif