Skip to content

Commit 9a5b277

Browse files
committed
Fixing issue with low TD
1 parent 1e20e0e commit 9a5b277

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/counter.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ bool Counter::remove_duplicates(vector<Lit>& lits) {
134134
void Counter::compute_score(TWD::TreeDecomposition& tdec, uint32_t nodes, bool print) {
135135
const auto& bags = tdec.Bags();
136136
td_width = tdec.width();
137-
if (print || conf.verb >= 1) verb_print(0, "[td] Calculated TD width: " << td_width-1);
137+
if (td_width <= 0) {
138+
if (print) verb_print(1, "TD width is 0, ignoring TD");
139+
return;
140+
}
141+
if (print) verb_print(2, "[td] Calculated TD width: " << td_width-1);
138142
const auto& adj = tdec.get_adj_list();
139143
#if 0
140144
for(uint32_t i = 0; i < bags.size(); i++) {
@@ -150,14 +154,14 @@ void Counter::compute_score(TWD::TreeDecomposition& tdec, uint32_t nodes, bool p
150154
#endif
151155
std::vector<int> dists = tdec.distanceFromCentroid(nodes);
152156
if (dists.empty()) {
153-
verb_print(1, "All projected vars in the same bag, ignoring TD");
157+
if (print) verb_print(1, "All projected vars in the same bag, ignoring TD");
154158
return;
155159
} else {
156160
int max_dst = 0;
157161
for(int i=1; i < (int)nodes; i++)
158162
max_dst = std::max(max_dst, dists[i]);
159163
if (max_dst == 0) {
160-
verb_print(1, "All projected vars are the same distance, ignoring TD");
164+
if (print) verb_print(1, "All projected vars are the same distance, ignoring TD");
161165
return;
162166
}
163167
}
@@ -213,9 +217,8 @@ void Counter::compute_score(TWD::TreeDecomposition& tdec, uint32_t nodes, bool p
213217
tdscore[i] = val;
214218
}
215219

216-
for(uint32_t i = 1; i < nodes; i++) {
217-
verb_print(2, "TD var: " << i << " tdscore: " << tdscore[i]);
218-
}
220+
for(uint32_t i = 1; i < nodes; i++)
221+
verb_print(2, "TD var: " << i << " tdscore: " << tdscore[i]);
219222
}
220223

221224
TWD::TreeDecomposition Counter::td_decompose_component(double mult) {

0 commit comments

Comments
 (0)