Class NicePossibleWorld

  • All Implemented Interfaces:
    java.lang.Iterable<Proposition>, java.util.Collection<Proposition>, java.util.Comparator<Pair<Proposition,​java.lang.Boolean>>, Interpretation<PlBeliefSet,​PlFormula>

    public class NicePossibleWorld
    extends InterpretationSet<Proposition,​PlBeliefSet,​PlFormula>
    implements java.util.Comparator<Pair<Proposition,​java.lang.Boolean>>
    Wrapper for the PossibleWorld providing better representation mechanisms, it knows all the possible propositions (the signature) and therefore provides a complete representation that maps a boolean to the Proposition. It also provides ordering of the (proposition, boolean) pairs in the enhanced representation. The default behavior is an alphabetically ordering of the Propositions but it can be changed by the user. Internally it uses the smaller and therefore faster implementation of PossibleWorld for satisfication test
    Author:
    Tim Janus
    • Constructor Detail

      • NicePossibleWorld

        public NicePossibleWorld​(java.util.Collection<Proposition> trueInWorld,
                                 java.util.Collection<Proposition> signature)
        Ctor: Generates the possible world using the given set of true propositions and generated a representation of the possible world using the given signature. The default alphabetically sort behavior is used to order the representation.
        Parameters:
        trueInWorld - A set of propositions describing those propositions that are true in this possible world. It has to be a subset of signature.
        signature - A set of propositions describing all know propositions by the the problem, the signature. It has to be a super set of trueInWorld
      • NicePossibleWorld

        public NicePossibleWorld​(java.util.Collection<Proposition> trueInWorld,
                                 java.util.Collection<Proposition> signature,
                                 java.util.Comparator<Pair<Proposition,​java.lang.Boolean>> comparator)
        Ctor: Generates the possible world using the given set of true propositions and generated a representation of the possible world using the given signature. The sort behavior given in comparator is used to order the representation.
        Parameters:
        trueInWorld - A set of propositions describing those propositions that are true in this possible world. It has to be a subset of signature.
        signature - A set of propositions describing all know propositions by the the problem, the signature. It has to be a super set of trueInWorld
        comparator - The comparator
    • Method Detail

      • setSignature

        public boolean setSignature​(java.util.Collection<Proposition> signature)
        Changes the signature of the world. That means the set of propositions has changed. The new set might contain new propositions and delete old propositions. The representation data structure is updated to reflect the new signature. There is a border case if a Proposition is deleted that is true in this world. Then the world is not representable with the given signature anymore, if this is the case then the representation data structure is cleared.
        Parameters:
        signature - A collection of propositions defining the new signature.
        Returns:
        true if representation is successfully updated and false if the world is not representable by the given signature anymore.
      • setComparator

        public void setComparator​(java.util.Comparator<Pair<Proposition,​java.lang.Boolean>> comparator)
        Changes the used comparator to sort the representation structure and resorts the representation. The default behavior is an alphabetically ordering. The default behavior is selected if null is given as argument or if an instance of the NicePossibleWorld is given as argument.
        Parameters:
        comparator - The new comparator used to sort the representation. If a null is given the default alphabetically ordering is used.
      • getOptimizedWorld

        public PossibleWorld getOptimizedWorld()
        Returns:
        The PossibleWorld instance that is used for satification tests etc.
      • getRepresentationStructure

        public java.util.Set<Pair<Proposition,​java.lang.Boolean>> getRepresentationStructure()
        Returns:
        The representation structure as a set of (proposition, boolean) pairs.
      • satisfies

        public boolean satisfies​(PlFormula formula)
                          throws java.lang.IllegalArgumentException
        Description copied from interface: Interpretation
        Checks whether this interpretation satisfies the given formula.
        Specified by:
        satisfies in interface Interpretation<PlBeliefSet,​PlFormula>
        Parameters:
        formula - a formula .
        Returns:
        "true" if this interpretation satisfies the given formula.
        Throws:
        java.lang.IllegalArgumentException - if the formula does not correspond to the expected language.
      • satisfies

        public boolean satisfies​(PlBeliefSet beliefBase)
                          throws java.lang.IllegalArgumentException
        Description copied from interface: Interpretation
        Checks whether this interpretation satisfies the given knowledge base.
        Specified by:
        satisfies in interface Interpretation<PlBeliefSet,​PlFormula>
        Parameters:
        beliefBase - a knowledge base.
        Returns:
        "true" if this interpretation satisfies the given knowledge base.
        Throws:
        java.lang.IllegalArgumentException - IllegalArgumentException if the knowledgebase does not correspond to the expected language.
      • getAllPossibleWorlds

        public static java.util.Set<NicePossibleWorld> getAllPossibleWorlds​(java.util.Collection<Proposition> signature)