Class AggregateAtom

  • All Implemented Interfaces:
    net.sf.tweety.commons.Formula, net.sf.tweety.logics.commons.syntax.interfaces.ComplexLogicalFormula, net.sf.tweety.logics.commons.syntax.interfaces.LogicStructure, net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula

    public class AggregateAtom
    extends ASPBodyElement
    This class represents an aggregate. Aggregates are functions that range over sets of terms and literals and evaluate to some value. For example, using the aggregate function #count one could obtain the number of employees of one department. Normally, this value is then compared to another value with a comparative operator like "=" to produce a truth value (also known as 'aggregate relation'). For example, this could be used to express the condition that the number of employees in one department has to be greater than 0.
    An aggregate that contains such a comparison is also referred to as an aggregate atom and can appear in the body of a rule.
    Author:
    Tim Janus, Thomas Vengels, Anna Gessler
    • Constructor Detail

      • AggregateAtom

        public AggregateAtom()
        Empty default constructor.
      • AggregateAtom

        public AggregateAtom​(ASPOperator.AggregateFunction func,
                             List<AggregateElement> elements)
        Creates a new Aggregate with the given aggregate function and the given aggregate elements.
        Parameters:
        func - an aggregate function
        elements - list of aggregate elements
      • AggregateAtom

        public AggregateAtom​(ASPOperator.AggregateFunction func,
                             List<AggregateElement> elements,
                             ASPOperator.BinaryOperator relation,
                             net.sf.tweety.logics.commons.syntax.interfaces.Term<?> t)
        Creates a new Aggregate with the given aggregate function, the given aggregate elements, and the given aggregate relation.
        Parameters:
        func - an aggregate function
        elements - list of aggregate elements
        relation - the relation
        t - some term
      • AggregateAtom

        public AggregateAtom​(ASPOperator.AggregateFunction func,
                             List<AggregateElement> elements,
                             ASPOperator.BinaryOperator relation,
                             net.sf.tweety.logics.commons.syntax.interfaces.Term<?> t,
                             ASPOperator.BinaryOperator relation2,
                             net.sf.tweety.logics.commons.syntax.interfaces.Term<?> t2)
        Creates a new Aggregate with the given aggregate function, the given aggregate elements, and the given left and right aggregate relations.
        Parameters:
        func - an aggregate function
        elements - list of aggregate elements
        relation - the relation
        t - some term
        relation2 - the relation
        t2 - some term
      • AggregateAtom

        public AggregateAtom​(AggregateAtom other)
        Copy-Constructor
        Parameters:
        other - another AggregateAtom
    • Method Detail

      • getLiterals

        public SortedSet<ASPLiteral> getLiterals()
        Description copied from class: ASPBodyElement
        Returns all literals in this element in form of a SortedSet. Literals are atoms or strict negations of atoms.
        Specified by:
        getLiterals in class ASPBodyElement
        Returns:
        all the literals used in the rule element
      • getPredicates

        public Set<net.sf.tweety.logics.commons.syntax.Predicate> getPredicates()
        Specified by:
        getPredicates in interface net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
        Specified by:
        getPredicates in class ASPElement
      • getAtoms

        public Set<ASPAtom> getAtoms()
        Specified by:
        getAtoms in interface net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
        Specified by:
        getAtoms in class ASPElement
      • substitute

        public AggregateAtom substitute​(net.sf.tweety.logics.commons.syntax.interfaces.Term<?> t,
                                        net.sf.tweety.logics.commons.syntax.interfaces.Term<?> v)
        Specified by:
        substitute in interface net.sf.tweety.logics.commons.syntax.interfaces.ComplexLogicalFormula
        Specified by:
        substitute in class ASPBodyElement
      • getSignature

        public net.sf.tweety.logics.fol.syntax.FolSignature getSignature()
        Specified by:
        getSignature in interface net.sf.tweety.commons.Formula
        Specified by:
        getSignature in class ASPElement
      • clone

        public AggregateAtom clone()
        Specified by:
        clone in interface net.sf.tweety.logics.commons.syntax.interfaces.ComplexLogicalFormula
        Specified by:
        clone in interface net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
        Specified by:
        clone in class ASPElement
      • isLiteral

        public boolean isLiteral()
      • getTerms

        public Set<net.sf.tweety.logics.commons.syntax.interfaces.Term<?>> getTerms()
      • getTerms

        public <C extends net.sf.tweety.logics.commons.syntax.interfaces.Term<?>> Set<C> getTerms​(Class<C> cls)
      • hasLeftRelation

        public boolean hasLeftRelation()
        Returns true if the aggregate has a left aggregate relation (meaning a term that the aggregate's resulting value will be compared to using a comparative operator).
        Returns:
        true if aggregate has left aggregate relation
      • hasRightRelation

        public boolean hasRightRelation()
        Returns true if the aggregate has a right aggregate relation (meaning a term that the aggregate's resulting value will be compared to using a comparative operator).
        Returns:
        true if aggregate has right aggregate relation
      • setFunction

        public void setFunction​(ASPOperator.AggregateFunction function)
        Sets the aggregate function.
        Parameters:
        function - an aggregate function
      • getRightOperator

        public ASPOperator.BinaryOperator getRightOperator()
        Returns the operator of the right aggregate relation.
        Returns:
        comparative operator
      • setRightOperator

        public void setRightOperator​(ASPOperator.BinaryOperator op)
        Sets the operator of the right aggregate relation.
        Parameters:
        op - comparative operator
      • getRightGuard

        public net.sf.tweety.logics.commons.syntax.interfaces.Term<?> getRightGuard()
        Returns the right relation term (right guard).
        Returns:
        Term
      • setRightGuard

        public void setRightGuard​(net.sf.tweety.logics.commons.syntax.interfaces.Term<?> relationTerm)
        Set the right relation term (right guard).
        Parameters:
        relationTerm - some term
      • getLeftOperator

        public ASPOperator.BinaryOperator getLeftOperator()
        Returns the operator of the left aggregate relation.
        Returns:
        comparative operator
      • setLeftOperator

        public void setLeftOperator​(ASPOperator.BinaryOperator op)
        Sets the operator of the left aggregate relation.
        Parameters:
        op - comparative operator
      • getLeftGuard

        public net.sf.tweety.logics.commons.syntax.interfaces.Term<?> getLeftGuard()
        Get the left relation term (right guard).
        Returns:
        Term
      • setLeftGuard

        public void setLeftGuard​(net.sf.tweety.logics.commons.syntax.interfaces.Term<?> relationTerm)
        Set the left relation term (right guard).
        Parameters:
        relationTerm - some term