Package org.ddolib.examples.max2sat
Class BinaryClause
java.lang.Object
org.ddolib.examples.max2sat.BinaryClause
- All Implemented Interfaces:
Comparable<BinaryClause>
Class to model a Binary clause of two literals for CNF formula.
To symbolize a literal x_i , for i > 0, we give the value i as
input. To symbolize NOT x_i, we give -i.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
i
public final int i -
j
public final int j
-
-
Constructor Details
-
BinaryClause
public BinaryClause(int i, int j)
-
-
Method Details
-
eval
public int eval(int a, int b) Evaluates if the clause is verified given 2 boolean values.- Parameters:
a- The value to attribute to the variablex_i(0 or 1).b- The value to attribute to the variablex_j(0 or 1).- Returns:
- 1 if the clause is verified. 0 else.
-
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
Used to compare binary clauses. It is used to sort them when generating Max2Sat instances.
The induced order is the following:- The lexical order on the literals' indices.
- The positive literal before the negative ones.
- Specified by:
compareToin interfaceComparable<BinaryClause>- Parameters:
other- The binary clause to be compared.- Returns:
-
0if ifthis == other 1ifthis > other-1ifthis < other
-
-