Module logicng

Class MaxSAT

    • Constructor Detail

      • MaxSAT

        protected MaxSAT​(MaxSATConfig config)
        Constructor.
        Parameters:
        config - the solver configuration
    • Method Detail

      • newSATVariable

        public static void newSATVariable​(MiniSatStyleSolver s)
        Creates a new variable in the SAT solver.
        Parameters:
        s - the SAT solver
      • searchSATSolver

        public static Tristate searchSATSolver​(MiniSatStyleSolver s,
                                               SATHandler satHandler,
                                               LNGIntVector assumptions)
        Solves the formula that is currently loaded in the SAT solver with a set of assumptions.
        Parameters:
        s - the SAT solver
        satHandler - a SAT handler
        assumptions - the assumptions
        Returns:
        the result of the solving process
      • searchSATSolver

        public static Tristate searchSATSolver​(MiniSatStyleSolver s,
                                               SATHandler satHandler)
        Solves the formula without assumptions.
        Parameters:
        s - the SAT solver
        satHandler - a SAT handler
        Returns:
        the result of the solving process
      • nVars

        public int nVars()
        Returns the number of variables in the working MaxSAT formula.
        Returns:
        the number of variables in the working MaxSAT formula
      • nSoft

        public int nSoft()
        Returns the number of soft clauses in the working MaxSAT formula.
        Returns:
        the number of soft clauses in the working MaxSAT formula
      • nHard

        public int nHard()
        Returns the number of hard clauses in the working MaxSAT formula.
        Returns:
        the number of hard clauses in the working MaxSAT formula
      • newVar

        public void newVar()
        Increases the number of variables in the working MaxSAT formula.
      • addHardClause

        public void addHardClause​(LNGIntVector lits)
        Adds a new hard clause to the hard clause database.
        Parameters:
        lits - the literals of the hard clause
      • addSoftClause

        public void addSoftClause​(int weight,
                                  LNGIntVector lits)
        Adds a new soft clause to the soft clause database.
        Parameters:
        weight - the weight of the soft clause
        lits - the literals of the soft clause
      • addSoftClause

        public void addSoftClause​(int weight,
                                  LNGIntVector lits,
                                  LNGIntVector vars)
        Adds a new soft clause to the soft clause database with predefined relaxation variables.
        Parameters:
        weight - the weight of the soft clause
        lits - the literals of the soft clause
        vars - the relaxation variables of the soft clause
      • newLiteral

        public int newLiteral​(boolean sign)
        Creates a new literal to be used in the working MaxSAT formula.
        Parameters:
        sign - the sign of the literal
        Returns:
        the new literal
      • setProblemType

        public void setProblemType​(MaxSAT.ProblemType type)
        Sets the problem type.
        Parameters:
        type - the problem type
      • updateSumWeights

        public void updateSumWeights​(int weight)
        Initializes 'ubCost' to the sum of weights of the soft clauses
        Parameters:
        weight - the weight
      • setCurrentWeight

        public void setCurrentWeight​(int weight)
        Initializes the current weight to the maximum weight of the soft clauses.
        Parameters:
        weight - the weight
      • currentWeight

        public int currentWeight()
        Returns the current weight.
        Returns:
        the current weight
      • newSATSolver

        public MiniSatStyleSolver newSATSolver()
        Creates an empty SAT Solver.
        Returns:
        the empty SAT solver
      • saveModel

        public void saveModel​(LNGBooleanVector currentModel)
        Saves the current model found by the SAT solver.
        Parameters:
        currentModel - the model found by the solver
      • computeCostModel

        public int computeCostModel​(LNGBooleanVector currentModel,
                                    int weight)
        Computes the cost of a given model. The cost of a model is the sum of the weights of the unsatisfied soft clauses. If a weight is specified, then it only considers the sum of the weights of the unsatisfied soft clauses with the specified weight.
        Parameters:
        currentModel - the model
        weight - the weight
        Returns:
        the cost of the given model
      • isBMO

        public boolean isBMO​(boolean cache)
        Tests if the MaxSAT formula has lexicographical optimization criterion.
        Parameters:
        cache - is indicates whether the result should be cached.
        Returns:
        true if the formula has lexicographical optimization criterion
      • stats

        public MaxSAT.Stats stats()
        Returns the stats of this solver instance.
        Returns:
        the stats of this solver instance
      • result

        public int result()
        Returns the optimal result of the solver.
        Returns:
        the optimal result of the solver
      • model

        public LNGBooleanVector model()
        Returns the model of the solver.
        Returns:
        the model of the solver