Class NicePossibleWorld
java.lang.Object
org.tweetyproject.commons.AbstractInterpretation<PlBeliefSet,PlFormula>
org.tweetyproject.commons.InterpretationSet<Proposition,PlBeliefSet,PlFormula>
org.tweetyproject.logics.pl.semantics.NicePossibleWorld
- All Implemented Interfaces:
Iterable<Proposition>
,Collection<Proposition>
,Comparator<Pair<Proposition,
,Boolean>> Interpretation<PlBeliefSet,
PlFormula>
public class NicePossibleWorld
extends InterpretationSet<Proposition,PlBeliefSet,PlFormula>
implements Comparator<Pair<Proposition,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 Summary
ConstructorDescriptionNicePossibleWorld
(Collection<Proposition> trueInWorld, 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.NicePossibleWorld
(Collection<Proposition> trueInWorld, Collection<Proposition> signature, Comparator<Pair<Proposition, 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. -
Method Summary
Modifier and TypeMethodDescriptionint
compare
(Pair<Proposition, Boolean> o1, Pair<Proposition, Boolean> o2) boolean
static Set
<NicePossibleWorld> getAllPossibleWorlds
(Collection<Proposition> signature) Return all possible nice worldsReturn The PossibleWorld instance that is used for satification tests etc.Return The representation structure as a set of (proposition, boolean)int
hashCode()
boolean
satisfies
(PlBeliefSet beliefBase) Checks whether this interpretation satisfies the given knowledge base.boolean
Checks whether this interpretation satisfies the given formula.void
setComparator
(Comparator<Pair<Proposition, Boolean>> comparator) Changes the used comparator to sort the representation structure and resorts the representation.boolean
setSignature
(Collection<Proposition> signature) Changes the signature of the world.toString()
Methods inherited from class org.tweetyproject.commons.InterpretationSet
add, add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
Methods inherited from class org.tweetyproject.commons.AbstractInterpretation
satisfies
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
NicePossibleWorld
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(Collection<Proposition> trueInWorld, Collection<Proposition> signature, Comparator<Pair<Proposition, 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 trueInWorldcomparator
- The comparator
-
-
Method Details
-
setSignature
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
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
Return The PossibleWorld instance that is used for satification tests etc.- Returns:
- The PossibleWorld instance that is used for satification tests etc.
-
getRepresentationStructure
Return The representation structure as a set of (proposition, boolean)- Returns:
- The representation structure as a set of (proposition, boolean) pairs.
-
satisfies
Description copied from interface:Interpretation
Checks whether this interpretation satisfies the given formula.- Specified by:
satisfies
in interfaceInterpretation<PlBeliefSet,
PlFormula> - Parameters:
formula
- a formula .- Returns:
- "true" if this interpretation satisfies the given formula.
- Throws:
IllegalArgumentException
- if the formula does not correspond to the expected language.
-
satisfies
Description copied from interface:Interpretation
Checks whether this interpretation satisfies the given knowledge base.- Specified by:
satisfies
in interfaceInterpretation<PlBeliefSet,
PlFormula> - Parameters:
beliefBase
- a knowledge base.- Returns:
- "true" if this interpretation satisfies the given knowledge base.
- Throws:
IllegalArgumentException
- IllegalArgumentException if the knowledgebase does not correspond to the expected language.
-
equals
- Specified by:
equals
in interfaceCollection<Proposition>
- Specified by:
equals
in interfaceComparator<Pair<Proposition,
Boolean>> - Overrides:
equals
in classInterpretationSet<Proposition,
PlBeliefSet, PlFormula>
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<Proposition>
- Overrides:
hashCode
in classInterpretationSet<Proposition,
PlBeliefSet, PlFormula>
-
toString
- Overrides:
toString
in classInterpretationSet<Proposition,
PlBeliefSet, PlFormula>
-
compare
- Specified by:
compare
in interfaceComparator<Pair<Proposition,
Boolean>>
-
getAllPossibleWorlds
Return all possible nice worlds- Parameters:
signature
- collection of propositions- Returns:
- all possible nice worlds
-