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
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
ConstructorsConstructorDescriptionOptimizationElement(Term<?> weight, int priority, List<Term<?>> terms, List<ASPBodyElement> literals) Creates a new optimization element with the given weight, priority, terms and literals.OptimizationElement(Term<?> weight, List<Term<?>> terms, List<ASPBodyElement> literals) Creates a new optimization element with the given weight, terms and literals.OptimizationElement(Term<?> weight, Term<?> priority, List<Term<?>> terms, List<ASPBodyElement> literals) Creates a new optimization element with the given weight, priority, terms and literals.OptimizationElement(Term<?> weight, Term<?> term, ASPBodyElement literal) Creates a new optimization element with the given single weight, term and literal.OptimizationElement(Term<?> term, ASPBodyElement literal) Creates a new optimization element with the given single term and literal. -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates a deep copy of this formulabooleangetAtoms()Processes the set of all atoms which appear in this formulaTerm<?> getLevel()Return level (priority) of this optimization element.GetterReturn the literals tuple of this optimization element.Return the term tuple of this optimization element.Processes the set of all predicates which appear in this formulaReturns the signature of the language of this formula.getTerms()Processes the set containing all terms of type C.Term<?> Return the weight of this optimization element.inthashCode()booleanReturns a representation of this ASP element in clingo (potassco) syntax.voidsetLevel(int l) Sets the level (priority) of this optimization statement.voidSets the level (priority) of this optimization statement.voidsetOptLiterals(List<ASPBodyElement> literals) Sets the literals tuple of this optimization element.voidsetOptTerms(List<Term<?>> terms) Sets the term tuple of this optimization element.voidSets the weight of this optimization statement.substitute(Term<?> t, Term<?> v) Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.toString()Methods inherited from class org.tweetyproject.lp.asp.syntax.ASPElement
containsTermsOfType, exchange, getPredicateCls, isGround, isWellFormed, printToDLV, substitute
-
Constructor Details
-
OptimizationElement
Creates a new optimization element with the given weight, terms and literals.- Parameters:
weight- weightterms- termsliterals- literals
-
OptimizationElement
Creates a new optimization element with the given single weight, term and literal.- Parameters:
weight- weightterm- termliteral- literal
-
OptimizationElement
Creates a new optimization element with the given single term and literal.- Parameters:
term- termliteral- 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- weightpriority- an integerterms- termsliterals- literals
-
OptimizationElement
-
-
Method Details
-
isLiteral
public boolean isLiteral()- Returns:
- true if the formula represents a literal in the language or false otherwise
-
getTerms
-
getTerms
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
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
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
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
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
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
Sets the weight of this optimization statement.- Parameters:
w- term
-
setLevel
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
-
setOptLiterals
Sets the literals tuple of this optimization element.- Parameters:
literals- the literals
-
getWeight
Return the weight of this optimization element.- Returns:
- the weight of this optimization element.
-
getLevel
Return level (priority) of this optimization element.- Returns:
- level (priority) of this optimization element.
-
getOptTerms
-
getOptLiterals
Return the literals tuple of this optimization element.- Returns:
- the literals tuple of this optimization element.
-
getLiterals
-
toString
-
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
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceSimpleLogicalFormula- Overrides:
hashCodein classObject
-
equals
- Specified by:
equalsin interfaceSimpleLogicalFormula- Overrides:
equalsin classObject
-