Class COptQuestSequenceVariable


public class COptQuestSequenceVariable extends COptQuestManifoldVariable
A sequence variable. Its value is a priority order of the components. Use a sequence variable when the decision is an order of discrete items, such as a job sequence or the priority of sensor tasks.

In every solution that the engine generates, the ranks are valid. In a full ranking, the values are a permutation of 1 to n, where n is the number of components and 1 is the highest priority. In a top-k ranking, the first topK components get the ranks 1 to topK, and every other component gets the rank topK + 1.

Variable names: <name>@<component> for each component, in the order of components. The value of each name is the integer rank of that component. The constructors that take k name the components 1 to k.

When two components have the same rank in a suggested solution, the component that comes first in components gets the better rank.

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

    • COptQuestSequenceVariable

      public COptQuestSequenceVariable(String name, int k) throws COptQuestException
      Creates a full ranking of k components named 1 to k.
      Parameters:
      name - base name of the variable
      k - number of components; must be at least 1
      Throws:
      COptQuestException - if k is less than 1
    • COptQuestSequenceVariable

      public COptQuestSequenceVariable(String name, int k, Integer topK) throws COptQuestException
      Creates a ranking of k components named 1 to k.
      Parameters:
      name - base name of the variable
      k - number of components; must be at least 1
      topK - null for a full ranking, or the number of components to rank. A value of k or more gives a full ranking, and a value less than 1 is used as 1. With topK = 1, the most important component gets rank 1, and every other component gets rank 2.
      Throws:
      COptQuestException - if k is less than 1
    • COptQuestSequenceVariable

      public COptQuestSequenceVariable(String name, String[] components) throws COptQuestException
      Creates a full ranking of the given components.
      Parameters:
      name - base name of the variable
      components - names of the components; each must be unique and must not contain whitespace, a semicolon, a comma or @
      Throws:
      COptQuestException - if components is null or empty, or holds a name that is not valid
    • COptQuestSequenceVariable

      public COptQuestSequenceVariable(String name, String[] components, Integer topK) throws COptQuestException
      Creates a ranking of the given components.
      Parameters:
      name - base name of the variable
      components - names of the components; each must be unique and must not contain whitespace, a semicolon, a comma or @
      topK - null for a full ranking, or the number of components to rank. A value of n or more gives a full ranking, and a value less than 1 is used as 1. With topK = 1, the most important component gets rank 1, and every other component gets rank 2.
      Throws:
      COptQuestException - if components is null or empty, or holds a name that is not valid
  • Method Details

    • getInputVariables

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

      The values of a sequence variable are in the list that getProjectedInputVariables() returns. That list has one variable <name>@<component> for each component.

      Returns:
      an empty list
    • getOutputVariables

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

      The values of a sequence variable are in the list that getProjectedInputVariables() returns. That list has one variable <name>@<component> for each component.

      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