fuzzydl.milp
Class Expression

java.lang.Object
  extended by fuzzydl.milp.Expression

public class Expression
extends java.lang.Object

Linear expression of the form c + c1 * x1 + c2 * x2 + ... + cN * xN


Constructor Summary
Expression()
           
Expression(double constant)
           
Expression(double constant, Term... terms)
           
Expression(Expression expr)
          Copy constructor.
Expression(Term... terms)
           
 
Method Summary
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()
           
 void computeVariables()
          Creates a table with variables of the terms and their coefficients.
 double getConstant()
          Gets the constant of the expression.
 double getConstantTerm(Variable var)
          Given a variable, gets its coefficient in the expression.
 double getSolutionValue()
          Gets a numerical solution to the expression.
 java.util.List<Term> getTerms()
          Gets the terms of the expression.
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.
static Expression subtractExpressions(Expression expr1, Expression expr2)
          Substracts two expressions.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Expression

public Expression()

Expression

public Expression(double constant)
Parameters:
constant - Coefficient c.

Expression

public Expression(double constant,
                  Term... terms)
Parameters:
constant - Coefficient c.
terms - List of terms(ci,xi).

Expression

public Expression(Term... terms)
Parameters:
terms - List of terms(ci,xi).

Expression

public Expression(Expression expr)
Copy constructor.

Parameters:
expr - An expression.
Method Detail

clone

public Expression clone()
Overrides:
clone in class java.lang.Object

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.

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.

computeVariables

public void computeVariables()
Creates a table with variables of the terms and their coefficients.


getConstantTerm

public double getConstantTerm(Variable var)
Given a variable, gets its coefficient in the expression.

Parameters:
var - A variable.
Returns:
Coefficient in the expression.

getSolutionValue

public double getSolutionValue()
Gets a numerical solution to the expression.

Returns:
A numerical value of the solution.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object