Package org.tweetyproject.math.term
Class Sum
- java.lang.Object
-
- org.tweetyproject.math.term.Term
-
- org.tweetyproject.math.term.AssociativeOperation
-
- org.tweetyproject.math.term.Sum
-
public class Sum extends AssociativeOperation
This class models a sum of two terms.- Author:
- Matthias Thimm
-
-
Method Summary
Modifier and Type Method Description Termderive(Variable v)Differentiates the term with respect to the given variable.voidexpandAssociativeOperations()This method expands all associative operations appearing in this term, e.g.java.util.Set<Sum>getSums()Returns all sums of this term.booleanisContinuous(Variable v)Checks whether this term is continuous in v.TermreplaceTerm(Term toSubstitute, Term substitution)Replaces each occurrence of "toSubstitute" by "substitution" and return the new term.Termsimplify()Simplifies this term in an equivalent way:
- Replaces products that contain a zero by the constant zero
- Removes a term one from products
- Removes a term zero from sums
- Aggregates constants in sums, products, and minimums
- Evaluates functional terms on constants
- Simplifies fractions where possible.SumtoLinearForm()Converts this term into a linear normal form, i.e.SumtoQuadraticForm()java.lang.StringtoString()Constantvalue()Computes the actual value of this term if it contains no variables.-
Methods inherited from class org.tweetyproject.math.term.AssociativeOperation
addAllTerm, addTerm, collapseAssociativeOperations, getAbsoluteValues, getMaximums, getMinimums, getProducts, getTerms, getVariables, isInteger, removeTerm, size
-
Methods inherited from class org.tweetyproject.math.term.Term
add, doubleValue, evaluateMatrix, evaluateVector, evaluateVector, isContinuous, isLinear, isQuadratic, min, minus, mult, replaceAllTerms, replaceAllTerms
-
-
-
-
Constructor Detail
-
Sum
public Sum()
Creates a new (empty) sum.
-
Sum
public Sum(Term first, Term second)
Creates a new sum with the given terms.- Parameters:
first- a term.second- a term.
-
Sum
public Sum(java.util.Collection<? extends Term> terms)
Creates a new sum with the given list of terms.- Parameters:
terms- a list of terms.
-
-
Method Detail
-
value
public Constant value()
Description copied from class:TermComputes the actual value of this term if it contains no variables.
-
replaceTerm
public Term replaceTerm(Term toSubstitute, Term substitution)
Description copied from class:TermReplaces each occurrence of "toSubstitute" by "substitution" and return the new term.- Specified by:
replaceTermin classTerm- Parameters:
toSubstitute- the term to be substitutedsubstitution- the new term- Returns:
- this term where "toSubstitute" is replaced by "substitution"
-
expandAssociativeOperations
public void expandAssociativeOperations()
Description copied from class:TermThis method expands all associative operations appearing in this term, e.g. every min{a,b,c} becomes min{min{a,b},c}.- Specified by:
expandAssociativeOperationsin classTerm
-
toLinearForm
public Sum toLinearForm() throws java.lang.IllegalArgumentException
Description copied from class:TermConverts this term into a linear normal form, i.e. into a sum of products of a constant and a variable.- Specified by:
toLinearFormin classTerm- Returns:
- a term in linear normal form.
- Throws:
java.lang.IllegalArgumentException- if this term cannot be converted into a linear normal form.
-
toQuadraticForm
public Sum toQuadraticForm() throws java.lang.IllegalArgumentException
- Specified by:
toQuadraticFormin classTerm- Throws:
java.lang.IllegalArgumentException
-
derive
public Term derive(Variable v) throws NonDifferentiableException
Description copied from class:TermDifferentiates the term with respect to the given variable.- Specified by:
derivein classTerm- Parameters:
v- a variable.- Returns:
- the derivation of this term wrt. the given variable.
- Throws:
NonDifferentiableException- if the term cannot be differentiated.
-
isContinuous
public boolean isContinuous(Variable v)
Description copied from class:TermChecks whether this term is continuous in v.- Specified by:
isContinuousin classTerm- Parameters:
v- a variable- Returns:
- "true" iff this term is continuous in v.
-
simplify
public Term simplify()
Description copied from class:TermSimplifies this term in an equivalent way:
- Replaces products that contain a zero by the constant zero
- Removes a term one from products
- Removes a term zero from sums
- Aggregates constants in sums, products, and minimums
- Evaluates functional terms on constants
- Simplifies fractions where possible.
-
getSums
public java.util.Set<Sum> getSums()
Description copied from class:TermReturns all sums of this term.- Overrides:
getSumsin classAssociativeOperation- Returns:
- all sums of this term.
-
-