Package net.sf.tweety.lp.asp.syntax
Class AggregateAtom
- java.lang.Object
-
- net.sf.tweety.lp.asp.syntax.ASPElement
-
- net.sf.tweety.lp.asp.syntax.ASPBodyElement
-
- net.sf.tweety.lp.asp.syntax.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 Summary
Constructors Constructor Description AggregateAtom()Empty default constructor.AggregateAtom(AggregateAtom other)Copy-ConstructorAggregateAtom(ASPOperator.AggregateFunction func, List<AggregateElement> elements)Creates a new Aggregate with the given aggregate function and the given aggregate elements.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.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.
-
Method Summary
Modifier and Type Method Description AggregateAtomclone()List<AggregateElement>getAggregateElements()Set<ASPAtom>getAtoms()ASPOperator.AggregateFunctiongetFunction()Returns the aggregate function.net.sf.tweety.logics.commons.syntax.interfaces.Term<?>getLeftGuard()Get the left relation term (right guard).ASPOperator.BinaryOperatorgetLeftOperator()Returns the operator of the left aggregate relation.SortedSet<ASPLiteral>getLiterals()Returns all literals in this element in form of a SortedSet.Set<net.sf.tweety.logics.commons.syntax.Predicate>getPredicates()net.sf.tweety.logics.commons.syntax.interfaces.Term<?>getRightGuard()Returns the right relation term (right guard).ASPOperator.BinaryOperatorgetRightOperator()Returns the operator of the right aggregate relation.net.sf.tweety.logics.fol.syntax.FolSignaturegetSignature()Set<net.sf.tweety.logics.commons.syntax.interfaces.Term<?>>getTerms()<C extends net.sf.tweety.logics.commons.syntax.interfaces.Term<?>>
Set<C>getTerms(Class<C> cls)booleanhasLeftRelation()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).booleanhasRightRelation()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).booleanisLiteral()voidsetFunction(ASPOperator.AggregateFunction function)Sets the aggregate function.voidsetLeftGuard(net.sf.tweety.logics.commons.syntax.interfaces.Term<?> relationTerm)Set the left relation term (right guard).voidsetLeftOperator(ASPOperator.BinaryOperator op)Sets the operator of the left aggregate relation.voidsetRightGuard(net.sf.tweety.logics.commons.syntax.interfaces.Term<?> relationTerm)Set the right relation term (right guard).voidsetRightOperator(ASPOperator.BinaryOperator op)Sets the operator of the right aggregate relation.AggregateAtomsubstitute(net.sf.tweety.logics.commons.syntax.interfaces.Term<?> t, net.sf.tweety.logics.commons.syntax.interfaces.Term<?> v)StringtoString()-
Methods inherited from class net.sf.tweety.lp.asp.syntax.ASPElement
containsTermsOfType, exchange, getPredicateCls, isGround, isWellFormed, substitute
-
-
-
-
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 functionelements- 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 functionelements- list of aggregate elementsrelation- the relationt- 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 functionelements- list of aggregate elementsrelation- the relationt- some termrelation2- the relationt2- some term
-
AggregateAtom
public AggregateAtom(AggregateAtom other)
Copy-Constructor- Parameters:
other- another AggregateAtom
-
-
Method Detail
-
getLiterals
public SortedSet<ASPLiteral> getLiterals()
Description copied from class:ASPBodyElementReturns all literals in this element in form of a SortedSet. Literals are atoms or strict negations of atoms.- Specified by:
getLiteralsin classASPBodyElement- Returns:
- all the literals used in the rule element
-
getPredicates
public Set<net.sf.tweety.logics.commons.syntax.Predicate> getPredicates()
- Specified by:
getPredicatesin interfacenet.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula- Specified by:
getPredicatesin classASPElement
-
getAtoms
public Set<ASPAtom> getAtoms()
- Specified by:
getAtomsin interfacenet.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula- Specified by:
getAtomsin classASPElement
-
substitute
public AggregateAtom substitute(net.sf.tweety.logics.commons.syntax.interfaces.Term<?> t, net.sf.tweety.logics.commons.syntax.interfaces.Term<?> v)
- Specified by:
substitutein interfacenet.sf.tweety.logics.commons.syntax.interfaces.ComplexLogicalFormula- Specified by:
substitutein classASPBodyElement
-
getSignature
public net.sf.tweety.logics.fol.syntax.FolSignature getSignature()
- Specified by:
getSignaturein interfacenet.sf.tweety.commons.Formula- Specified by:
getSignaturein classASPElement
-
clone
public AggregateAtom clone()
- Specified by:
clonein interfacenet.sf.tweety.logics.commons.syntax.interfaces.ComplexLogicalFormula- Specified by:
clonein interfacenet.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula- Specified by:
clonein classASPElement
-
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)
-
getAggregateElements
public List<AggregateElement> getAggregateElements()
-
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
-
getFunction
public ASPOperator.AggregateFunction getFunction()
Returns the aggregate function.- Returns:
- an aggregate function
-
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
-
-