Closed symphorien closed 3 years ago
It can even be reproduced by setting -fpv
but with no priority variables: on
p cnf 3 2
1 0
2 3 0
with -fpv
the result is wrong:
d4 -fpv=<(echo) -dDNNF -out=/dev/stdout /tmp/.tmpZb7ML3
but without it is correct
d4 -dDNNF -out=/dev/stdout /tmp/.tmpZb7ML3
cc @jm62300 so that you receive an email (asked in https://github.com/crillab/d4/issues/2#issuecomment-793962952)
Actually for projection you cannot use decomposition heuristic. Please test with the option -pv=NO.
Same behavior with -pv=NO
.
Actually I think the problem is that non-projected variables are never decided, and I get better results with
diff --git a/interfaces/VariableHeuristicInterface.cc b/interfaces/VariableHeuristicInterface.cc
index 3966f6b..5092512 100644
--- a/interfaces/VariableHeuristicInterface.cc
+++ b/interfaces/VariableHeuristicInterface.cc
@@ -76,12 +76,12 @@ Var VariableHeuristicInterface::selectVariable(vec<Var> &component)
for(int i = 0 ; i<component.size() ; i++)
{
Var v = component[i];
- if(s.value(v) != l_Undef || !varProjected[v]) continue;
+ if(s.value(v) != l_Undef /*|| !varProjected[v]*/) continue;
double score = sm->computeScore(v);
if(next == var_Undef || score > maxScore){next = v; maxScore = score;}
}
- assert(next == var_Undef || varProjected[next]);
+ /* assert(next == var_Undef || varProjected[next]); */
return next;
}// selectVariable
but then sometimes I get decisions on non-projected variables while some projection variables are not yet set, for example in
p cnf 2 1
1 2 0
(project on 2)
Strange, can you give me the file you pass as parameter for the projected variables.
I use shell substitution, as described above:
d4 -fpv=<(echo 2) -dDNNF -pv=NO -out=/dev/stdout thefile.cnf
I just tested and I got : o 1 0 o 2 0 t 3 0 2 3 -2 1 0 2 3 2 0 1 2 0 s 2
The number of models is correct. About the dDNNF it looks OK since we want to compute the number of models projected on {2}.
v | v ---- 2 ---- T |
---|
-2 | T
Which is equivalent to: v ---- 2 ---- T | -2 |
---|
T
because the root does not contain literals.
did you apply the patch that I posted?
Ah, maybe it's a misunderstanding:
About the dDNNF it looks OK since we want to compute the number of models projected on {2}
I thought d4 would output a dDNNF that is equivalent to the original formula, but with decisions on projected variables "above". Do you mean that it is not the case?
Nope it is not the case, basic projected model counter apply a two phases process that first branch on projected variables and then only asks for satisfiability on the other variables.
I you want to first branch on a set of variables and then consider the other at the end you can simply modify the branching heuristic to do the job. If you need help I can do it.
Thanks. I hacked something together that seems to work. Are you interested in having this functionality upstream? (not right now because it needs clean up and I'm not fluent in c++)
With this cnf formula:
and projection on variable 1, d4 outputs a dDNNF equivalent to just the variable 6:
reproduced on revision f4281153c42d36089feb7d052a309100b2989eed