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:
java.lang.Iterable<Triple<T,T,Relation>>
,java.util.Collection<Triple<T,T,Relation>>
,java.util.Set<Triple<T,T,Relation>>
,BinaryRelation<T>
public class PreferenceOrder<T> extends java.lang.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(java.util.Collection<? extends Triple<T,T,Relation>> relations)
generates a preference order with a given set of elements
-
Method Summary
Modifier and Type Method Description boolean
add(Triple<T,T,Relation> t)
adds a given pair of generic elements to the set.boolean
addAll(java.util.Collection<? extends Triple<T,T,Relation>> c)
adds all given elements to the preference orderboolean
addPair(T f, T s, Relation relation)
adds two given (single) elements as pair into the setvoid
clear()
clears the current preference order element setboolean
compareEqualityWith(PreferenceOrder<T> po)
compares this preference order to another given one whether each relation is contained in bothboolean
contains(java.lang.Object o)
checks whether this preference order contains a given pairboolean
containsAll(java.util.Collection<?> c)
checks, whether all of the given elements are contained in the preference orderboolean
containsRelation(T a, T b)
checks whether this preference order contains a pair of given elementsboolean
containsTriple(T firstElement, T secondElement, Relation relation)
checks whether the given triple is containedboolean
equals(java.lang.Object obj)
Triple<T,T,Relation>
get(Triple<T,T,Relation> e)
checks existence and returns a demanded pairjava.util.Set<T>
getDomainElements()
(re-)computes a set of single elements in this preference orderLevelingFunction<T>
getLevelingFunction()
returns the ranking function for this preference orderTriple<T,T,Relation>
getTriple(T a, T b)
returns a pair if it consists of of two given elementsboolean
isEmpty()
returns whether the set is empty or notboolean
isRelated(T a, T b)
returns whether the elements a and b are relatedboolean
isTotal()
checks whether the set is total or notboolean
isTransitive()
checks whether the given set is transitive or notboolean
isValid()
checks whether the given set represents a valid preference orderjava.util.Iterator<Triple<T,T,Relation>>
iterator()
java.util.Iterator<Triple<T,T,Relation>>
iterator(java.util.Set<Triple<T,T,Relation>> s)
returns an iterator over a set of triplesboolean
remove(java.lang.Object o)
removes specific pair of the setboolean
removeAll(java.util.Collection<?> c)
removes all given elements from the preference orderboolean
retainAll(java.util.Collection<?> c)
int
size()
returns the size of the setvoid
strengthenElementInLF(T element)
strengthens the given element in this preference order in its leveling functionvoid
strengthenElementInRF(T element)
strengthens the given element in this preference order in its ranking functionjava.lang.Object[]
toArray()
returns an array containing all objects<T> T[]
toArray(T[] a)
returns all elements in an arrayjava.lang.String
toString()
returns a String with the elements of this setvoid
weakenElementInLF(T element)
weakens the given element in this preference order in its leveling functionvoid
weakenElementInRF(T element)
weakens the given element in this preference order in its ranking function
-
-
-
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(Triple<T,T,Relation> t)
adds a given pair of generic elements to the set.- Specified by:
add
in interfaceBinaryRelation<T>
- Specified by:
add
in interfacejava.util.Collection<T>
- Specified by:
add
in interfacejava.util.Set<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 java.util.Set<T> getDomainElements()
(re-)computes a set of single elements in this preference order- Specified by:
getDomainElements
in interfaceBinaryRelation<T>
- Returns:
- a set of the single elements in this binary relation
-
remove
public boolean remove(java.lang.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:
isRelated
in 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 java.util.Iterator<Triple<T,T,Relation>> iterator(java.util.Set<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 Triple<T,T,Relation> get(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 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(java.lang.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 java.lang.String toString()
returns a String with the elements of this set- Specified by:
toString
in interfaceBinaryRelation<T>
- Overrides:
toString
in classjava.lang.Object
- Returns:
- a String with the elements of this set
-
toArray
public java.lang.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:
isTotal
in interfaceBinaryRelation<T>
- Returns:
- true if total, false otherwise
-
isTransitive
public boolean isTransitive()
checks whether the given set is transitive or not- Specified by:
isTransitive
in interfaceBinaryRelation<T>
- Returns:
- true if transitive, false otherwise
-
isValid
public boolean isValid()
checks whether the given set represents a valid preference order- Specified by:
isValid
in interfaceBinaryRelation<T>
- Returns:
- true if valid, false if not
-
clear
public void clear()
clears the current preference order element set
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
checks, whether all of the given elements are contained in the preference order
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
removes all given elements from the preference order
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
addAll
public boolean addAll(java.util.Collection<? extends Triple<T,T,Relation>> c)
adds all given elements to the preference order
-
equals
public boolean equals(java.lang.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
-
-