fuzzydl.milp

## Class Expression

- java.lang.Object
- - fuzzydl.milp.Expression

-     public class Expression
      extends java.lang.Object

  Linear expression of the form c + c1 * x1 + c2 * x2 + ... + cN * xN
  Author:
    Fernando Bobillo

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Expression(double constant)`
    `Expression(double constant, Term... terms)`
    `Expression(Expression expr)`
    `Expression(java.util.Set<Variable> v)`
    `Expression(Term... terms)`
    `Expression(java.util.Vector<Variable> v)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Expression` | `addConstant(Expression expr, java.lang.Double constant)` Adds a double constant to an expression.
    `static Expression` | `addExpressions(Expression expr1, Expression expr2)` Adds two expressions.
    `static Expression` | `addTerm(Expression expr, Term term)` Adds a term to an expression.
    `void` | `addTerm(Term term)` Adds a term to an expression.
    `Expression` | `clone()` Gets a copy of an expression.
    `double` | `getConstant()` Gets the constant of the expression.
    `double` | `getConstantTerm(Variable var)` Given a variable, gets its coefficient in the expression.
    `java.util.List<Term>` | `getTerms()` Gets the terms of the expression.
    `void` | `incrementConstant()` Increments the double constant in one.
    `static Expression` | `multiplyConstant(Expression expr, java.lang.Double constant)` Multiplies a double constant and an expression.
    `static Expression` | `negateExpression(Expression expr)` Changes the sign of all the elements of an expression.
    `void` | `setConstant(double constant)` Sets a double constant to an expression.
    `static Expression` | `subtractExpressions(Expression expr1, Expression expr2)` Substracts two expressions.
    `java.lang.String` | `toString()` Gets a printable name of the expression.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Expression

          public Expression(double constant)

    - #### Expression

          public Expression(double constant,
                            Term... terms)

    - #### Expression

          public Expression(Term... terms)

    - #### Expression

          public Expression(Expression expr)

    - #### Expression

          public Expression(java.util.Vector<Variable> v)

    - #### Expression

          public Expression(java.util.Set<Variable> v)

  - ### Method Detail

    - #### clone

          public Expression clone()

      Gets a copy of an expression.
      Overrides:
        `clone` in class `java.lang.Object`
      Returns:
        A copy of the expression.

    - #### getTerms

          public java.util.List<Term> getTerms()

      Gets the terms of the expression.
      Returns:
        Terms of the expression.

    - #### getConstant

          public double getConstant()

      Gets the constant of the expression.
      Returns:
        Constant of the expression.

    - #### negateExpression

          public static Expression negateExpression(Expression expr)

      Changes the sign of all the elements of an expression.
      Parameters:
        `expr` - An expression.
      Returns:
        A new (negated) expression.

    - #### addConstant

          public static Expression addConstant(Expression expr,
                                               java.lang.Double constant)

      Adds a double constant to an expression.
      Parameters:
        `expr` - An expression.
        `constant` - A double constant.
      Returns:
        A new expression with the sum.

    - #### setConstant

          public void setConstant(double constant)

      Sets a double constant to an expression.
      Parameters:
        `constant` - A double constant.

    - #### incrementConstant

          public void incrementConstant()

      Increments the double constant in one.

    - #### addTerm

          public void addTerm(Term term)

      Adds a term to an expression.
      Parameters:
        `term` - A term.

    - #### addTerm

          public static Expression addTerm(Expression expr,
                                           Term term)

      Adds a term to an expression.
      Parameters:
        `expr` - An expression.
        `term` - A term.
      Returns:
        A new expression with the sum.

    - #### addExpressions

          public static Expression addExpressions(Expression expr1,
                                                  Expression expr2)

      Adds two expressions.
      Parameters:
        `expr1` - An expression.
        `expr2` - Another expression.
      Returns:
        A new expression with the sum.

    - #### subtractExpressions

          public static Expression subtractExpressions(Expression expr1,
                                                       Expression expr2)

      Substracts two expressions.
      Parameters:
        `expr1` - First expression.
        `expr2` - Second expression.
      Returns:
        A new expression with the sum.

    - #### multiplyConstant

          public static Expression multiplyConstant(Expression expr,
                                                    java.lang.Double constant)

      Multiplies a double constant and an expression.
      Parameters:
        `expr` - An expression.
        `constant` - A double constant.
      Returns:
        A new expression with the product.

    - #### getConstantTerm

          public double getConstantTerm(Variable var)

      Given a variable, gets its coefficient in the expression.
      Parameters:
        `var` - A variable.
      Returns:
        Coefficient in the expression.

    - #### toString

          public java.lang.String toString()

      Gets a printable name of the expression.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        Name of the expression.