- java.lang.Object
-
- org.logicng.solvers.maxsat.encodings.Encoding
-
- org.logicng.solvers.maxsat.encodings.ModularTotalizer
-
public class ModularTotalizer extends Encoding
Encodes that at most 'rhs' literals can be assigned value true. Uses the modular totalizer encoding for translating the cardinality constraint into CNF.- Since:
- 1.0
- Version:
- 2.0.0
-
-
Field Summary
Fields Modifier and Type Field Description protected LNGIntVectorcardinalityInlitsprotected LNGIntVectorcardinalityLwoutlitsprotected LNGIntVectorcardinalityUpoutlitsprotected intcurrentCardinalityRhsprotected inth0protected static intLIT_ERRORprotected intmodulo
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadder(MiniSatStyleSolver s, int mod, LNGIntVector upper, LNGIntVector lower, LNGIntVector lupper, LNGIntVector llower, LNGIntVector rupper, LNGIntVector rlower)voidencode(MiniSatStyleSolver s, LNGIntVector lits, int rhs)Encodes a cardinality constraint.protected voidencodeOutput(MiniSatStyleSolver s, int rhs)protected voidtoCNF(MiniSatStyleSolver s, int mod, LNGIntVector ublits, LNGIntVector lwlits, int rhs)StringtoString()voidupdate(MiniSatStyleSolver s, int rhs)Updates the right-hand side of the current constraint.
-
-
-
Field Detail
-
LIT_ERROR
protected static final int LIT_ERROR
- See Also:
- Constant Field Values
-
h0
protected final int h0
-
cardinalityUpoutlits
protected final LNGIntVector cardinalityUpoutlits
-
cardinalityLwoutlits
protected final LNGIntVector cardinalityLwoutlits
-
modulo
protected int modulo
-
cardinalityInlits
protected LNGIntVector cardinalityInlits
-
currentCardinalityRhs
protected int currentCardinalityRhs
-
-
Method Detail
-
encode
public void encode(MiniSatStyleSolver s, LNGIntVector lits, int rhs)
Encodes a cardinality constraint.- Parameters:
s- the solverlits- the literals of the constraintrhs- the right-hand side of the constraint
-
update
public void update(MiniSatStyleSolver s, int rhs)
Updates the right-hand side of the current constraint.- Parameters:
s- the solverrhs- the new right-hand side
-
encodeOutput
protected void encodeOutput(MiniSatStyleSolver s, int rhs)
-
toCNF
protected void toCNF(MiniSatStyleSolver s, int mod, LNGIntVector ublits, LNGIntVector lwlits, int rhs)
-
adder
protected void adder(MiniSatStyleSolver s, int mod, LNGIntVector upper, LNGIntVector lower, LNGIntVector lupper, LNGIntVector llower, LNGIntVector rupper, LNGIntVector rlower)
-
-