Skip to content

Commit 57d0926

Browse files
feat: switch to MAMS heuristic
1 parent b489428 commit 57d0926

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

src/hyperGraph/HyperGraphExtractorDual.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,14 @@ void HyperGraphExtractorDual::constructHyperGraph(
208208
m_idxClauses.resize(0);
209209
hypergraph.setSize(0);
210210

211-
int heuristic_max = 100;
211+
int heuristic_max = 1;
212212

213-
/*for (int &variable : component) {
214-
int heuristic_value = om.getNbBinaryClause(variable) * 0.25;
213+
for (int &variable : component) {
214+
int heuristic_value = om.hg_heuristic_mams(variable);
215215
if (heuristic_value > heuristic_max) {
216216
heuristic_max = heuristic_value;
217217
}
218-
}*/
218+
}
219219

220220
//heuristic_max = heuristic_max / 10000;
221221

@@ -233,7 +233,7 @@ void HyperGraphExtractorDual::constructHyperGraph(
233233
continue;
234234

235235
// Set the weight for this variable.
236-
weight = om.hg_heuristic_maxo(v, heuristic_max);
236+
weight = om.hg_scale_heuristic(om.hg_heuristic_mams(v), heuristic_max);
237237

238238
// The current variable should not be marked.
239239
assert(!m_markedVar[v]);
@@ -324,7 +324,7 @@ void HyperGraphExtractorDual::constructHyperGraph(
324324
if (!size)
325325
pos--;
326326
else {
327-
int weight = om.hg_heuristic_maxo(v, heuristic_max);
327+
int weight = om.hg_scale_heuristic(om.hg_heuristic_mams(v), heuristic_max);
328328
hypergraph.getCost()[hypergraph.getSize()] = weight;
329329
hypergraph.incSize();
330330
considered.push_back(v);

src/specs/cnf/SpecManagerCnf.hpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -210,28 +210,30 @@ class SpecManagerCnf : public SpecManager {
210210
}
211211
}
212212

213-
/*
214-
* Calculates the MAXO heuristic for the given variable.
215-
* This heuristic assigns a variable its occurrence.
216-
*/
217-
int hg_heuristic_maxo(Var v, int max) {
218-
int value = max - getNbClause(v);
213+
int hg_scale_heuristic(int value, int max) {
214+
int ret = max / 100 - value;
219215

220-
if (value < 1) {
221-
value = 1;
216+
if (ret < 1) {
217+
ret = 1;
222218
}
223219

224-
return value;
220+
return ret;
225221
}
226222

227-
int hg_heuristic_moms(Var v, int max) {
228-
int value = max - (getNbBinaryClause(v) * 0.25);
223+
/*
224+
* Calculates the MAXO heuristic for the given variable.
225+
* This heuristic assigns a variable its occurrence.
226+
*/
227+
int hg_heuristic_maxo(Var v) {
228+
return getNbClause(v);
229+
}
229230

230-
if (value < 1) {
231-
value = 1;
232-
}
231+
int hg_heuristic_moms(Var v) {
232+
return getNbBinaryClause(v);
233+
}
233234

234-
return value;
235-
}
235+
int hg_heuristic_mams(Var v) {
236+
return hg_heuristic_maxo(v) + hg_heuristic_moms(v);
237+
}
236238
};
237239
} // namespace d4

0 commit comments

Comments
 (0)