Class COptQuestConstraint

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

public abstract class COptQuestConstraint extends Object implements Cloneable
COptQuestConstraint is a pure virtual class that defines a linear constraint.
  • Constructor Details

    • COptQuestConstraint

      public COptQuestConstraint()
      Default constructor
    • COptQuestConstraint

      public COptQuestConstraint(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.
  • Method Details

    • clone

      public Object clone()
    • 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 - if variable type not valid for constraint
    • RemoveVariable

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

      public int GetNumberOfVariables()
      Returns the number of variables 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 findVar, double coefficient)
      Changes the coefficient of the variable to the value specified by the input parameter.
      Parameters:
      findVar - - variable to change
      coefficient - - new coefficient value
    • 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
    • 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 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)
      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.
    • SetName

      public void SetName(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.
    • SetTolerance

      public void SetTolerance(double tolerance)
      Set the tolerance per variable for the constraint