PolyBoRi
|
00001 // -*- c++ -*- 00002 //***************************************************************************** 00157 //***************************************************************************** 00158 00159 // include basic definitions 00160 #include "pbori_defs.h" 00161 00162 // include definitions of decision diagram interfaces 00163 #include "CDDInterface.h" 00164 00165 // include polybori functionals 00166 #include "pbori_func.h" 00167 #include "BooleRing.h" 00168 00169 #ifndef BooleSet_h_ 00170 #define BooleSet_h_ 00171 00172 BEGIN_NAMESPACE_PBORI 00173 00175 class BooleMonomial; 00176 class BooleExponent; 00177 00178 template<class OrderType, class NavigatorType, class MonomType> 00179 class CGenericIter; 00180 // temporarily 00181 class LexOrder; 00182 00183 //template<class OrderType, class NavigatorType, class MonomType> 00184 //class CGenericIter; 00185 00186 00187 #define PBORI_CONST_DDFUNCS(func) \ 00188 self func(const self& rhs) const { return self(base::func(rhs.diagram())); } 00189 00190 #define PBORI_DDFUNCS(func) \ 00191 self& func(const self& rhs) { base::func(rhs.diagram()); return *this; } 00192 00193 #define PBORI_CONST_DDFUNCS_IDX(func) \ 00194 self func(idx_type idx) const { return self(base::func(idx)); } 00195 00196 #define PBORI_DDFUNCS_IDX(func) \ 00197 self& func(idx_type idx) { base::func(idx); return *this; } 00198 00199 00200 class BooleSet: 00201 public CTypes::dd_type { 00202 00203 public: 00205 typedef BooleSet self; 00206 00208 typedef CTypes::dd_type base; 00209 00211 typedef base dd_type; 00212 00213 typedef base::navigator navigator; 00214 typedef base::size_type size_type; 00215 typedef base::idx_type idx_type; 00216 00218 typedef BooleMonomial term_type; 00219 00221 typedef BooleExponent exp_type; 00222 00224 typedef BooleRing ring_type; 00225 00227 typedef CGenericIter<LexOrder, navigator, term_type> const_iterator; 00228 00230 typedef CGenericIter<LexOrder, navigator, exp_type> exp_iterator; 00231 00233 BooleSet(); 00234 00236 BooleSet(const self& rhs): base(rhs) {} 00237 00239 BooleSet(const base& rhs): base(rhs) {} 00240 00242 BooleSet(idx_type idx, const self& first, const self& second): 00243 base(idx, first, second) { 00244 00245 00246 } 00247 00249 BooleSet(idx_type idx, navigator first, navigator second, 00250 const ring_type& ring): 00251 base(ring.manager(), idx, first, second) { } 00252 00254 BooleSet(idx_type idx, const self& rhs): 00255 base(rhs.ring().manager(), idx, rhs.navigation()) { } 00256 00258 // BooleSet(bool_type); 00261 00263 BooleSet(navigator navi, const ring_type& ring): 00264 base(ring.manager().manager(), navi) { } 00265 00267 ~BooleSet() {} 00268 00270 const_iterator begin() const; 00271 00273 const_iterator end() const; 00274 00276 exp_iterator expBegin() const; 00277 00279 exp_iterator expEnd() const; 00280 00282 self& operator=(const self&); 00283 00285 using base::operator=; 00286 00288 term_type usedVariables() const; 00289 00291 exp_type usedVariablesExp() const; 00292 00294 self& addAssign(const term_type&); 00295 00297 self add(const term_type&) const; 00298 00300 bool_type owns(const term_type&) const; 00301 00303 bool_type owns(const exp_type&) const; 00304 00306 term_type lastLexicographicalTerm() const; 00307 00309 self divisorsOf(const term_type& rhs) const; 00310 00312 self divisorsOf(const exp_type& rhs) const; 00313 00315 self firstDivisorsOf(const self& rhs) const; 00316 00318 self multiplesOf(const term_type& rhs) const; 00319 00321 self divide(const term_type& rhs) const; 00322 00324 self& divideAssign(const term_type& rhs); 00325 00327 bool_type hasTermOfVariables(const term_type& rhs) const; 00328 00330 self minimalElements() const;// { return base::minimalElements(); }; 00331 00333 using base::ownsOne; 00334 00336 bool_type isSingleton() const { return dd_is_singleton(navigation()); } 00337 00339 bool_type isSingletonOrPair() const { 00340 return dd_is_singleton_or_pair(navigation()); 00341 } 00342 00344 bool_type isPair() const { return dd_is_pair(navigation()); } 00345 00347 self existAbstract(const term_type& rhs) const; 00348 00350 const dd_type& diagram() const { return dynamic_cast<const dd_type&>(*this); } 00351 00353 self ite(const self& then_dd, const self& else_dd) { 00354 return self(base::ite(then_dd.diagram(), else_dd.diagram())); 00355 }; 00356 00358 self& iteAssign(const self& then_dd, const self& else_dd) { 00359 base::iteAssign(then_dd.diagram(), else_dd.diagram()); 00360 return *this; 00361 }; 00362 00364 self cartesianProduct(const self& rhs) const { 00365 return base::unateProduct(rhs.diagram()); 00366 }; 00367 00369 00370 PBORI_CONST_DDFUNCS_IDX(subset0) 00371 PBORI_CONST_DDFUNCS_IDX(subset1) 00372 PBORI_CONST_DDFUNCS_IDX(change) 00373 00374 00375 PBORI_CONST_DDFUNCS(unite) 00376 PBORI_CONST_DDFUNCS(diff) 00377 PBORI_CONST_DDFUNCS(diffConst) 00378 PBORI_CONST_DDFUNCS(intersect) 00379 PBORI_CONST_DDFUNCS(product) 00380 PBORI_CONST_DDFUNCS(dotProduct) 00381 PBORI_CONST_DDFUNCS(Xor) 00382 PBORI_CONST_DDFUNCS(ddDivide) 00383 PBORI_CONST_DDFUNCS(weakDivide) 00384 PBORI_CONST_DDFUNCS(divideFirst) 00385 00387 PBORI_DDFUNCS_IDX(subset0Assign) 00388 PBORI_DDFUNCS_IDX(subset1Assign) 00389 PBORI_DDFUNCS_IDX(changeAssign) 00390 00391 PBORI_DDFUNCS(uniteAssign) 00392 PBORI_DDFUNCS(diffAssign) 00393 PBORI_DDFUNCS(diffConstAssign) 00394 PBORI_DDFUNCS(intersectAssign) 00395 PBORI_DDFUNCS(productAssign) 00396 PBORI_DDFUNCS(dotProductAssign) 00397 PBORI_DDFUNCS(ddDivideAssign) 00398 PBORI_DDFUNCS(weakDivideAssign) 00399 PBORI_DDFUNCS(divideFirstAssign) 00401 00403 using base::hash; 00404 00406 using base::stableHash; 00407 00409 ostream_type& print(ostream_type&) const; 00410 00412 self emptyElement() const { return base::emptyElement(); } 00413 00415 size_type countIndex(idx_type idx) const; 00416 00418 double countIndexDouble(idx_type idx) const ; 00419 00421 ring_type ring() const { return ring_type(base::manager()); } 00422 }; 00423 00425 inline BooleSet::ostream_type& 00426 operator<<( BooleSet::ostream_type& os, const BooleSet& bset ) { 00427 return bset.print(os); 00428 } 00429 END_NAMESPACE_PBORI 00430 00431 #endif