com.opttek.optquest
Class COptQuestConstraint

java.lang.Object
  extended by com.opttek.optquest.COptQuestConstraint
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
COptQuestEQConstraint, COptQuestGEConstraint, COptQuestLEConstraint

public abstract class COptQuestConstraint
extends java.lang.Object
implements java.lang.Cloneable

COptQuestConstraint is a pure virtual class that defines a linear constraint.


Constructor Summary
COptQuestConstraint()
          Default constructor
COptQuestConstraint(double rhs)
          Constructor that assigns a value for the right hand side.
COptQuestConstraint(java.lang.String name, double rhs)
          Constructor that assigns a name and value for the right hand side.
 
Method Summary
 void AddVariable(COptQuestVariable variable, double coefficient)
          Adds a variable and its coefficient to the linear expression.
 void ChangeVariableCoefficient(COptQuestVariable var, double coefficient)
          Changes the coefficient of the variable to the value specified by the input parameter.
 java.lang.Object clone()
           
 double GetCoefficientAt(int index)
          Returns the coefficient at the specified 0 based index.
 double GetLHSValue(COptQuestSolution sol)
          For internal use only Evaluate the left side of the constraint and return the value
 java.lang.String GetName()
          Returns the name assigned to the constraint.
 int GetNumberOfVariables()
          Returns the number of varaibles that were added to the constraint by calls to the AddVariable() method.
 double GetRHS()
          Returns the right hand side value.
 int GetType()
           
 COptQuestVariable GetVariableAt(int index)
          Returns the COptQuestVariable at the specified 0 based index.
 void RemoveVariable(COptQuestVariable variable)
          Modifies the constraint by removing the variable.
 void SetName(java.lang.String value)
          Assigns a name to the constraint.
 void SetRHS(double val)
          Sets the right hand side value of a linear constraint.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

COptQuestConstraint

public COptQuestConstraint(java.lang.String name,
                           double rhs)
Constructor that assigns a name and value for the right hand side.

Parameters:
name - - Alpha numeric constraint name.
rhs - - right hand side value for the constraint.

COptQuestConstraint

public COptQuestConstraint(double rhs)
Constructor that assigns a value for the right hand side.

Parameters:
rhs - - right hand side value for the constraint.

COptQuestConstraint

public COptQuestConstraint()
Default constructor

Method Detail

clone

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

AddVariable

public void AddVariable(COptQuestVariable variable,
                        double coefficient)
                 throws COptQuestException
Adds a variable and its coefficient to the linear expression. This method is called for each variable that is used in the left hand side expression. For example, the constraint 2*Var1 + 3*Var2 + 1.5*Var3 <= 100 would call AddVariable(Var1,2), AddVariable(Var2, 3) and AddVariable(Var3,1.5).

Parameters:
variable - - COptQuestVariable object that is in the linear expression
coefficient - - coefficient of the variable
Throws:
COptQuestException

RemoveVariable

public void RemoveVariable(COptQuestVariable variable)
Modifies the constraint by removing the variable.

Parameters:
variable -

GetNumberOfVariables

public int GetNumberOfVariables()
Returns the number of varaibles that were added to the constraint by calls to the AddVariable() method.

Returns:
count of the number of variables in the left hand side of the linear expression.

GetVariableAt

public COptQuestVariable GetVariableAt(int index)
Returns the COptQuestVariable at the specified 0 based index. For example, the constraint 2*Var1 + 3*Var2 + 1.5*Var3 <= 100 called AddVariable(Var1,2), AddVariable(Var2, 3) and AddVariable(Var3,1.5). GetVariableAt(1) would return the COptQuestVariable object for Var2.

Parameters:
index - 0 based index
Returns:
COptQuestVariable at the specified index

ChangeVariableCoefficient

public void ChangeVariableCoefficient(COptQuestVariable var,
                                      double coefficient)
Changes the coefficient of the variable to the value specified by the input parameter.

Parameters:
var -
coefficient -

GetCoefficientAt

public double GetCoefficientAt(int index)
Returns the coefficient at the specified 0 based index. For example, the constraint 2*Var1 + 3*Var2 + 1.5*Var3 <= 100 called AddVariable(Var1,2), AddVariable(Var2, 3) and AddVariable(Var3,1.5). GetCoefficientAt(1) would return 3, the coefficient for Var2.

Parameters:
index - 0 based index
Returns:
coefficient at the specified index

GetType

public int GetType()

SetRHS

public void SetRHS(double val)
Sets the right hand side value of a linear constraint.

Parameters:
val - - right hand side value

GetRHS

public double GetRHS()
Returns the right hand side value. The default value is 0.0.

Returns:
the right hand side value.

GetName

public java.lang.String GetName()
Returns the name assigned to the constraint. Returns an empty string if the constraint is not named.

Returns:
the name assigned to the constraint

GetLHSValue

public double GetLHSValue(COptQuestSolution sol)
                   throws COptQuestException
For internal use only Evaluate the left side of the constraint and return the value

Parameters:
sol - - solution to be used for evaluation
Returns:
- value of the left hand side.
Throws:
COptQuestException

SetName

public void SetName(java.lang.String value)
Assigns a name to the constraint. Names must be alphanumeric and cannot be a function name recognized by the COptQuestEquationSolver.

Parameters:
value - = name of the variable.