Class OptimizationElement

java.lang.Object
org.tweetyproject.lp.asp.syntax.ASPElement
org.tweetyproject.lp.asp.syntax.OptimizationElement
All Implemented Interfaces:
Formula, ComplexLogicalFormula, LogicStructure, SimpleLogicalFormula

public class OptimizationElement extends ASPElement
This class represents an element of an optimization statement, meaning a term-literal tuple that is associated with a weight and optionally a priority (level).
Author:
Anna Gessler
  • Constructor Details

    • OptimizationElement

      public OptimizationElement(Term<?> weight, List<Term<?>> terms, List<ASPBodyElement> literals)
      Creates a new optimization element with the given weight, terms and literals.
      Parameters:
      weight - weight
      terms - terms
      literals - literals
    • OptimizationElement

      public OptimizationElement(Term<?> weight, Term<?> term, ASPBodyElement literal)
      Creates a new optimization element with the given single weight, term and literal.
      Parameters:
      weight - weight
      term - term
      literal - literal
    • OptimizationElement

      public OptimizationElement(Term<?> term, ASPBodyElement literal)
      Creates a new optimization element with the given single term and literal.
      Parameters:
      term - term
      literal - literal
    • OptimizationElement

      public OptimizationElement(Term<?> weight, int priority, List<Term<?>> terms, List<ASPBodyElement> literals)
      Creates a new optimization element with the given weight, priority, terms and literals.
      Parameters:
      weight - weight
      priority - an integer
      terms - terms
      literals - literals
    • OptimizationElement

      public OptimizationElement(Term<?> weight, Term<?> priority, List<Term<?>> terms, List<ASPBodyElement> literals)
      Creates a new optimization element with the given weight, priority, terms and literals.
      Parameters:
      weight - weight
      priority - priority
      terms - terms
      literals - literals
  • Method Details

    • isLiteral

      public boolean isLiteral()
      Returns:
      true if the formula represents a literal in the language or false otherwise
    • getTerms

      public Set<Term<?>> getTerms()
      Returns:
      a set containing all terms of this logical structure
    • getTerms

      public <C extends Term<?>> Set<C> getTerms(Class<C> cls)
      Description copied from interface: LogicStructure
      Processes the set containing all terms of type C. This method uses the equals method of the given Class and therefore does not add terms which are sub classes of type C to the set.
      Type Parameters:
      C - the type of terms
      Parameters:
      cls - The Class structure containing type information about the searched term
      Returns:
      A set containing all terms of type C of this logical structure
    • getPredicates

      public Set<Predicate> getPredicates()
      Description copied from interface: SimpleLogicalFormula
      Processes the set of all predicates which appear in this formula
      Specified by:
      getPredicates in interface SimpleLogicalFormula
      Specified by:
      getPredicates in class ASPElement
      Returns:
      all predicates that appear in this formula
    • substitute

      public OptimizationElement substitute(Term<?> t, Term<?> v)
      Description copied from interface: ComplexLogicalFormula
      Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.
      Specified by:
      substitute in interface ComplexLogicalFormula
      Specified by:
      substitute in class ASPElement
      Parameters:
      t - the term to be substituted.
      v - the term to substitute.
      Returns:
      a formula where every occurrence of "v" is replaced by "t".
    • getSignature

      public FolSignature getSignature()
      Description copied from interface: Formula
      Returns the signature of the language of this formula.
      Specified by:
      getSignature in interface Formula
      Specified by:
      getSignature in class ASPElement
      Returns:
      the signature of the language of this formula.
    • getAtoms

      public Set<ASPAtom> getAtoms()
      Description copied from interface: SimpleLogicalFormula
      Processes the set of all atoms which appear in this formula
      Specified by:
      getAtoms in interface SimpleLogicalFormula
      Specified by:
      getAtoms in class ASPElement
      Returns:
      The set of all atoms
    • clone

      public ASPElement clone()
      Description copied from interface: SimpleLogicalFormula
      Creates a deep copy of this formula
      Specified by:
      clone in interface ComplexLogicalFormula
      Specified by:
      clone in interface SimpleLogicalFormula
      Specified by:
      clone in class ASPElement
      Returns:
      the cloned formula
    • setWeight

      public void setWeight(Term<?> w)
      Sets the weight of this optimization statement.
      Parameters:
      w - term
    • setLevel

      public void setLevel(Term<?> l)
      Sets the level (priority) of this optimization statement.
      Parameters:
      l - term
    • setLevel

      public void setLevel(int l)
      Sets the level (priority) of this optimization statement.
      Parameters:
      l - integer
    • setOptTerms

      public void setOptTerms(List<Term<?>> terms)
      Sets the term tuple of this optimization element.
      Parameters:
      terms -
    • setOptLiterals

      public void setOptLiterals(List<ASPBodyElement> literals)
      Sets the literals tuple of this optimization element.
      Parameters:
      literals -
    • getWeight

      public Term<?> getWeight()
      Returns:
      the weight of this optimization element.
    • getLevel

      public Term<?> getLevel()
      Returns:
      level (priority) of this optimization element.
    • getOptTerms

      public List<Term<?>> getOptTerms()
      Returns:
      the term tuple of this optimization element.
    • getOptLiterals

      public List<ASPBodyElement> getOptLiterals()
      Returns:
      the literals tuple of this optimization element.
    • getLiterals

      public SortedSet<ASPLiteral> getLiterals()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • printToClingo

      public String printToClingo()
      Description copied from class: ASPElement
      Returns a representation of this ASP element in clingo (potassco) syntax. See https://potassco.org/ for more information.
      Overrides:
      printToClingo in class ASPElement
      Returns:
      String representation in clingo syntax
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface SimpleLogicalFormula
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface SimpleLogicalFormula
      Overrides:
      equals in class Object