com.opttek.optquest
Class COptQuestConstraint

java.lang.Object
  extended bycom.opttek.optquest.COptQuestConstraint
Direct Known Subclasses:
COptQuestEQConstraint, COptQuestGEConstraint, COptQuestLEConstraint

public class COptQuestConstraint
extends java.lang.Object

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.
 double GetCoefficientAt(int index)
          Returns the coefficient at the specified 0 based index.
 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 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

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

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

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:

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.