Class COptQuestPartitionVariable


public final class COptQuestPartitionVariable extends COptQuestManifoldVariable
A partition variable. Its value is a division of m items into exactly k groups. The groups have no order, and no group is empty. Use a partition variable when the decision is a division of items into groups, such as crews into shifts or customers into delivery zones.

In every solution that the engine generates, every group has at least one item, and the same division into groups always gets the same group numbers.

Variable names: <name>@1 to <name>@m, one for each item. The value of each name is the number of the group that the item is in, counted from 1. Item 1 is always in group 1. For each later item, the group number is at most one more than the largest group number among the items before it.

In a suggested solution, the engine rounds each value to the nearest group number from 1 to k. It then fills any empty group and numbers the groups again, so the values can change.

In most programs, you add this variable with OptQuestModel.AddPartitionVariable 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.AddPartitionVariable(String, int, int)
  • Constructor Details

    • COptQuestPartitionVariable

      public COptQuestPartitionVariable(String name, int m, int k) throws COptQuestException
      Creates a partition variable that divides m items into k groups.
      Parameters:
      name - base name of the variable
      m - number of items; must be at least k
      k - number of groups; must be at least 1
      Throws:
      COptQuestException - if k is less than 1 or m is less than k
  • Method Details

    • getInputVariables

      public List<COptQuestVariable> getInputVariables()
      Returns an empty list, because a partition variable has no ordinary input variables.

      The values of a partition variable are in the list that getProjectedInputVariables() returns. That list has the variables <name>@1 to <name>@m, one for each item.

      Returns:
      an empty list
    • getOutputVariables

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

      The values of a partition variable are in the list that getProjectedInputVariables() returns. That list has the variables <name>@1 to <name>@m, one for each item.

      Returns:
      an empty list
    • getProjectedInputVariables

      public List<COptQuestUserControlledVariable> getProjectedInputVariables()
      Description copied from class: COptQuestManifoldVariable
      Returns the decision values of this manifold variable that are not ordinary decision variables.

      For example, an angle variable returns angle@theta, and a mixture variable returns one mix@<component> name for each component. In every solution that the engine generates, and in every suggested solution, these values are inside the set of the variable. Your evaluator reads them as inputs: OptQuestSolution.GetInputNames() returns them.

      A constraint that uses one of these names is checked after the evaluation, like a constraint on an output. Your evaluator can receive values that break the constraint, and the solution is then infeasible.

      Specified by:
      getProjectedInputVariables in class COptQuestManifoldVariable
      Returns:
      fixed-size or immutable list of these 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