Package net.sf.tweety.math.term
Class Variable
- java.lang.Object
-
- net.sf.tweety.math.term.Term
-
- net.sf.tweety.math.term.Variable
-
- Direct Known Subclasses:
BinaryVariable,FloatVariable,IntegerVariable
public abstract class Variable extends Term
This class models a variable as a mathematical term.- Author:
- Matthias Thimm
-
-
Constructor Summary
Constructors Constructor Description Variable(java.lang.String name)Creates a new variable with the given name.Variable(java.lang.String name, boolean isPositive)Creates a new variable with the given name.Variable(java.lang.String name, double lowerBound, double upperBound)Creates a new variable with the given name and bounds.
-
Method Summary
Modifier and Type Method Description voidcollapseAssociativeOperations()This method collapses all associative operations appearing in this term, e.g.Termderive(Variable v)Differentiates the term with respect to the given variable.booleanequals(java.lang.Object obj)voidexpandAssociativeOperations()This method expands all associative operations appearing in this term, e.g.java.util.Set<AbsoluteValue>getAbsoluteValues()Returns all absolute values of this term.doublegetLowerBound()Returns the lower bound of this variable.java.util.Set<Maximum>getMaximums()Returns all maximums of this term.java.util.Set<Minimum>getMinimums()Returns all minimums of this term.java.lang.StringgetName()Returns the name of this variable.java.util.Set<Product>getProducts()Returns all products of this term.doublegetUpperBound()Returns the upper bound of this variable.java.util.Set<Variable>getVariables()Returns all variables in this term.inthashCode()booleanisContinuous(Variable v)Checks whether this term is continuous in v.booleanisPositive()Checks whether this variables should be positive.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.java.lang.StringtoString()Constantvalue()Computes the actual value of this term if it contains no variables.-
Methods inherited from class net.sf.tweety.math.term.Term
add, doubleValue, evaluateMatrix, evaluateVector, evaluateVector, isContinuous, isInteger, isLinear, min, minus, mult, replaceAllTerms, replaceAllTerms
-
-
-
-
Constructor Detail
-
Variable
public Variable(java.lang.String name)
Creates a new variable with the given name.- Parameters:
name- the name of this variable.
-
Variable
public Variable(java.lang.String name, boolean isPositive)Creates a new variable with the given name.- Parameters:
name- the name of this variable.isPositive- whether this variables should be positive.
-
Variable
public Variable(java.lang.String name, double lowerBound, double upperBound)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 Detail
-
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
public Constant value()
Description copied from class:TermComputes the actual value of this term if it contains no variables.
-
getName
public java.lang.String getName()
Returns the name of this variable.- Returns:
- the name of this variable.
-
getVariables
public java.util.Set<Variable> getVariables()
Description copied from class:TermReturns all variables in this term.- Specified by:
getVariablesin classTerm- Returns:
- all variables in this term.
-
getProducts
public java.util.Set<Product> getProducts()
Description copied from class:TermReturns all products of this term.- Specified by:
getProductsin classTerm- Returns:
- all products of this term.
-
getMinimums
public java.util.Set<Minimum> getMinimums()
Description copied from class:TermReturns all minimums of this term.- Specified by:
getMinimumsin classTerm- Returns:
- all minimums of this term.
-
getMaximums
public java.util.Set<Maximum> getMaximums()
Description copied from class:TermReturns all maximums of this term.- Specified by:
getMaximumsin classTerm- Returns:
- all maximums of this term.
-
getAbsoluteValues
public java.util.Set<AbsoluteValue> getAbsoluteValues()
Description copied from class:TermReturns all absolute values of this term.- Specified by:
getAbsoluteValuesin classTerm- Returns:
- all absolute values of this term.
-
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"
-
collapseAssociativeOperations
public void collapseAssociativeOperations()
Description copied from class:TermThis method collapses all associative operations appearing in this term, e.g. every min{min{a,b},c} becomes min{a,b,c}.- Specified by:
collapseAssociativeOperationsin classTerm
-
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
-
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.
-
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.
-
derive
public Term derive(Variable v)
Description copied from class:TermDifferentiates the term with respect to the given variable.
-
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.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-