31 #include "NodeTable.hpp" 32 #include "../util/MessageHandler.hpp" 33 #include "../util/MyVector.hpp" 44 static size_t const SWEEP_RATIO = 20;
46 NodeTableEntity<ARITY>& diagram;
47 MyVector<NodeBranchId>* oneSrcPtr;
49 MyVector<int> sweepLevel;
50 MyVector<size_t> deadCount;
61 diagram(diagram), oneSrcPtr(0), allCount(0), maxCount(0), rootPtr(0) {
70 MyVector<NodeBranchId>& oneSrcPtr) :
72 oneSrcPtr(&oneSrcPtr),
92 void update(
int current,
int child,
size_t count) {
95 if (current <= 1)
return;
97 if (
size_t(current) >= sweepLevel.size()) {
98 sweepLevel.resize(current + 1);
99 deadCount.resize(current + 2);
102 for (
int i = child; i <= current; ++i) {
103 if (sweepLevel[i] > 0)
break;
104 sweepLevel[i] = current + 1;
107 deadCount[current] = count;
108 allCount += diagram[current].size();
110 int k = sweepLevel[current - 1];
111 for (
int i = sweepLevel[current]; i > k; --i) {
112 deadCount[k] += deadCount[i];
115 if (maxCount < allCount) maxCount = allCount;
116 if (deadCount[k] * SWEEP_RATIO < maxCount)
return;
118 MyVector<MyVector<NodeId> > newId(diagram.numRows());
121 mh.begin(
"sweeping") <<
" <" << diagram.size() <<
"> ...";
123 for (
int i = k; i < diagram.numRows(); ++i) {
124 size_t m = diagram[i].size();
129 for (
size_t j = 0; j < m; ++j) {
130 Node<ARITY>& p = diagram[i][j];
133 for (
int b = 0; b < ARITY; ++b) {
134 NodeId& f = p.branch[b];
135 if (f.row() >= k) f = newId[f.row()][f.col()];
136 if (f != 0) dead =
false;
143 newId[i][j] = NodeId(i, jj);
149 diagram[i].resize(jj);
153 for (
size_t i = 0; i < oneSrcPtr->size(); ++i) {
154 NodeBranchId& nbi = (*oneSrcPtr)[i];
156 NodeId f = newId[nbi.row][nbi.col];
163 *rootPtr = newId[rootPtr->row()][rootPtr->col()];
165 allCount = diagram.size();
166 mh.end(diagram.size());
void update(int current, int child, size_t count)
Updates status and sweeps the DD if necessary.
DdSweeper(NodeTableEntity< ARITY > &diagram, MyVector< NodeBranchId > &oneSrcPtr)
Constructor.
DdSweeper(NodeTableEntity< ARITY > &diagram)
Constructor.
void setRoot(NodeId &root)
Set the root pointer.