Class COptQuestObjectiveFunction


public class COptQuestObjectiveFunction extends COptQuestSingleObjective
The COptQuestObjectiveFunction class is used to define a linear objective. Linear objectives are in the form coeff1 * var1 + coeff2 * var2 + ... + coeffn * varN.
  • Constructor Details

    • COptQuestObjectiveFunction

      public COptQuestObjectiveFunction(String name)
      Constructor that assigns a name to the objective
      Parameters:
      name - alphanumeric name
    • COptQuestObjectiveFunction

      public COptQuestObjectiveFunction()
      Default constructor
  • Method Details

    • AddVariable

      public void AddVariable(COptQuestVariable variable, double coefficient)
      Adds a variable and its coefficient to the linear objective which has the form coeff1 * var1 + coeff2 + var2 + coeffn * varN. This method is called once for each variable.
    • ChangeVariableCoefficient

      public void ChangeVariableCoefficient(COptQuestVariable var, double coefficient)
      Change the coefficient for this variable.
    • GetNumberOfVariables

      public long GetNumberOfVariables()
      Returns the number of variable/coefficient pairs that were added to the linear objective.
      Returns:
      number of variables added to the linear objective
    • GetVariableAt

      public COptQuestVariable GetVariableAt(int index)
      Returns the variable at the specified index.
      Parameters:
      index - value between 0 and the number of variables added to the linear objective
      Returns:
      the decision variable at the specified index
    • GetCoefficientAt

      public double GetCoefficientAt(int index)
      Returns the coefficient at the specified index.
      Parameters:
      index - value between 0 and the number of variables added to the linear objective
      Returns:
      the coefficient at the specified index
    • IsLinear

      public boolean IsLinear()
      Returns true. COptQuestObjectiveFunction objects define a linear objective.
      Overrides:
      IsLinear in class COptQuestObjective
      Returns:
      true if the objective is a linear function of the decision variables.
    • GetNumCoefficients

      public int GetNumCoefficients()
      Returns the number of variable/coefficient pairs that were added to the linear objective.
      Returns:
      - the number of coefficients added to the linear objective.