Package org.tweetyproject.lp.asp.syntax
Class OptimizationStatement
- java.lang.Object
-
- org.tweetyproject.lp.asp.syntax.ASPElement
-
- org.tweetyproject.lp.asp.syntax.ASPBodyElement
-
- org.tweetyproject.lp.asp.syntax.OptimizationStatement
-
- All Implemented Interfaces:
Formula,ComplexLogicalFormula,LogicStructure,SimpleLogicalFormula
public class OptimizationStatement extends ASPBodyElement
This class represents an optimization statement. Optimization statements represent sets of weak constraints with the goal of finding an optimal answer set wrt. to the constraints.- Author:
- Anna Gessler
-
-
Constructor Summary
Constructors Constructor Description OptimizationStatement(ASPOperator.OptimizeFunction function)Creates a new empty OptimizatonStatement with the given function.OptimizationStatement(ASPOperator.OptimizeFunction function, java.util.List<OptimizationElement> optElements)Creates a new empty OptimizatonStatement with the given function and the given optimization elements (term-literal tuples with weight and priority).OptimizationStatement(ASPOperator.OptimizeFunction function, Term<?> weight, int priority, java.util.List<Term<?>> terms, java.util.List<ASPBodyElement> literals)Creates a new OptimizatonStatement with the given function, weight, priority and single term-literal tuple.OptimizationStatement(ASPOperator.OptimizeFunction function, Term<?> weight, java.util.List<Term<?>> terms, java.util.List<ASPBodyElement> literals)Creates a new OptimizatonStatement with the given function, weight and single term-literal tuple.OptimizationStatement(ASPOperator.OptimizeFunction function, OptimizationElement element)Creates a new OptimizatonStatement with the given function and single term-literal tuple.
-
Method Summary
Modifier and Type Method Description OptimizationStatementclone()Creates a deep copy of this formulajava.util.Set<ASPAtom>getAtoms()Processes the set of all atoms which appear in this formulajava.util.SortedSet<ASPLiteral>getLiterals()Returns all literals in this element in form of a SortedSet.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.booleanisLiteral()java.lang.StringprintToClingo()Returns a representation of this ASP element in clingo (potassco) syntax.voidsetElements(java.util.List<OptimizationElement> elements)Sets the optimization elements.voidsetOptimizeFunction(ASPOperator.OptimizeFunction function)Sets the optimization function.OptimizationStatementsubstitute(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
-
OptimizationStatement
public OptimizationStatement(ASPOperator.OptimizeFunction function)
Creates a new empty OptimizatonStatement with the given function.- Parameters:
function-
-
OptimizationStatement
public OptimizationStatement(ASPOperator.OptimizeFunction function, java.util.List<OptimizationElement> optElements)
Creates a new empty OptimizatonStatement with the given function and the given optimization elements (term-literal tuples with weight and priority).- Parameters:
function-optElements- list of OptimizationElements
-
OptimizationStatement
public OptimizationStatement(ASPOperator.OptimizeFunction function, Term<?> weight, java.util.List<Term<?>> terms, java.util.List<ASPBodyElement> literals)
Creates a new OptimizatonStatement with the given function, weight and single term-literal tuple.- Parameters:
function-weight-terms-literals-
-
OptimizationStatement
public OptimizationStatement(ASPOperator.OptimizeFunction function, Term<?> weight, int priority, java.util.List<Term<?>> terms, java.util.List<ASPBodyElement> literals)
Creates a new OptimizatonStatement with the given function, weight, priority and single term-literal tuple.- Parameters:
function-weight-terms-literals-
-
OptimizationStatement
public OptimizationStatement(ASPOperator.OptimizeFunction function, OptimizationElement element)
Creates a new OptimizatonStatement with the given function and single term-literal tuple.- Parameters:
function- the target functionelement- some element
-
-
Method Detail
-
setOptimizeFunction
public void setOptimizeFunction(ASPOperator.OptimizeFunction function)
Sets the optimization function.- Parameters:
function-
-
setElements
public void setElements(java.util.List<OptimizationElement> elements)
Sets the optimization elements.- Parameters:
elements-
-
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
-
substitute
public OptimizationStatement 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 classASPBodyElement- Parameters:
t- the term to be substituted.v- the term to substitute.- Returns:
- a formula where every occurrence of "v" is replaced by "t".
-
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
-
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 OptimizationStatement 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
-
getLiterals
public java.util.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
-
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
-
-