Class PreferenceOrder<T>

java.lang.Object
org.tweetyproject.preferences.PreferenceOrder<T>
Type Parameters:
T - the generic type of objects/pairs in this preference order
All Implemented Interfaces:
Iterable<Triple<T,​T,​Relation>>, Collection<Triple<T,​T,​Relation>>, Set<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 Details

    • PreferenceOrder

      public PreferenceOrder()
      Creates an empty HashSet of preference order.
    • PreferenceOrder

      public PreferenceOrder(Collection<? extends Triple<T,​T,​Relation>> relations)
      generates a preference order with a given set of elements
      Parameters:
      relations - the set of given element pairs
  • Method Details

    • 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 interface BinaryRelation<T>
      Specified by:
      add in interface Collection<T>
      Specified by:
      add in interface 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 pair
      s - second element of the new pair
      relation - 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:
      getDomainElements in interface BinaryRelation<T>
      Returns:
      a set of the single elements in this binary relation
    • remove

      public boolean remove(Object o)
      removes specific pair of the set
      Specified by:
      remove in interface Collection<T>
      Specified by:
      remove in interface Set<T>
      Parameters:
      o - the pair to be removed
      Returns:
      true if successful, false if not
    • isEmpty

      public boolean isEmpty()
      returns whether the set is empty or not
      Specified by:
      isEmpty in interface Collection<T>
      Specified by:
      isEmpty in interface Set<T>
      Returns:
      true if empty, false if not
    • isRelated

      public boolean isRelated(T a, T b)
      returns whether the elements a and b are related
      Specified by:
      isRelated in interface BinaryRelation<T>
      Parameters:
      a - the first element to be checked
      b - the second element to be checked
      Returns:
      true if related, false if not.
    • iterator

      public Iterator<Triple<T,​T,​Relation>> iterator(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 element
      b - 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 element
      b - 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
      Specified by:
      contains in interface Collection<T>
      Specified by:
      contains in interface Set<T>
      Parameters:
      o - the given pair
      Returns:
      true if pair is in this preference order, false if not
    • containsTriple

      public boolean containsTriple(T firstElement, T secondElement, Relation relation)
      checks whether the given triple is contained
      Parameters:
      firstElement - the first element
      secondElement - the second element
      relation - the relation
      Returns:
      true iff the given triple is contained
    • size

      public int size()
      returns the size of the set
      Specified by:
      size in interface Collection<T>
      Specified by:
      size in interface Set<T>
      Returns:
      the size of the set
    • toString

      public String toString()
      returns a String with the elements of this set
      Specified by:
      toString in interface BinaryRelation<T>
      Overrides:
      toString in class Object
      Returns:
      a String with the elements of this set
    • toArray

      public Object[] toArray()
      returns an array containing all objects
      Specified by:
      toArray in interface Collection<T>
      Specified by:
      toArray in interface Set<T>
      Returns:
      the Object[]-array
    • toArray

      public <T> T[] toArray(T[] a)
      returns all elements in an array
      Specified by:
      toArray in interface Collection<T>
      Specified by:
      toArray in interface Set<T>
      Parameters:
      a - is a given array
      Returns:
      an array
    • isTotal

      public boolean isTotal()
      checks whether the set is total or not
      Specified by:
      isTotal in interface BinaryRelation<T>
      Returns:
      true if total, false otherwise
    • isTransitive

      public boolean isTransitive()
      checks whether the given set is transitive or not
      Specified by:
      isTransitive in interface BinaryRelation<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 interface BinaryRelation<T>
      Returns:
      true if valid, false if not
    • clear

      public void clear()
      clears the current preference order element set
      Specified by:
      clear in interface Collection<T>
      Specified by:
      clear in interface Set<T>
    • containsAll

      public boolean containsAll(Collection<?> c)
      checks, whether all of the given elements are contained in the preference order
      Specified by:
      containsAll in interface Collection<T>
      Specified by:
      containsAll in interface Set<T>
      Returns:
      true iff all elements are contained, false otherwise
    • removeAll

      public boolean removeAll(Collection<?> c)
      removes all given elements from the preference order
      Specified by:
      removeAll in interface Collection<T>
      Specified by:
      removeAll in interface Set<T>
      Returns:
      true if elements-set has changed, false if not
    • retainAll

      public boolean retainAll(Collection<?> c)
      Specified by:
      retainAll in interface Collection<T>
      Specified by:
      retainAll in interface Set<T>
    • addAll

      public boolean addAll(Collection<? extends Triple<T,​T,​Relation>> c)
      adds all given elements to the preference order
      Specified by:
      addAll in interface Collection<T>
      Specified by:
      addAll in interface Set<T>
      Returns:
      true if element-set changed, false if not
    • iterator

      public Iterator<Triple<T,​T,​Relation>> iterator()
      Specified by:
      iterator in interface Collection<T>
      Specified by:
      iterator in interface Iterable<T>
      Specified by:
      iterator in interface Set<T>
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Collection<T>
      Specified by:
      equals in interface Set<T>
      Overrides:
      equals in class Object
    • 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