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
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
ConstructorDescriptionCreates a new empty OptimizatonStatement with the given function.OptimizationStatement
(ASPOperator.OptimizeFunction function, 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, List<Term<?>> terms, List<ASPBodyElement> literals) Creates a new OptimizatonStatement with the given function, weight, priority and single term-literal tuple.OptimizationStatement
(ASPOperator.OptimizeFunction function, Term<?> weight, List<Term<?>> terms, 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 TypeMethodDescriptionclone()
Creates a deep copy of this formulaboolean
getAtoms()
Processes the set of all atoms which appear in this formulaReturn the optimization elements of this optimization statementReturns all literals in this element in form of a SortedSet.Return the optimize function of this optimization statementProcesses 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.int
hashCode()
boolean
Returns a representation of this ASP element in clingo (potassco) syntax.void
setElements
(List<OptimizationElement> elements) Sets the optimization elements of this optimization statement.void
Sets the optimization function.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
-
OptimizationStatement
Creates a new empty OptimizatonStatement with the given function.- Parameters:
function
- the function
-
OptimizationStatement
public OptimizationStatement(ASPOperator.OptimizeFunction function, 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
- the functionoptElements
- list of OptimizationElements
-
OptimizationStatement
public OptimizationStatement(ASPOperator.OptimizeFunction function, Term<?> weight, List<Term<?>> terms, List<ASPBodyElement> literals) Creates a new OptimizatonStatement with the given function, weight and single term-literal tuple.- Parameters:
function
- functionweight
- weightterms
- termsliterals
- literals
-
OptimizationStatement
public OptimizationStatement(ASPOperator.OptimizeFunction function, Term<?> weight, int priority, List<Term<?>> terms, List<ASPBodyElement> literals) Creates a new OptimizatonStatement with the given function, weight, priority and single term-literal tuple.- Parameters:
function
- functionweight
- weightpriority
- priorityterms
- termsliterals
- literals
-
OptimizationStatement
Creates a new OptimizatonStatement with the given function and single term-literal tuple.- Parameters:
function
- the target functionelement
- some element
-
-
Method Details
-
setElements
Sets the optimization elements of this optimization statement.- Parameters:
elements
- the optimization elements
-
getElements
Return the optimization elements of this optimization statement- Returns:
- the optimization elements of this optimization statement
-
getOptimizeFunction
Return the optimize function of this optimization statement- Returns:
- the optimize function of this optimization statement
-
setOptimizeFunction
Sets the optimization function.- Parameters:
function
- function
-
isLiteral
public boolean isLiteral()- Returns:
- true if the formula represents a literal in the language or false otherwise
-
getTerms
-
getTerms
Description copied from interface:LogicStructure
Processes 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
Description copied from interface:ComplexLogicalFormula
Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.- Specified by:
substitute
in interfaceComplexLogicalFormula
- Specified by:
substitute
in 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
Description copied from interface:SimpleLogicalFormula
Processes the set of all predicates which appear in this formula- Specified by:
getPredicates
in interfaceSimpleLogicalFormula
- Specified by:
getPredicates
in classASPElement
- Returns:
- all predicates that appear in this formula
-
getSignature
Description copied from interface:Formula
Returns the signature of the language of this formula.- Specified by:
getSignature
in interfaceFormula
- Specified by:
getSignature
in classASPElement
- Returns:
- the signature of the language of this formula.
-
getAtoms
Description copied from interface:SimpleLogicalFormula
Processes the set of all atoms which appear in this formula- Specified by:
getAtoms
in interfaceSimpleLogicalFormula
- Specified by:
getAtoms
in classASPElement
- Returns:
- The set of all atoms
-
clone
Description copied from interface:SimpleLogicalFormula
Creates a deep copy of this formula- Specified by:
clone
in interfaceComplexLogicalFormula
- Specified by:
clone
in interfaceSimpleLogicalFormula
- Specified by:
clone
in classASPElement
- Returns:
- the cloned formula
-
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 classASPBodyElement
- Returns:
- all the literals used in the rule element
-
toString
-
printToClingo
Description copied from class:ASPElement
Returns a representation of this ASP element in clingo (potassco) syntax. See https://potassco.org/ for more information.- Overrides:
printToClingo
in classASPElement
- Returns:
- String representation in clingo syntax
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceSimpleLogicalFormula
- Overrides:
hashCode
in classObject
-
equals
- Specified by:
equals
in interfaceSimpleLogicalFormula
- Overrides:
equals
in classObject
-