Class CanonicalIterator

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.math.BigInteger next
      The next value used for compiling a knowledge base.
      private java.math.BigInteger upperBoundIndex
      The upper bound used for enumerating knowledge bases.
    • Constructor Summary

      Constructors 
      Constructor Description
      CanonicalIterator()
      Default constructor.
      CanonicalIterator​(java.lang.Integer startIndex)
      Creates a new enumerator that enumerates knowledge bases starting from the given index
      CanonicalIterator​(java.lang.Integer startIndex, java.lang.Integer endIndex)
      Creates a new enumerator that enumerates knowledge bases starting from the given start index up to the given end index (including)
      CanonicalIterator​(java.lang.Long startIndex)
      Creates a new enumerator that enumerates knowledge bases starting from the given index
      CanonicalIterator​(java.lang.Long startIndex, java.lang.Long endIndex)
      Creates a new enumerator that enumerates knowledge bases starting from the given start index up to the given end index (including)
      CanonicalIterator​(java.math.BigInteger startIndex)
      Creates a new enumerator that enumerates knowledge bases starting from the given index
      CanonicalIterator​(java.math.BigInteger startIndex, java.math.BigInteger endIndex)
      Creates a new enumerator that enumerates knowledge bases starting from the given start index up to the given end index (including)
    • Method Summary

      Modifier and Type Method Description
      static java.util.BitSet beliefSet2BitSet​(PlBeliefSet bs)
      Creates a bitset representation of the given belief set.
      private PlBeliefSet bitset2BeliefSet​(java.util.BitSet s)
      Parses a knowledge base (PlBeliefSet) from the the given bitset.
      private static java.lang.String formula2String​(PlFormula f, java.util.Map<Proposition,​java.lang.Integer> prop)
      Encodes the given formula as a bitstring.
      private void gotoNextValidIndex()
      Sets this.next to the next value actually encoding a belief base (or to this.upperBoundIndex if set).
      boolean hasNext()  
      private boolean isLessThan​(java.util.BitSet s, boolean equal, int i, int j, int k, int l)
      Checks whether the bitvector at positions [i,...,j] is less than the bitvector at positions [k,...,l].
      PlBeliefSet next()  
      java.math.BigInteger nextIndex()
      Returns the index of the next element.
      private Pair<java.util.Collection<PlFormula>,​java.lang.Integer> parseAssociativeFormula​(java.util.BitSet s, int idx, int numOfTerms, PlSignature sig)
      Parses an associate formula from the given bitset starting at index idx, with the given number of terms and the given signature
      private Pair<PlFormula,​java.lang.Integer> parseFormula​(java.util.BitSet s, int idx, PlSignature sig)
      Reads the next formula of the given bitset, starting at the given index.
      private Pair<PlFormula,​java.lang.Integer> parseProposition​(java.util.BitSet s, int idx, PlSignature sig)
      Parses a proposition in bitset s starting from idx.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, remove
    • Field Detail

      • upperBoundIndex

        private java.math.BigInteger upperBoundIndex
        The upper bound used for enumerating knowledge bases.
      • next

        private java.math.BigInteger next
        The next value used for compiling a knowledge base.
    • Constructor Detail

      • CanonicalIterator

        public CanonicalIterator()
        Default constructor. Creates an enumerator that enumerates knowledge bases starting from index 1.
      • CanonicalIterator

        public CanonicalIterator​(java.lang.Long startIndex)
        Creates a new enumerator that enumerates knowledge bases starting from the given index
        Parameters:
        startIndex - some integer value
      • CanonicalIterator

        public CanonicalIterator​(java.lang.Integer startIndex)
        Creates a new enumerator that enumerates knowledge bases starting from the given index
        Parameters:
        startIndex - some integer value
      • CanonicalIterator

        public CanonicalIterator​(java.math.BigInteger startIndex)
        Creates a new enumerator that enumerates knowledge bases starting from the given index
        Parameters:
        startIndex - some integer value
      • CanonicalIterator

        public CanonicalIterator​(java.lang.Long startIndex,
                                 java.lang.Long endIndex)
        Creates a new enumerator that enumerates knowledge bases starting from the given start index up to the given end index (including)
        Parameters:
        startIndex - some integer value
        endIndex - some integer value
      • CanonicalIterator

        public CanonicalIterator​(java.lang.Integer startIndex,
                                 java.lang.Integer endIndex)
        Creates a new enumerator that enumerates knowledge bases starting from the given start index up to the given end index (including)
        Parameters:
        startIndex - some integer value
        endIndex - some integer value
      • CanonicalIterator

        public CanonicalIterator​(java.math.BigInteger startIndex,
                                 java.math.BigInteger endIndex)
        Creates a new enumerator that enumerates knowledge bases starting from the given start index up to the given end index (including)
        Parameters:
        startIndex - some integer value
        endIndex - some integer value
    • Method Detail

      • gotoNextValidIndex

        private void gotoNextValidIndex()
        Sets this.next to the next value actually encoding a belief base (or to this.upperBoundIndex if set).
      • isLessThan

        private boolean isLessThan​(java.util.BitSet s,
                                   boolean equal,
                                   int i,
                                   int j,
                                   int k,
                                   int l)
        Checks whether the bitvector at positions [i,...,j] is less than the bitvector at positions [k,...,l]. If equal=true, "less" is substituted by "less or equal".
        Parameters:
        s - some bitset
        equal - whether equality is allowed
        i - start index of first bitvector (including)
        j - end index of first bitvector (including)
        k - start index of second bitvector (including)
        l - end index of second bitvector (including)
        Returns:
        "true" if [i,...,j] is less (or equal) [k,...,l]
      • parseAssociativeFormula

        private Pair<java.util.Collection<PlFormula>,​java.lang.Integer> parseAssociativeFormula​(java.util.BitSet s,
                                                                                                      int idx,
                                                                                                      int numOfTerms,
                                                                                                      PlSignature sig)
        Parses an associate formula from the given bitset starting at index idx, with the given number of terms and the given signature
        Parameters:
        s - some bitset
        idx - the starting index of the formula to be parsed
        numOfTerms - the number of terms to be parsed
        sig - the current signature
        Returns:
        the set of parsed terms and the index position in s after this formula
      • parseProposition

        private Pair<PlFormula,​java.lang.Integer> parseProposition​(java.util.BitSet s,
                                                                         int idx,
                                                                         PlSignature sig)
        Parses a proposition in bitset s starting from idx.
        Parameters:
        s - some bitset
        idx - the starting index of the proposition
        sig - the current signature
        Returns:
        the formula parsed and the index in s after this formula
      • parseFormula

        private Pair<PlFormula,​java.lang.Integer> parseFormula​(java.util.BitSet s,
                                                                     int idx,
                                                                     PlSignature sig)
        Reads the next formula of the given bitset, starting at the given index.
        Parameters:
        s - a bitset
        idx - the start index of a formula
        sig - the current signature
        Returns:
        the formula that has been read and the index right in the bitset right after this formula; if the bitset if invalid, "null" is returned
      • bitset2BeliefSet

        private PlBeliefSet bitset2BeliefSet​(java.util.BitSet s)
        Parses a knowledge base (PlBeliefSet) from the the given bitset. If the bitset does not encode a PlBeliefSet, null is returned
        Parameters:
        s - some bitset
        Returns:
        the knowledge base encoded by the bitset, or null.
      • nextIndex

        public java.math.BigInteger nextIndex()
        Returns the index of the next element.
        Returns:
        the index of the next element.
      • formula2String

        private static java.lang.String formula2String​(PlFormula f,
                                                       java.util.Map<Proposition,​java.lang.Integer> prop)
        Encodes the given formula as a bitstring.
        Parameters:
        f - some formula
        prop - map of propositions to their indices
        Returns:
        a bitstring representing the formula
      • beliefSet2BitSet

        public static java.util.BitSet beliefSet2BitSet​(PlBeliefSet bs)
        Creates a bitset representation of the given belief set.
        Parameters:
        bs - some belief set
        Returns:
        a bitset representation of the belief set