com.singularsys.aa.linear
Class LinearExpr

java.lang.Object
  extended by com.singularsys.aa.SimpleExpr
      extended by com.singularsys.aa.linear.LinearExpr
All Implemented Interfaces:
Expression

public class LinearExpr
extends SimpleExpr

Stores a linear expressions. These must be of the form:

 constant + c1*v1 + c2*v2 + c3*v3 + ...
 
where c1, c2, and c3 are the constant coefficients of the variables v1, v2, and v3 respectively.


Field Summary
 
Fields inherited from class com.singularsys.aa.SimpleExpr
variables
 
Constructor Summary
LinearExpr()
           
 
Method Summary
 void addCoefficient(java.lang.String name, java.lang.Object value)
          Adds a coefficient to the linear equation.
 java.lang.Object getCoefficient(java.lang.String name)
          Returns the value of the coefficient for a variable specified by name.
 java.lang.Object getConstant()
          Returns the constant value of the equation.
 java.lang.Object getValue(java.util.Hashtable varValues)
          Returns the value of the expression given the variable values in
 boolean hasCoefficient(java.lang.String name)
          Returns true if a variable "name" has a coefficient associated with it.
 void setConstant(java.lang.Object constant_in)
          Sets the constant value of the linear equation
 
Methods inherited from class com.singularsys.aa.SimpleExpr
getValue, getVariables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearExpr

public LinearExpr()
Method Detail

setConstant

public void setConstant(java.lang.Object constant_in)
Sets the constant value of the linear equation


getConstant

public java.lang.Object getConstant()
Returns the constant value of the equation. Returns a Double object with a 0 value if the constant value was not set.


addCoefficient

public void addCoefficient(java.lang.String name,
                           java.lang.Object value)
Adds a coefficient to the linear equation. There is one value for every variable name. So if addCoefficient() is called twice for the same variable name, the value from the first call is overwritten.


getCoefficient

public java.lang.Object getCoefficient(java.lang.String name)
Returns the value of the coefficient for a variable specified by name. If the variable is not found, a Double object with a value of zero is returned.


hasCoefficient

public boolean hasCoefficient(java.lang.String name)
Returns true if a variable "name" has a coefficient associated with it.


getValue

public java.lang.Object getValue(java.util.Hashtable varValues)
Returns the value of the expression given the variable values in
varValues
.

Specified by:
getValue in interface Expression
Overrides:
getValue in class SimpleExpr
Parameters:
varValues - A hastable containing the variable names as keys, and the values as objects.
Returns:
The value of the expression.