Module logicng

Class GlucoseSyrup


  • public class GlucoseSyrup
    extends MiniSatStyleSolver
    Glucose 4.0 solver.
    Since:
    1.0
    Version:
    2.1.0
    • Field Detail

      • RATIO_REMOVE_CLAUSES

        protected static final int RATIO_REMOVE_CLAUSES
        the ratio of clauses which will be removed
        See Also:
        Constant Field Values
      • LB_BLOCKING_RESTART

        protected static final int LB_BLOCKING_RESTART
        the lower bound for blocking restarts
        See Also:
        Constant Field Values
      • lastDecisionLevel

        protected LNGIntVector lastDecisionLevel
      • myflag

        protected int myflag
      • analyzeLBD

        protected long analyzeLBD
      • analyzeSzWithoutSelectors

        protected int analyzeSzWithoutSelectors
      • nbclausesbeforereduce

        protected int nbclausesbeforereduce
      • conflicts

        protected int conflicts
      • conflictsRestarts

        protected int conflictsRestarts
      • sumLBD

        protected double sumLBD
      • curRestart

        protected int curRestart
      • lbLBDMinimizingClause

        protected int lbLBDMinimizingClause
      • lbLBDFrozenClause

        protected int lbLBDFrozenClause
      • lbSizeMinimizingClause

        protected int lbSizeMinimizingClause
      • firstReduceDB

        protected int firstReduceDB
      • specialIncReduceDB

        protected int specialIncReduceDB
      • incReduceDB

        protected int incReduceDB
      • factorK

        protected double factorK
      • factorR

        protected double factorR
      • sizeLBDQueue

        protected int sizeLBDQueue
      • sizeTrailQueue

        protected int sizeTrailQueue
      • reduceOnSize

        protected boolean reduceOnSize
      • reduceOnSizeSize

        protected int reduceOnSizeSize
      • maxVarDecay

        protected double maxVarDecay
    • Constructor Detail

      • GlucoseSyrup

        public GlucoseSyrup​(MiniSatConfig config,
                            GlucoseConfig glucoseConfig)
        Constructs a new Glucose solver with a given solver configuration.
        Parameters:
        config - the MiniSat configuration
        glucoseConfig - the Glucose configuration
    • Method Detail

      • initializeGlucose

        protected void initializeGlucose()
        Initializes the additional parameters.
      • initializeGlucoseConfig

        protected void initializeGlucoseConfig()
        Initializes the glucose configuration.
      • newVar

        public int newVar​(boolean sign,
                          boolean dvar)
        Description copied from class: MiniSatStyleSolver
        Adds a new variable to the solver.
        Specified by:
        newVar in class MiniSatStyleSolver
        Parameters:
        sign - the initial polarity of the new variable, true if negative, false if positive
        dvar - true if this variable can be used as a decision variable, false if it should not be used as a decision variable
        Returns:
        the index of the new variable
      • addClause

        public boolean addClause​(LNGIntVector ps,
                                 Proposition proposition)
        Description copied from class: MiniSatStyleSolver
        Adds a clause to the solver.
        Specified by:
        addClause in class MiniSatStyleSolver
        Parameters:
        ps - the literals of the clause
        proposition - a proposition (if required for proof tracing)
        Returns:
        true if the clause was added successfully, false otherwise
      • saveState

        public int[] saveState()
        Description copied from class: MiniSatStyleSolver
        Saves and returns the solver state expressed as an integer array which stores the length of the internal data structures.
        Specified by:
        saveState in class MiniSatStyleSolver
        Returns:
        the current solver state
      • loadState

        public void loadState​(int[] state)
        Description copied from class: MiniSatStyleSolver
        Loads a given state in the solver.

        ATTENTION: You can only load a state which was created by this instance of the solver before the current state. Only the sizes of the internal data structures are stored, meaning you can track back in time and restore a solver state with fewer variables and/or fewer clauses. It is not possible to import a solver state from another solver or another solving execution.

        Specified by:
        loadState in class MiniSatStyleSolver
        Parameters:
        state - the solver state to load
      • uncheckedEnqueue

        protected void uncheckedEnqueue​(int lit,
                                        MSClause reason)
        Description copied from class: MiniSatStyleSolver
        Assigns a literal (= a variable to the respective value).
        Specified by:
        uncheckedEnqueue in class MiniSatStyleSolver
        Parameters:
        lit - the literal
        reason - the reason clause of the assignment (conflict resolution) or null if it was a decision
      • attachClause

        protected void attachClause​(MSClause c)
        Description copied from class: MiniSatStyleSolver
        Attaches a given clause to the solver (i.e. the watchers for this clause are initialized).
        Specified by:
        attachClause in class MiniSatStyleSolver
        Parameters:
        c - the clause
      • propagate

        protected MSClause propagate()
        Description copied from class: MiniSatStyleSolver
        Performs unit propagation.
        Specified by:
        propagate in class MiniSatStyleSolver
        Returns:
        the conflicting clause if a conflict arose during unit propagation or null if there was none
      • litRedundant

        protected boolean litRedundant​(int p,
                                       int abstractLevels)
        Description copied from class: MiniSatStyleSolver
        Returns true if a given literal is redundant in the current conflict analysis, false otherwise.
        Specified by:
        litRedundant in class MiniSatStyleSolver
        Parameters:
        p - the literal
        abstractLevels - an abstraction of levels
        Returns:
        true if a given literal is redundant in the current conflict analysis
      • analyzeFinal

        protected void analyzeFinal​(int p,
                                    LNGIntVector outConflict)
        Description copied from class: MiniSatStyleSolver
        Analysis the final conflict if there were assumptions.
        Specified by:
        analyzeFinal in class MiniSatStyleSolver
        Parameters:
        p - the conflicting literal
        outConflict - the vector to store the final conflict
      • reduceDB

        protected void reduceDB()
        Description copied from class: MiniSatStyleSolver
        Reduces the database of learnt clauses. Only clauses of the first half of the clauses with the most activity are possibly removed. A clause is only removed if it is not locked, i.e. is the reason of an assignment for a variable.
        Specified by:
        reduceDB in class MiniSatStyleSolver
      • satisfied

        protected boolean satisfied​(MSClause c)
        Description copied from class: MiniSatStyleSolver
        Returns true if a given clause is satisfied under the current assignment, false otherwise.
        Specified by:
        satisfied in class MiniSatStyleSolver
        Parameters:
        c - the clause
        Returns:
        true if a given clause is satisfied under the current assignment
      • simplify

        protected boolean simplify()
        Description copied from class: MiniSatStyleSolver
        Simplifies the database of clauses. This method is only executed on level 0. All learnt clauses which are satisfied on level 0 are removed. Depending on the configuration of the solver, also original clauses which are satisfied at level 0 are removed.
        Specified by:
        simplify in class MiniSatStyleSolver
        Returns:
        true if simplification was successful and no conflict was found, false if a conflict was found during the simplification
      • computeLBD

        protected long computeLBD​(LNGIntVector lits,
                                  int e)
        Computes the LBD for a given vector of literals.
        Parameters:
        lits - the vector of literals
        e - parameter for incremental mode
        Returns:
        the LBD
      • computeLBD

        protected long computeLBD​(MSClause c)
        Computes the LBD for a given clause
        Parameters:
        c - the clause
        Returns:
        the LBD
      • isSelector

        protected boolean isSelector​(int v)
        Returns true if a given variable is a selector variable, false otherwise.
        Parameters:
        v - the variable
        Returns:
        true if the given variable is a selector variable
      • minimisationWithBinaryResolution

        protected void minimisationWithBinaryResolution​(LNGIntVector outLearnt)
        A special clause minimization by binary resolution for small clauses.
        Parameters:
        outLearnt - the vector where the new learnt 1-UIP clause is stored
      • search

        protected Tristate search()
        The main search procedure of the CDCL algorithm.
        Returns:
        a Tristate representing the result. FALSE if the formula is UNSAT, TRUE if the formula is SAT, and UNKNOWN if the state is not known yet (restart)
      • analyze

        protected void analyze​(MSClause conflictClause,
                               LNGIntVector outLearnt,
                               LNGIntVector selectors)
        Analyzes a given conflict clause wrt. the current solver state. A 1-UIP clause is created during this procedure and the new backtracking level is stored in the solver state.
        Parameters:
        conflictClause - the conflict clause to start the resolution analysis with
        outLearnt - the vector where the new learnt 1-UIP clause is stored
        selectors - a vector of selector variables
      • simplifyClause

        protected void simplifyClause​(LNGIntVector outLearnt,
                                      LNGIntVector selectors)
        Minimizes a given learnt clause depending on the minimization method of the solver configuration.
        Parameters:
        outLearnt - the learnt clause which should be minimized
        selectors - a vector of selector variables
      • isRotatable

        protected boolean isRotatable​(int lit)
        Description copied from class: MiniSatStyleSolver
        Tests the given literal whether it is rotatable in the current model.
        Overrides:
        isRotatable in class MiniSatStyleSolver
        Parameters:
        lit - literal to test
        Returns:
        true if the literal is rotatable, otherwise false