Package org.tweetyproject.math.term
Class Variable
java.lang.Object
org.tweetyproject.math.term.Term
org.tweetyproject.math.term.Variable
- Direct Known Subclasses:
BinaryVariable
,FloatVariable
,IntegerVariable
This class models a variable as a mathematical term.
- Author:
- Matthias Thimm
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method collapses all associative operations appearing in this term, e.g.Differentiates the term with respect to the given variable.boolean
void
This method expands all associative operations appearing in this term, e.g.Returns all absolute values of this term.double
Returns the lower bound of this variable.Returns all maximums of this term.Returns all minimums of this term.getName()
Returns the name of this variable.Returns all products of this term.getSums()
Returns all sums of this term.getTerms()
Getter Termsdouble
Returns the upper bound of this variable.Returns all variables in this term.int
hashCode()
boolean
Checks whether this term is continuous in v.boolean
Checks whether this variables should be positive.replaceTerm
(Term toSubstitute, Term substitution) Replaces each occurrence of "toSubstitute" by "substitution" and return the new term.simplify()
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.Converts this term into a linear normal form, i.e.Return a quadratic formtoString()
value()
Computes the actual value of this term if it contains no variables.Methods inherited from class org.tweetyproject.math.term.Term
add, doubleValue, evaluateMatrix, evaluateVector, evaluateVector, isContinuous, isInteger, isLinear, isQuadratic, min, minus, mult, replaceAllTerms, replaceAllTerms
-
Constructor Details
-
Variable
Creates a new variable with the given name.- Parameters:
name
- the name of this variable.
-
Variable
Creates a new variable with the given name.- Parameters:
name
- the name of this variable.isPositive
- whether this variables should be positive.
-
Variable
Creates a new variable with the given name and bounds.- Parameters:
name
- the name of this variable.lowerBound
- the lower bound of the variable.upperBound
- the upper bound of the variable.
-
-
Method Details
-
isPositive
public boolean isPositive()Checks whether this variables should be positive.- Returns:
- "true" if this variables should be positive.
-
getUpperBound
public double getUpperBound()Returns the upper bound of this variable.- Returns:
- the upper bound of this variable.
-
getLowerBound
public double getLowerBound()Returns the lower bound of this variable.- Returns:
- the lower bound of this variable.
-
value
-
getName
-
getVariables
Description copied from class:Term
Returns all variables in this term.- Specified by:
getVariables
in classTerm
- Returns:
- all variables in this term.
-
getProducts
Description copied from class:Term
Returns all products of this term.- Specified by:
getProducts
in classTerm
- Returns:
- all products of this term.
-
getSums
-
getMinimums
Description copied from class:Term
Returns all minimums of this term.- Specified by:
getMinimums
in classTerm
- Returns:
- all minimums of this term.
-
getMaximums
Description copied from class:Term
Returns all maximums of this term.- Specified by:
getMaximums
in classTerm
- Returns:
- all maximums of this term.
-
getAbsoluteValues
Description copied from class:Term
Returns all absolute values of this term.- Specified by:
getAbsoluteValues
in classTerm
- Returns:
- all absolute values of this term.
-
replaceTerm
Description copied from class:Term
Replaces each occurrence of "toSubstitute" by "substitution" and return the new term.- Specified by:
replaceTerm
in classTerm
- Parameters:
toSubstitute
- the term to be substitutedsubstitution
- the new term- Returns:
- this term where "toSubstitute" is replaced by "substitution"
-
collapseAssociativeOperations
public void collapseAssociativeOperations()Description copied from class:Term
This method collapses all associative operations appearing in this term, e.g. every min{min{a,b},c} becomes min{a,b,c}.- Specified by:
collapseAssociativeOperations
in classTerm
-
expandAssociativeOperations
public void expandAssociativeOperations()Description copied from class:Term
This method expands all associative operations appearing in this term, e.g. every min{a,b,c} becomes min{min{a,b},c}.- Specified by:
expandAssociativeOperations
in classTerm
-
isContinuous
Description copied from class:Term
Checks whether this term is continuous in v.- Specified by:
isContinuous
in classTerm
- Parameters:
v
- a variable- Returns:
- "true" iff this term is continuous in v.
-
toLinearForm
Description copied from class:Term
Converts this term into a linear normal form, i.e. into a sum of products of a constant and a variable.- Specified by:
toLinearForm
in classTerm
- Returns:
- a term in linear normal form.
- Throws:
IllegalArgumentException
- if this term cannot be converted into a linear normal form.
-
toQuadraticForm
Description copied from class:Term
Return a quadratic form- Specified by:
toQuadraticForm
in classTerm
- Returns:
- a quadratic form
- Throws:
IllegalArgumentException
- error
-
derive
-
simplify
Description copied from class:Term
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. -
getTerms
-
hashCode
-
equals
-
toString
-