16 #ifndef polybori_ring_CCuddInterface_h_
17 #define polybori_ring_CCuddInterface_h_
29 #include <boost/intrusive_ptr.hpp>
30 #include <boost/scoped_array.hpp>
32 #include <boost/preprocessor/cat.hpp>
33 #include <boost/preprocessor/seq/for_each.hpp>
34 #include <boost/preprocessor/facilities/expand.hpp>
35 #include <boost/preprocessor/stringize.hpp>
48 return(
"Out of memory.");
49 case CUDD_TOO_MANY_NODES:
50 return(
"To many nodes.");
51 case CUDD_MAX_MEM_EXCEEDED:
52 return(
"Maximum memory exceeded.");
53 case CUDD_INVALID_ARG:
54 return(
"Invalid argument.");
55 case CUDD_INTERNAL_ERROR:
56 return(
"Internal error.");
57 case CUDD_TIMEOUT_EXPIRED:
60 return(
"No error. (Should not reach here!)");
62 return(
"Unexpected error.");
74 if (!(--(ptr->hooks))) {
88 #define PB_CUDDMGR_READ(count, data, funcname) data funcname() const { \
89 return BOOST_PP_CAT(PBORI_PREFIX(Cudd_), funcname)(*this); }
91 #define PB_CUDDMGR_SWITCH(count, data, funcname) void funcname() { \
92 BOOST_PP_CAT(PBORI_PREFIX(Cudd_), funcname)(*this); }
94 #define PB_CUDDMGR_SET(count, data, funcname) void funcname(data arg) { \
95 BOOST_PP_CAT(PBORI_PREFIX(Cudd_), funcname)(*this, arg); }
130 typedef boost::intrusive_ptr<mgr_type>
mgr_ptr;
137 p_mgr(init(numVars, numVarsZ, numSlots, cacheSize, maxMemory)),
139 for (
idx_type idx = 0;
size_type(idx) < numVarsZ; ++idx) initVar(m_vars[idx], idx);
150 callBack(&self::recursiveDeref));
176 return checkedResult(DD_ONE(getManager()));
179 #ifdef CUDD_ORIGINAL_INCLUSION
183 int ReorderingStatusZdd(
PBORI_PREFIX(Cudd_ReorderingType) * method)
const {
197 void AddHook(DD_HFP f,
PBORI_PREFIX(Cudd_HookType) where) {
200 void RemoveHook(DD_HFP f,
PBORI_PREFIX(Cudd_HookType) where) {
203 int IsInHook(DD_HFP f,
PBORI_PREFIX(Cudd_HookType) where)
const {
206 void EnableReorderingReporting() {
209 void DisableReorderingReporting() {
213 void DebugCheck(){ checkedResult(
PBORI_PREFIX(Cudd_DebugCheck)(*
this)); }
214 void CheckKeys(){ checkedResult(
PBORI_PREFIX(Cudd_CheckKeys)(*
this)); }
215 void PrintLinear() { checkedResult(
PBORI_PREFIX(Cudd_PrintLinear)(*
this)); }
217 int ReadLinear(
int x,
int y) {
return PBORI_PREFIX(Cudd_ReadLinear)(*
this, x, y); }
221 void PrintVersion(FILE * fp)
const { std::cout.flush();
PBORI_PREFIX(Cudd_PrintVersion)(fp); }
223 void zddPrintSubtable()
const{
228 void zddReduceHeap(
PBORI_PREFIX(Cudd_ReorderingType) heuristic,
int minsize) {
229 checkedResult(
PBORI_PREFIX(Cudd_zddReduceHeap)(*
this, heuristic, minsize));
231 void zddShuffleHeap(
int * permutation) {
232 checkedResult(
PBORI_PREFIX(Cudd_zddShuffleHeap)(*
this, permutation));
234 void zddSymmProfile(
int lower,
int upper)
const {
241 (SetMinHit)(SetLooseUpTo)(SetMaxCacheHard)(SetMaxLive) )
244 (SetSiftMaxVar)(SetSiftMaxSwap)(SetRecomb)(SetSymmviolation)
245 (SetArcviolation)(SetPopulationSize)(SetNumberXovers)
248 BOOST_PP_SEQ_FOR_EACH(PB_CUDDMGR_SET, FILE*, (SetStdout)(SetStderr))
251 (zddRealignEnable)(zddRealignDisable)
253 (EnableGarbageCollection)(DisableGarbageCollection)
254 (TurnOnCountDead)(TurnOffCountDead)(ClearErrorCode)
258 (ReadCacheUsedSlots)(ReadCacheLookUps)(ReadCacheHits)
259 (ReadSwapSteps)(ReadMaxGrowth)(AverageDistance)
262 BOOST_PP_SEQ_FOR_EACH(PB_CUDDMGR_READ, size_type,
263 (ReadCacheSlots)(ReadMinHit)(ReadLooseUpTo)(ReadMaxCache)
264 (ReadMaxCacheHard)(ReadSlots)(ReadKeys)(ReadDead)(ReadMinDead)
265 (ReadNextReordering)(ReadMaxLive)
268 BOOST_PP_SEQ_FOR_EACH(PB_CUDDMGR_READ,
int,
269 (zddRealignmentEnabled)(ReadZddSize)(ReadReorderings)(ReadSiftMaxVar)
270 (ReadSiftMaxSwap)(ReadGarbageCollections)(GarbageCollectionEnabled)
271 (DeadAreCounted)(ReadRecomb)
272 (ReadPopulationSize)(ReadSymmviolation)(ReadArcviolation)
273 (ReadNumberXovers)(ReorderingReporting)(ReadErrorCode)
276 BOOST_PP_SEQ_FOR_EACH(PB_CUDDMGR_READ,
long,
277 (ReadReorderingTime)(ReadGarbageCollectionTime)
278 (ReadPeakNodeCount)(zddReadNodeCount)
281 BOOST_PP_SEQ_FOR_EACH(PB_CUDDMGR_READ, large_size_type,
282 (ReadMemoryInUse)(ReadMaxMemory) )
284 BOOST_PP_SEQ_FOR_EACH(PB_CUDDMGR_READ, FILE*, (ReadStdout)(ReadStderr))
286 PB_CUDDMGR_SET(BOOST_PP_NIL,
PBORI_PREFIX(Cudd_ReorderingType), AutodynEnableZdd)
287 PB_CUDDMGR_SET(BOOST_PP_NIL,
unsigned long, SetMaxMemory)
288 PB_CUDDMGR_SET(BOOST_PP_NIL,
double, SetMaxGrowth)
293 BOOST_PP_SEQ_FOR_EACH(PB_CUDDMGR_READ,
int,(ReadZddSize))
303 size_type
nVariables()
const {
return (size_type)ReadZddSize(); }
311 mgr_ptr init(size_type numVars,size_type numVarsZ, size_type numSlots,
312 size_type cacheSize, large_size_type maxMemory) {
324 checkedResult(
int(result != NULL));
337 return checkedResult(func(*
this, idx) );
342 return checkedResult(func(*
this) );
354 idx, zddOne(), zddZero()));
358 template <
class MemberFuncPtr>
366 operator mgr_type*()
const {
return getManager(); }
372 std::vector<node_ptr> m_vars;
376 #undef PB_CUDDMGR_READ
377 #undef PB_CUDDMGR_SWITCH
378 #undef PB_CUDDMGR_SET