Class COptQuestChoiceVariable


public class COptQuestChoiceVariable extends COptQuestManifoldVariable
A choice variable. Its value is one option out of k options. Use a choice variable when the decision is one selection from options that have no natural order, such as a machine type, a supplier or an operating mode.

In every solution that the engine generates, exactly one option is selected.

Variable names: <name>@choice, the 1-based index of the selected option, a whole number from 1 to k.

In a suggested solution, the engine rounds the value to the nearest whole number from 1 to k.

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

    • COptQuestChoiceVariable

      public COptQuestChoiceVariable(String name, int k) throws COptQuestException
      Creates a choice variable with k options.
      Parameters:
      name - base name of the variable
      k - number of options; must be at least 1
      Throws:
      COptQuestException - if k is less than 1
  • Method Details

    • getInputVariables

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

      The value of a choice variable is in the list that getProjectedInputVariables() returns. That list has one variable, <name>@choice.

      Returns:
      an empty list
    • getOutputVariables

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

      The value of a choice variable is in the list that getProjectedInputVariables() returns. That list has one variable, <name>@choice.

      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