Class COptQuestBudgetedSelectionVariable


public final class COptQuestBudgetedSelectionVariable extends COptQuestManifoldVariable
A budgeted selection variable. Its value is a selection of candidates whose total cost is within a budget. Use a budgeted selection variable when the decision is which candidates to include within a budget, such as which projects to fund.

The engine adds the budget rule, and the optional count rule, to the model as constraints, so a solution that does not meet a rule is infeasible.

Variable names: <name>@1 to <name>@n, one for each candidate. These are ordinary binary inputs. The value of each name is 1 if the candidate is selected and 0 if it is not.

In most programs, you add this variable with one of the OptQuestModel.AddBudgetedSelectionVariable methods and read its values with OptQuestSolution.GetValue(String) and the generated names. Construct this class only when you add the variable with COptQuestOptimization.AddVariable(COptQuestVariable).

See Also:
  • OptQuestModel.AddBudgetedSelectionVariable(String, int, double[], double)
  • OptQuestModel.AddBudgetedSelectionVariable(String, int, double[], double, double, int, int)
  • Constructor Details

    • COptQuestBudgetedSelectionVariable

      public COptQuestBudgetedSelectionVariable(String name, int n, double[] costs, double budgetMin, double budgetMax, int kMin, int kMax) throws COptQuestException
      Creates a budgeted selection variable with a budget range and a range for the number of selected candidates.
      Parameters:
      name - base name of the variable
      n - number of candidates; must be at least 1
      costs - cost of each candidate, one entry for each candidate
      budgetMin - smallest total cost of the selected candidates; 0 or less for no smallest total
      budgetMax - largest total cost of the selected candidates
      kMin - smallest number of candidates to select; 0 for no smallest number
      kMax - largest number of candidates to select; n for no largest number
      Throws:
      COptQuestException - if n is less than 1, if costs is null or does not have n entries, if no selection has from kMin to kMax candidates, if budgetMax is less than the lowest possible total cost, or if budgetMin is positive and greater than budgetMax or than the highest possible total cost
    • COptQuestBudgetedSelectionVariable

      public COptQuestBudgetedSelectionVariable(String name, int n, double[] costs, double budgetMax) throws COptQuestException
      Creates a budgeted selection variable whose selected candidates cost at most budgetMax.
      Parameters:
      name - base name of the variable
      n - number of candidates; must be at least 1
      costs - cost of each candidate, one entry for each candidate
      budgetMax - largest total cost of the selected candidates
      Throws:
      COptQuestException - if n is less than 1, if costs is null or does not have n entries, or if budgetMax is less than the lowest possible total cost
  • Method Details

    • getProjectedInputVariables

      public List<COptQuestUserControlledVariable> getProjectedInputVariables()
      Returns an empty list, because the values of a budgeted selection variable are ordinary inputs.

      The values are in the list that getInputVariables() returns. That list has the variables <name>@1 to <name>@n, one for each candidate.

      Returns:
      an empty list
    • getOutputVariables

      public List<COptQuestUserControlledVariable> getOutputVariables()
      Returns an empty list, because a budgeted selection variable has no output variables.

      The values of a budgeted selection variable are ordinary inputs, so they are in the list that getInputVariables() returns. That list has the variables <name>@1 to <name>@n, one for each candidate.

      Returns:
      an empty list
    • getInputVariables

      public List<COptQuestVariable> getInputVariables()
      Description copied from class: COptQuestManifoldVariable
      Returns the ordinary decision variables of this manifold variable.

      The engine chooses these values directly. Your evaluator reads them as inputs. The item selection and budgeted selection types use this list, and so do the vector, matrix and N-dimensional types of continuous, integer, discrete and binary variables. For every other type, the list is empty.

      Specified by:
      getInputVariables in class COptQuestManifoldVariable
      Returns:
      fixed-size or immutable list of input variables; never null
    • getConstraints

      public List<COptQuestStringConstraint> getConstraints()
      Description copied from class: COptQuestManifoldVariable
      Returns the constraints that this manifold variable adds to the model.

      The engine adds these constraints to the model when the variable is added. Most manifold variable types add no constraints and return an empty list.

      Overrides:
      getConstraints in class COptQuestManifoldVariable
      Returns:
      list of constraints; never null