Module logicng

Class 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 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 factory
        miniSat - the solver
        proposition - 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.
      • result

        public List<Formula> result()
        Returns the result of this algorithm.
        Returns:
        the result of this algorithm