- java.lang.Object
-
- org.logicng.datastructures.EncodingResult
-
public final class EncodingResult extends Object
The result of an encoding.Encodings (normal forms, cardinality constraints, pseudo-Boolean constraint) are often used only when adding formulas to the SAT solver. Therefore, it is not necessary to generate all the formulas required for the encoding in the formula factory and therefore polluting the factory and the heap. This class can be used to connect an encoding directly with a SAT solver and therefore introducing the variables only on the solver - not in the factory. When working with many encodings, this can be a large performance gain.
- Since:
- 1.1
- Version:
- 2.0.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddClause(LNGVector<Literal> literals)Adds a clause to the resultvoidaddClause(Literal... literals)Adds a clause to the resultVariablenewVariable()Returns a new auxiliary variable.voidreset()Resets the result.List<Formula>result()Returns the result of this algorithm.static EncodingResultresultForFormula(FormulaFactory f)Constructs a new result which stores the result in a formula.static EncodingResultresultForMiniSat(FormulaFactory f, MiniSat miniSat, Proposition proposition)Constructs a new result which adds the result directly to a given MiniSat solver.
-
-
-
Method Detail
-
resultForFormula
public static EncodingResult resultForFormula(FormulaFactory f)
Constructs a new result which stores the result in a formula.- Parameters:
f- the formula factory- Returns:
- the result
-
resultForMiniSat
public static EncodingResult resultForMiniSat(FormulaFactory f, MiniSat miniSat, Proposition proposition)
Constructs a new result which adds the result directly to a given MiniSat solver.- Parameters:
f- the formula factoryminiSat- the solverproposition- the original proposition of the cardinality constraint- Returns:
- the result
-
addClause
public void addClause(Literal... literals)
Adds a clause to the result- Parameters:
literals- the literals of the clause
-
addClause
public void addClause(LNGVector<Literal> literals)
Adds a clause to the result- Parameters:
literals- the literals of the clause
-
newVariable
public Variable newVariable()
Returns a new auxiliary variable.- Returns:
- a new auxiliary variable
-
reset
public void reset()
Resets the result.
-
-