Skip to content

Question about unlabeled OR nodes #9

@symphorien

Description

@symphorien

I'm intrigued as to why only some OR nodes are labeled with an opposing variable.
The corresponding code is here

//Dimitar Sht. Shterionov: ignoring negative values on OR nodes
if (choiceVar > 0)
out << "O " << choiceVar << " " << children.size();
else
out << "O 0 " << children.size();

and does not explain why only positive literals are valid opposing variables.
I tried to patch this away,

diff --git a/src/src_sharpSAT/MainSolver/DecisionTree.cpp b/src/src_sharpSAT/MainSolver/DecisionTree.cpp
index a9a3f11..6311652 100644
--- a/src/src_sharpSAT/MainSolver/DecisionTree.cpp
+++ b/src/src_sharpSAT/MainSolver/DecisionTree.cpp
@@ -724,8 +724,8 @@ void DTNode::genNNF(ostream & out)
 	else if (DT_OR == type)
 	{
 		//Dimitar Sht. Shterionov: ignoring negative values on OR nodes
-		if (choiceVar > 0)
-			out << "O " << choiceVar << " " << children.size();
+		if (true)
+			out << "O " << std::abs(choiceVar) << " " << children.size();
 		else
 			out << "O 0 " << children.size();
 
diff --git a/src/src_sharpSAT/MainSolver/MainSolver.h b/src/src_sharpSAT/MainSolver/MainSolver.h
index 1eb440c..1ef75cd 100644
--- a/src/src_sharpSAT/MainSolver/MainSolver.h
+++ b/src/src_sharpSAT/MainSolver/MainSolver.h
@@ -333,7 +333,7 @@ public:
 					out << "AND";
 					break;
 				case DT_OR:
-					out << "OR";
+					out << "OR " << node->choiceVar;
 					break;
 				case DT_BOTTOM:
 					out << "F";

but of course this leads to incorrect results:
with

p cnf 4 16
-2 1 4 0
3 1 -4 0
-2 3 -4 0
1 4 3 0
3 -1 -2 0
1 -4 3 0
4 2 3 0
-1 -2 4 0
2 -1 3 0
3 -4 1 0
2 -1 4 0
-4 1 -2 0
3 -4 -2 0
2 3 -4 0
3 2 -4 0
2 -1 -4 0

and priority to variables 2,4 I get

nnf 13 16 4
L -2
L -1
L -4
L 3
A 4 0 1 2 3
L 4
A 2 0 1
L 2
L 1
A 2 7 8
O 0 2 6 9
A 3 5 3 10
O 0 2 4 11

with vanilla dsharp (see the two unlabeled OR nodes)
and with the patched dsharp I get

nnf 13 16 4
L -2
L -1
L -4
L 3
A 4 0 1 2 3
L 4
A 2 0 1
L 2
L 1
A 2 7 8
O 1 2 6 9
A 3 5 3 10
O 3 2 4 11

but the label 3 on the last OR node is incorrect: both branches lead to node 3 (L 3).
graph

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions