Module logicng

Class MSClause


  • public final class MSClause
    extends Object
    A clause of the SAT solver for MiniSAT-style solvers.
    Since:
    1.0
    Version:
    2.0.0
    • Constructor Summary

      Constructors 
      Constructor Description
      MSClause​(LNGIntVector ps, boolean learnt)
      Constructs a new clause
      MSClause​(LNGIntVector ps, boolean learnt, boolean isAtMost)
      Constructs a new clause
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double activity()
      Returns the activity of this clause.
      int atMostWatchers()
      Returns the number of watchers if this is an at-most clause.
      boolean canBeDel()
      Returns true if this clause can be deleted, false otherwise.
      int cardinality()
      Returns the right-hand k side of an at-most k constraint.
      boolean equals​(Object o)  
      int get​(int i)
      Returns the literal at index i.
      int hashCode()  
      void incrementActivity​(double inc)
      Increments this clause's activity by a given value
      boolean isAtMost()
      Returns true if this is an at-most clause, false otherwise.
      long lbd()
      Returns the LBD of this clause.
      boolean learnt()
      Returns true if this clause is learnt, false otherwise.
      boolean oneWatched()
      Returns true if this clause is a one literal watched clause, false otherwise
      void pop()
      Pops (removes) the last literal of this clause.
      void rescaleActivity()
      Rescales this clause's activity
      boolean seen()
      Returns true if this clause is marked 'seen', false otherwise.
      void set​(int i, int lit)
      Sets the literal at index i.
      void setAtMostWatchers​(int atMostWatchers)
      Sets the number of watchers for this at-most clause.
      void setCanBeDel​(boolean canBeDel)
      Sets whether this clause can be deleted or not.
      void setLBD​(long lbd)
      Sets the LBD of this clause.
      void setOneWatched​(boolean oneWatched)
      Sets whether this clause is a one literal watched clause or not.
      void setSeen​(boolean seen)
      Marks this clause with the given 'seen' flag.
      void setSizeWithoutSelectors​(int szWithoutSelectors)
      Sets the size of this clause without selector variables.
      int size()
      Returns the size (number of literals) of this clause.
      int sizeWithoutSelectors()
      Returns the size of this clause without selector variables.
      String toString()  
    • Field Detail

      • glucoseComparator

        public static final Comparator<MSClause> glucoseComparator
        A comparator for clauses based on LBD and activity (used for the Glucose solver).
      • minisatComparator

        public static final Comparator<MSClause> minisatComparator
        A comparator for clauses based on activity (used for the MiniSAT solver).
    • Constructor Detail

      • MSClause

        public MSClause​(LNGIntVector ps,
                        boolean learnt)
        Constructs a new clause
        Parameters:
        ps - the vector of literals
        learnt - true if it is a learnt clause, false otherwise
      • MSClause

        public MSClause​(LNGIntVector ps,
                        boolean learnt,
                        boolean isAtMost)
        Constructs a new clause
        Parameters:
        ps - the vector of literals
        learnt - true if it is a learnt clause, false otherwise
        isAtMost - true if it is an at-most clause, false otherwise
    • Method Detail

      • size

        public int size()
        Returns the size (number of literals) of this clause.
        Returns:
        the size
      • get

        public int get​(int i)
        Returns the literal at index i.
        Parameters:
        i - the index
        Returns:
        the literal at index i
      • set

        public void set​(int i,
                        int lit)
        Sets the literal at index i.
        Parameters:
        i - the index
        lit - the literal
      • activity

        public double activity()
        Returns the activity of this clause.
        Returns:
        the activity of this clause
      • incrementActivity

        public void incrementActivity​(double inc)
        Increments this clause's activity by a given value
        Parameters:
        inc - the increment value
      • rescaleActivity

        public void rescaleActivity()
        Rescales this clause's activity
      • learnt

        public boolean learnt()
        Returns true if this clause is learnt, false otherwise.
        Returns:
        true if this clause is learnt
      • sizeWithoutSelectors

        public int sizeWithoutSelectors()
        Returns the size of this clause without selector variables.
        Returns:
        the size of this clause without selector variables
      • setSizeWithoutSelectors

        public void setSizeWithoutSelectors​(int szWithoutSelectors)
        Sets the size of this clause without selector variables.
        Parameters:
        szWithoutSelectors - the size of this clause without selector variables
      • seen

        public boolean seen()
        Returns true if this clause is marked 'seen', false otherwise.
        Returns:
        true if this clause is marked 'seen'
      • setSeen

        public void setSeen​(boolean seen)
        Marks this clause with the given 'seen' flag.
        Parameters:
        seen - the 'seen' flag
      • lbd

        public long lbd()
        Returns the LBD of this clause.
        Returns:
        the LBD of this clause
      • setLBD

        public void setLBD​(long lbd)
        Sets the LBD of this clause.
        Parameters:
        lbd - the LBD of this clause
      • canBeDel

        public boolean canBeDel()
        Returns true if this clause can be deleted, false otherwise.
        Returns:
        true if this clause can be deleted
      • setCanBeDel

        public void setCanBeDel​(boolean canBeDel)
        Sets whether this clause can be deleted or not.
        Parameters:
        canBeDel - true if it can be deleted, false otherwise
      • oneWatched

        public boolean oneWatched()
        Returns true if this clause is a one literal watched clause, false otherwise
        Returns:
        true if this clause is a one literal watched clause
      • setOneWatched

        public void setOneWatched​(boolean oneWatched)
        Sets whether this clause is a one literal watched clause or not.
        Parameters:
        oneWatched - true if it is a one literal watched clause, false otherwise
      • isAtMost

        public boolean isAtMost()
        Returns true if this is an at-most clause, false otherwise.
        Returns:
        true if this is an at-most clause
      • atMostWatchers

        public int atMostWatchers()
        Returns the number of watchers if this is an at-most clause.
        Returns:
        the number of watchers
      • setAtMostWatchers

        public void setAtMostWatchers​(int atMostWatchers)
        Sets the number of watchers for this at-most clause.
        Parameters:
        atMostWatchers - the number of watchers
      • pop

        public void pop()
        Pops (removes) the last literal of this clause.
      • cardinality

        public int cardinality()
        Returns the right-hand k side of an at-most k constraint.
        Returns:
        the right-hand side
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object