- java.lang.Object
-
- org.logicng.solvers.maxsat.encodings.Encoding
-
- org.logicng.solvers.maxsat.encodings.Totalizer
-
public class Totalizer extends Encoding
Encodes that at most 'rhs' literals can be assigned value true. Uses the totalizer encoding for translating the cardinality constraint into CNF.- Since:
- 1.0
- Version:
- 2.4.0
-
-
Field Summary
Fields Modifier and Type Field Description protected intblockingprotected LNGIntVectorcardinalityInlitsprotected LNGIntVectorcardinalityOutlitsprotected intcurrentCardinalityRhsprotected MaxSATConfig.IncrementalStrategyincrementalStrategyprotected booleanjoinModeprotected LNGVector<LNGIntVector>totalizerIterativeLeftprotected LNGVector<LNGIntVector>totalizerIterativeOutputprotected LNGIntVectortotalizerIterativeRhsprotected LNGVector<LNGIntVector>totalizerIterativeRight
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadder(MiniSatStyleSolver s, LNGIntVector left, LNGIntVector right, LNGIntVector output)voidbuild(MiniSatStyleSolver s, LNGIntVector lits, int rhs)Builds the cardinality constraint.MaxSATConfig.IncrementalStrategyincremental()Returns the incremental strategy.protected voidincremental(MiniSatStyleSolver s, int rhs)LNGIntVectorlits()Returns the totalizer's literals.LNGIntVectoroutputs()Returns the totalizer's output literals.voidsetIncremental(MaxSATConfig.IncrementalStrategy incremental)Sets the incremental strategy.protected voidtoCNF(MiniSatStyleSolver s, LNGIntVector lits)StringtoString()voidupdate(MiniSatStyleSolver s, int rhs)Updates the right-hand side.voidupdate(MiniSatStyleSolver s, int rhs, LNGIntVector assumptions)Updates the right-hand side of a constraint.
-
-
-
Field Detail
-
totalizerIterativeLeft
protected final LNGVector<LNGIntVector> totalizerIterativeLeft
-
totalizerIterativeRight
protected final LNGVector<LNGIntVector> totalizerIterativeRight
-
totalizerIterativeOutput
protected final LNGVector<LNGIntVector> totalizerIterativeOutput
-
totalizerIterativeRhs
protected final LNGIntVector totalizerIterativeRhs
-
blocking
protected final int blocking
-
cardinalityOutlits
protected final LNGIntVector cardinalityOutlits
-
cardinalityInlits
protected LNGIntVector cardinalityInlits
-
incrementalStrategy
protected MaxSATConfig.IncrementalStrategy incrementalStrategy
-
currentCardinalityRhs
protected int currentCardinalityRhs
-
joinMode
protected boolean joinMode
-
-
Method Detail
-
update
public void update(MiniSatStyleSolver s, int rhs)
Updates the right-hand side.- Parameters:
s- the solverrhs- the new right-hand side
-
setIncremental
public void setIncremental(MaxSATConfig.IncrementalStrategy incremental)
Sets the incremental strategy.- Parameters:
incremental- the incremental strategy
-
incremental
public MaxSATConfig.IncrementalStrategy incremental()
Returns the incremental strategy.- Returns:
- the incremental strategy
-
update
public void update(MiniSatStyleSolver s, int rhs, LNGIntVector assumptions)
Updates the right-hand side of a constraint.- Parameters:
s- the solverrhs- the new right-hand sideassumptions- the assumptions- Throws:
IllegalStateException- if the incremental strategy is unknown
-
build
public void build(MiniSatStyleSolver s, LNGIntVector lits, int rhs)
Builds the cardinality constraint.- Parameters:
s- the solverlits- the literals of the constraintrhs- the right-hand side of the constraint
-
toCNF
protected void toCNF(MiniSatStyleSolver s, LNGIntVector lits)
-
adder
protected void adder(MiniSatStyleSolver s, LNGIntVector left, LNGIntVector right, LNGIntVector output)
-
incremental
protected void incremental(MiniSatStyleSolver s, int rhs)
-
lits
public LNGIntVector lits()
Returns the totalizer's literals.- Returns:
- the literals
-
outputs
public LNGIntVector outputs()
Returns the totalizer's output literals.- Returns:
- the literals
-
-