Class Term

    • Constructor Summary

      Constructors 
      Constructor Description
      Term()  
    • Constructor Detail

      • Term

        public Term()
    • Method Detail

      • add

        public Sum add​(Term t)
        Returns the sum of this and the given term.
        Parameters:
        t - a term
        Returns:
        the sum of this and the given term.
      • minus

        public Difference minus​(Term t)
        Returns the sum of this and (-1) * the given term.
        Parameters:
        t - a term
        Returns:
        the sum of this and (-1) * the given term.
      • mult

        public Product mult​(Term t)
        Returns the product of this and the given term.
        Parameters:
        t - a term.
        Returns:
        the product of this and the given term.
      • min

        public Term min​(Term t)
        Returns the minimum of this and the given term.
        Parameters:
        t - a term.
        Returns:
        the minimum of this and the given term.
      • value

        public abstract Constant value()
                                throws IllegalArgumentException
        Computes the actual value of this term if it contains no variables.
        Returns:
        the value of this term, either a float or an integer.
        Throws:
        IllegalArgumentException - if this term contains at least on variable.
      • doubleValue

        public double doubleValue()
                           throws IllegalArgumentException
        Computes the actual value of this term if it contains no variables.
        Returns:
        the double value of this term.
        Throws:
        IllegalArgumentException - if this term contains at least on variable.
      • isContinuous

        public abstract boolean isContinuous​(Variable v)
        Checks whether this term is continuous in v.
        Parameters:
        v - a variable
        Returns:
        "true" iff this term is continuous in v.
      • isContinuous

        public boolean isContinuous()
        Checks whether this term is continuous in all appearing variables.
        Returns:
        "true" iff this term is continuous in all appearing variables
      • getVariables

        public abstract Set<Variable> getVariables()
        Returns all variables in this term.
        Returns:
        all variables in this term.
      • getProducts

        public abstract Set<Product> getProducts()
        Returns all products of this term.
        Returns:
        all products of this term.
      • getMinimums

        public abstract Set<Minimum> getMinimums()
        Returns all minimums of this term.
        Returns:
        all minimums of this term.
      • getMaximums

        public abstract Set<Maximum> getMaximums()
        Returns all maximums of this term.
        Returns:
        all maximums of this term.
      • getAbsoluteValues

        public abstract Set<AbsoluteValue> getAbsoluteValues()
        Returns all absolute values of this term.
        Returns:
        all absolute values of this term.
      • isInteger

        public abstract boolean isInteger()
        Checks whether this term represents an integer value.
        Returns:
        "true" iff this term represents an integer value.
      • toLinearForm

        public abstract Sum toLinearForm()
                                  throws IllegalArgumentException
        Converts this term into a linear normal form, i.e. into a sum of products of a constant and a variable.
        Returns:
        a term in linear normal form.
        Throws:
        IllegalArgumentException - if this term cannot be converted into a linear normal form.
      • replaceTerm

        public abstract Term replaceTerm​(Term toSubstitute,
                                         Term substitution)
        Replaces each occurrence of "toSubstitute" by "substitution" and return the new term.
        Parameters:
        toSubstitute - the term to be substituted
        substitution - the new term
        Returns:
        this term where "toSubstitute" is replaced by "substitution"
      • evaluateVector

        public static List<Double> evaluateVector​(List<Term> functions,
                                                  Map<Variable,​? extends Term> mapping)
        Evaluates each function in the given list with the given values for variables.
        Parameters:
        functions - a list of functions
        mapping - a map mapping variables to terms
        Returns:
        the values
      • evaluateVector

        public static double[] evaluateVector​(List<Term> functions,
                                              double[] values,
                                              List<Variable> variables)
        Evaluates each function in the given list with the given values for variables.
        Parameters:
        functions - a list of functions
        values - the values of the variables
        variables - the (ordered) list of variables
        Returns:
        the values
      • evaluateMatrix

        public static double[][] evaluateMatrix​(List<List<Term>> functions,
                                                double[] values,
                                                List<Variable> variables)
        Evaluates each function in the given matrix with the given values for variables.
        Parameters:
        functions - a list of functions
        values - the values of the variables
        variables - the (ordered) list of variables
        Returns:
        the values
      • replaceAllTerms

        public Term replaceAllTerms​(double[] values,
                                    List<Variable> variables)
        Replaces terms according to the given map.
        Parameters:
        values - an array of values.
        variables - A list of variables that shall be substituted by the given values
        Returns:
        a term.
      • replaceAllTerms

        public Term replaceAllTerms​(Map<? extends Term,​? extends Term> substitutes)
        Replaces terms according to the given map.
        Parameters:
        substitutes - a map.
        Returns:
        a term.
      • isLinear

        public boolean isLinear()
        Checks whether this term is linear.
        Returns:
        "true" if this term is linear.
      • simplify

        public abstract 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.
        Returns:
        the simplified term.
      • collapseAssociativeOperations

        public abstract void collapseAssociativeOperations()
        This method collapses all associative operations appearing in this term, e.g. every min{min{a,b},c} becomes min{a,b,c}.
      • expandAssociativeOperations

        public abstract void expandAssociativeOperations()
        This method expands all associative operations appearing in this term, e.g. every min{a,b,c} becomes min{min{a,b},c}.