Package org.tweetyproject.lp.asp.syntax
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 Summary
Constructors Constructor Description OptimizationElement(Term<?> weight, int priority, java.util.List<Term<?>> terms, java.util.List<ASPBodyElement> literals)Create a new optimization statement with the given weight, priority, terms and literals.OptimizationElement(Term<?> weight, java.util.List<Term<?>> terms, java.util.List<ASPBodyElement> literals)Create a new optimization statement with the given weight, terms and literals.OptimizationElement(Term<?> weight, Term<?> priority, java.util.List<Term<?>> terms, java.util.List<ASPBodyElement> literals)Create a new optimization statement with the given weight, priority, terms and literals.OptimizationElement(Term<?> weight, Term<?> term, ASPBodyElement literal)Create a new optimization statement with the given single weight, term and literal.
-
Method Summary
Modifier and Type Method Description ASPElementclone()Creates a deep copy of this formulajava.util.Set<ASPAtom>getAtoms()Processes the set of all atoms which appear in this formulaTerm<?>getLevel()java.util.SortedSet<ASPLiteral>getLiterals()java.util.List<ASPBodyElement>getOptLiterals()java.util.List<Term<?>>getOptTerms()java.util.Set<Predicate>getPredicates()Processes the set of all predicates which appear in this formulaFolSignaturegetSignature()Returns the signature of the language of this formula.java.util.Set<Term<?>>getTerms()<C extends Term<?>>
java.util.Set<C>getTerms(java.lang.Class<C> cls)Processes the set containing all terms of type C.Term<?>getWeight()booleanisLiteral()java.lang.StringprintToClingo()Returns a representation of this ASP element in clingo (potassco) syntax.voidsetLevel(int l)Sets the level (priority) of this optimization statement.voidsetLevel(Term<?> l)Sets the level (priority) of this optimization statement.voidsetOptLiterals(java.util.List<ASPBodyElement> literals)Set the literals tuple of this optimization element.voidsetOptTerms(java.util.List<Term<?>> terms)Set the term tuple of this optimization element.voidsetWeight(Term<?> w)Sets the weight of this optimization statement.OptimizationElementsubstitute(Term<?> t, Term<?> v)Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.java.lang.StringtoString()-
Methods inherited from class org.tweetyproject.lp.asp.syntax.ASPElement
containsTermsOfType, exchange, getPredicateCls, isGround, isWellFormed, substitute
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.SimpleLogicalFormula
equals, hashCode
-
-
-
-
Constructor Detail
-
OptimizationElement
public OptimizationElement(Term<?> weight, java.util.List<Term<?>> terms, java.util.List<ASPBodyElement> literals)
Create a new optimization statement with the given weight, terms and literals.- Parameters:
weight-terms-literals-
-
OptimizationElement
public OptimizationElement(Term<?> weight, Term<?> term, ASPBodyElement literal)
Create a new optimization statement with the given single weight, term and literal.- Parameters:
weight-term-literal-
-
OptimizationElement
public OptimizationElement(Term<?> weight, int priority, java.util.List<Term<?>> terms, java.util.List<ASPBodyElement> literals)
Create a new optimization statement with the given weight, priority, terms and literals.- Parameters:
weight-priority- an integerterms-literals-
-
OptimizationElement
public OptimizationElement(Term<?> weight, Term<?> priority, java.util.List<Term<?>> terms, java.util.List<ASPBodyElement> literals)
Create a new optimization statement with the given weight, priority, terms and literals.- Parameters:
weight-priority-terms-literals-
-
-
Method Detail
-
isLiteral
public boolean isLiteral()
- Returns:
- true if the formula represents a literal in the language or false otherwise
-
getTerms
public java.util.Set<Term<?>> getTerms()
- Returns:
- a set containing all terms of this logical structure
-
getTerms
public <C extends Term<?>> java.util.Set<C> getTerms(java.lang.Class<C> cls)
Description copied from interface:LogicStructureProcesses 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 java.util.Set<Predicate> getPredicates()
Description copied from interface:SimpleLogicalFormulaProcesses the set of all predicates which appear in this formula- Specified by:
getPredicatesin interfaceSimpleLogicalFormula- Specified by:
getPredicatesin classASPElement- Returns:
- all predicates that appear in this formula
-
substitute
public OptimizationElement substitute(Term<?> t, Term<?> v)
Description copied from interface:ComplexLogicalFormulaSubstitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.- Specified by:
substitutein interfaceComplexLogicalFormula- Specified by:
substitutein classASPElement- 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:FormulaReturns the signature of the language of this formula.- Specified by:
getSignaturein interfaceFormula- Specified by:
getSignaturein classASPElement- Returns:
- the signature of the language of this formula.
-
getAtoms
public java.util.Set<ASPAtom> getAtoms()
Description copied from interface:SimpleLogicalFormulaProcesses the set of all atoms which appear in this formula- Specified by:
getAtomsin interfaceSimpleLogicalFormula- Specified by:
getAtomsin classASPElement- Returns:
- The set of all atoms
-
clone
public ASPElement clone()
Description copied from interface:SimpleLogicalFormulaCreates a deep copy of this formula- Specified by:
clonein interfaceComplexLogicalFormula- Specified by:
clonein interfaceSimpleLogicalFormula- Specified by:
clonein classASPElement- 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(java.util.List<Term<?>> terms)
Set the term tuple of this optimization element.- Parameters:
terms-
-
setOptLiterals
public void setOptLiterals(java.util.List<ASPBodyElement> literals)
Set 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 java.util.List<Term<?>> getOptTerms()
- Returns:
- the term tuple of this optimization element.
-
getOptLiterals
public java.util.List<ASPBodyElement> getOptLiterals()
- Returns:
- the literals tuple of this optimization element.
-
getLiterals
public java.util.SortedSet<ASPLiteral> getLiterals()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
printToClingo
public java.lang.String printToClingo()
Description copied from class:ASPElementReturns a representation of this ASP element in clingo (potassco) syntax. See https://potassco.org/ for more information.- Overrides:
printToClingoin classASPElement- Returns:
- String representation in clingo syntax
-
-