Skip to content

Commit b415898

Browse files
committed
Better example generation
1 parent da2e8e5 commit b415898

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

src/comp_analyzer.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ THE SOFTWARE.
3030
#include <cstdint>
3131
#include <cstdint>
3232
#include <memory>
33-
#include <ratio>
3433

3534
using namespace GanakInt;
3635

@@ -46,7 +45,7 @@ void CompAnalyzer::calc_blocked(
4645
const ClauseAllocator* alloc, const vector<ClauseOfs>& long_irred_cls)
4746
{
4847
const uint32_t n = max_var+1;
49-
lit_to_blocked_clids.resize(n*2);
48+
clid_to_blocking_lits.resize(long_irred_cls.size()+1);
5049
if (counter->get_opt_indep_support_end() >= max_var+1) {
5150
verb_print(1, "No need to calculate blocked clauses, as all vars are opt independent");
5251
return;
@@ -196,15 +195,14 @@ void CompAnalyzer::calc_blocked(
196195
}
197196
if (!blocked) continue; // try next var
198197
if (blocked) {
199-
cout << "BINGO! cl: " << cl << " blocked on: " << l << " given: " << l_set << endl;
200-
clids_blocked.push_back(clid);
198+
/* cout << "BINGO! cl: " << cl << " blocked on: " << l << " given: " << l_set << endl; */
199+
clid_to_blocking_lits[clid].push_back(l_set);
201200
break;
202201
}
203202
}
204203
for(const auto& l: cl) seen[l.raw()] = 0;
205204
}
206205
blocked_tot += clids_blocked.size();
207-
lit_to_blocked_clids[l_set.raw()] = clids_blocked;
208206
for(const auto& l: seen_set_clear) seen_set[l.raw()] = 0;
209207
seen_set_clear.clear();
210208
}
@@ -243,26 +241,18 @@ void CompAnalyzer::initialize(
243241
long_clauses_data.clear();
244242
long_clauses_data.push_back(SENTINEL_LIT); // MUST start with a sentinel!
245243
vector<uint32_t> tmp;
244+
std::mt19937_64 mtrand(conf.seed);
246245
for (const auto& off: long_irred_cls) {
247246
const Clause& cl = *alloc->ptr(off);
248247
assert(cl.size() > 2);
249248
const uint32_t long_cl_off = long_clauses_data.size();
250249

251-
Lit example_blocking = NOT_A_LIT;
252-
bool found = false;
253-
for (int32_t v = n-1; v >= 1; v--) {
254-
for(uint32_t i2 = 0; i2 < 2; i2++) {
255-
Lit b = Lit(v, i2);
256-
const auto& list = lit_to_blocked_clids[b.raw()];
257-
if (std::find(list.begin(), list.end(), max_clid) != list.end()) {
258-
example_blocking = b;
259-
cout << "Example blocking: " << example_blocking << " for cl: " << cl << " id: " << max_clid << endl;
260-
found = true;
261-
break;
262-
}
263-
}
264-
if (found) break;
265-
}
250+
Lit example_blocking = NOT_A_LIT;
251+
auto& blk_lits =clid_to_blocking_lits[max_clid];
252+
if (!blk_lits.empty()) {
253+
std::shuffle(blk_lits.begin(), blk_lits.end(), mtrand);
254+
example_blocking = blk_lits[0];
255+
}
266256

267257
if (cl.size() > 3) {
268258
Lit blk_lit = cl[cl.size()/2];

src/comp_analyzer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class CompAnalyzer {
181181
private:
182182
void calc_blocked(const LiteralIndexedVector<LitWatchList> & literals,
183183
const ClauseAllocator* alloc, const vector<ClauseOfs>& long_irred_cls);
184-
vector<vector<uint32_t>> lit_to_blocked_clids;
184+
vector<vector<Lit>> clid_to_blocking_lits;
185185

186186
// the id of the last clause
187187
// note that clause ID is the clause number,

0 commit comments

Comments
 (0)