Package net.sf.tweety.preferences
Class PreferenceOrder<T>
- java.lang.Object
-
- net.sf.tweety.preferences.PreferenceOrder<T>
-
- Type Parameters:
T- the generic type of objects/pairs in this preference order
- All Implemented Interfaces:
Iterable<net.sf.tweety.commons.util.Triple<T,T,Relation>>,Collection<net.sf.tweety.commons.util.Triple<T,T,Relation>>,Set<net.sf.tweety.commons.util.Triple<T,T,Relation>>,BinaryRelation<T>
public class PreferenceOrder<T> extends Object implements BinaryRelation<T>
This class extends the BinaryRelation-class with a check for totality and transitivity- Author:
- Bastian Wolf
-
-
Constructor Summary
Constructors Constructor Description PreferenceOrder()Creates an empty HashSet of preference order.PreferenceOrder(Collection<? extends net.sf.tweety.commons.util.Triple<T,T,Relation>> relations)generates a preference order with a given set of elements
-
Method Summary
Modifier and Type Method Description booleanadd(net.sf.tweety.commons.util.Triple<T,T,Relation> t)adds a given pair of generic elements to the set.booleanaddAll(Collection<? extends net.sf.tweety.commons.util.Triple<T,T,Relation>> c)adds all given elements to the preference orderbooleanaddPair(T f, T s, Relation relation)adds two given (single) elements as pair into the setvoidclear()clears the current preference order element setbooleancompareEqualityWith(PreferenceOrder<T> po)compares this preference order to another given one whether each relation is contained in bothbooleancontains(Object o)checks whether this preference order contains a given pairbooleancontainsAll(Collection<?> c)checks, whether all of the given elements are contained in the preference orderbooleancontainsRelation(T a, T b)checks whether this preference order contains a pair of given elementsbooleancontainsTriple(T firstElement, T secondElement, Relation relation)checks whether the given triple is containedbooleanequals(Object obj)net.sf.tweety.commons.util.Triple<T,T,Relation>get(net.sf.tweety.commons.util.Triple<T,T,Relation> e)checks existence and returns a demanded pairSet<T>getDomainElements()(re-)computes a set of single elements in this preference orderLevelingFunction<T>getLevelingFunction()returns the ranking function for this preference ordernet.sf.tweety.commons.util.Triple<T,T,Relation>getTriple(T a, T b)returns a pair if it consists of of two given elementsbooleanisEmpty()returns whether the set is empty or notbooleanisRelated(T a, T b)returns whether the elements a and b are relatedbooleanisTotal()checks whether the set is total or notbooleanisTransitive()checks whether the given set is transitive or notbooleanisValid()checks whether the given set represents a valid preference orderIterator<net.sf.tweety.commons.util.Triple<T,T,Relation>>iterator()Iterator<net.sf.tweety.commons.util.Triple<T,T,Relation>>iterator(Set<net.sf.tweety.commons.util.Triple<T,T,Relation>> s)returns an iterator over a set of triplesbooleanremove(Object o)removes specific pair of the setbooleanremoveAll(Collection<?> c)removes all given elements from the preference orderbooleanretainAll(Collection<?> c)intsize()returns the size of the setvoidstrengthenElementInLF(T element)strengthens the given element in this preference order in its leveling functionvoidstrengthenElementInRF(T element)strengthens the given element in this preference order in its ranking functionObject[]toArray()returns an array containing all objects<T> T[]toArray(T[] a)returns all elements in an arrayStringtoString()returns a String with the elements of this setvoidweakenElementInLF(T element)weakens the given element in this preference order in its leveling functionvoidweakenElementInRF(T element)weakens the given element in this preference order in its ranking function-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
hashCode, spliterator
-
-
-
-
Constructor Detail
-
PreferenceOrder
public PreferenceOrder()
Creates an empty HashSet of preference order.
-
PreferenceOrder
public PreferenceOrder(Collection<? extends net.sf.tweety.commons.util.Triple<T,T,Relation>> relations)
generates a preference order with a given set of elements- Parameters:
relations- the set of given element pairs
-
-
Method Detail
-
getLevelingFunction
public LevelingFunction<T> getLevelingFunction()
returns the ranking function for this preference order- Returns:
- the ranking function for this preference order
-
add
public boolean add(net.sf.tweety.commons.util.Triple<T,T,Relation> t)
adds a given pair of generic elements to the set.- Specified by:
addin interfaceBinaryRelation<T>- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceSet<T>- Parameters:
t- the given set- Returns:
- true if successful, false if not
-
addPair
public boolean addPair(T f, T s, Relation relation)
adds two given (single) elements as pair into the set- Parameters:
f- first element of the new pairs- second element of the new pairrelation- the relation- Returns:
- true if successful, false if not
-
getDomainElements
public Set<T> getDomainElements()
(re-)computes a set of single elements in this preference order- Specified by:
getDomainElementsin interfaceBinaryRelation<T>- Returns:
- a set of the single elements in this binary relation
-
remove
public boolean remove(Object o)
removes specific pair of the set
-
isEmpty
public boolean isEmpty()
returns whether the set is empty or not
-
isRelated
public boolean isRelated(T a, T b)
returns whether the elements a and b are related- Specified by:
isRelatedin interfaceBinaryRelation<T>- Parameters:
a- the first element to be checkedb- the second element to be checked- Returns:
- true if related, false if not.
-
iterator
public Iterator<net.sf.tweety.commons.util.Triple<T,T,Relation>> iterator(Set<net.sf.tweety.commons.util.Triple<T,T,Relation>> s)
returns an iterator over a set of triples- Parameters:
s- a set of triples- Returns:
- an iterator over a set of triples
-
get
public net.sf.tweety.commons.util.Triple<T,T,Relation> get(net.sf.tweety.commons.util.Triple<T,T,Relation> e)
checks existence and returns a demanded pair- Parameters:
e- the demanded pair- Returns:
- a pair if it exists, null otherwise
-
getTriple
public net.sf.tweety.commons.util.Triple<T,T,Relation> getTriple(T a, T b)
returns a pair if it consists of of two given elements- Parameters:
a- the first elementb- the second element- Returns:
- a pair if found, null if not
-
containsRelation
public boolean containsRelation(T a, T b)
checks whether this preference order contains a pair of given elements- Parameters:
a- the first elementb- the second element- Returns:
- true if pair is in this preference order, false if not
-
contains
public boolean contains(Object o)
checks whether this preference order contains a given pair
-
containsTriple
public boolean containsTriple(T firstElement, T secondElement, Relation relation)
checks whether the given triple is contained- Parameters:
firstElement- the first elementsecondElement- the second elementrelation- the relation- Returns:
- true iff the given triple is contained
-
size
public int size()
returns the size of the set
-
toString
public String toString()
returns a String with the elements of this set- Specified by:
toStringin interfaceBinaryRelation<T>- Overrides:
toStringin classObject- Returns:
- a String with the elements of this set
-
toArray
public Object[] toArray()
returns an array containing all objects
-
toArray
public <T> T[] toArray(T[] a)
returns all elements in an array
-
isTotal
public boolean isTotal()
checks whether the set is total or not- Specified by:
isTotalin interfaceBinaryRelation<T>- Returns:
- true if total, false otherwise
-
isTransitive
public boolean isTransitive()
checks whether the given set is transitive or not- Specified by:
isTransitivein interfaceBinaryRelation<T>- Returns:
- true if transitive, false otherwise
-
isValid
public boolean isValid()
checks whether the given set represents a valid preference order- Specified by:
isValidin interfaceBinaryRelation<T>- Returns:
- true if valid, false if not
-
clear
public void clear()
clears the current preference order element set
-
containsAll
public boolean containsAll(Collection<?> c)
checks, whether all of the given elements are contained in the preference order- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceSet<T>- Returns:
- true iff all elements are contained, false otherwise
-
removeAll
public boolean removeAll(Collection<?> c)
removes all given elements from the preference order
-
retainAll
public boolean retainAll(Collection<?> c)
-
addAll
public boolean addAll(Collection<? extends net.sf.tweety.commons.util.Triple<T,T,Relation>> c)
adds all given elements to the preference order
-
equals
public boolean equals(Object obj)
-
compareEqualityWith
public boolean compareEqualityWith(PreferenceOrder<T> po)
compares this preference order to another given one whether each relation is contained in both- Parameters:
po- the preference order to compare with- Returns:
- true if both are equal, false if not
-
weakenElementInLF
public void weakenElementInLF(T element)
weakens the given element in this preference order in its leveling function- Parameters:
element- the element to be weaken
-
strengthenElementInLF
public void strengthenElementInLF(T element)
strengthens the given element in this preference order in its leveling function- Parameters:
element- the element to be strengthen
-
weakenElementInRF
public void weakenElementInRF(T element)
weakens the given element in this preference order in its ranking function- Parameters:
element- the element to be weaken
-
strengthenElementInRF
public void strengthenElementInRF(T element)
strengthens the given element in this preference order in its ranking function- Parameters:
element- the element to be strengthen
-
-