Class COptQuestPathVariable


public class COptQuestPathVariable extends COptQuestManifoldVariable
A path variable. Its value is a simple path through some of the given nodes: an order of nodes in which no node appears twice. Use a path variable when the decision is a route that visits some of the candidate nodes, such as a patrol route or a delivery tour.

In every solution that the engine generates, the path is valid. The positions of the nodes on the path are 1 to L, where L is the length of the path, with no gap and no repeat. The start node, when given, has position 1. The end node, when given and different from the start node, has position L. When the start node and the end node are the same node, it has position 1 only. Every required node is on the path. The path can have only one node.

Variable names: <name>@<node> for each node, in the order of nodeNames. The value of each name is the 1-based position of that node on the path, or 0 if the node is not on the path.

In a suggested solution, the engine puts a node whose value is 0 or less off the path, and it uses the other values only to order the nodes. The engine numbers the positions again, and it adds the start node, the end node and the required nodes when they are missing.

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

    • COptQuestPathVariable

      public COptQuestPathVariable(String name, String[] nodeNames) throws COptQuestException
      Creates a path variable with any start node, any end node and no required nodes.
      Parameters:
      name - base name of the variable
      nodeNames - names of the candidate nodes; there must be at least two, and each must be unique and must not contain whitespace, a semicolon, a comma or @
      Throws:
      COptQuestException - if nodeNames is null, has fewer than two nodes or holds a name that is not valid
    • COptQuestPathVariable

      public COptQuestPathVariable(String name, String[] nodeNames, String startNode, String endNode) throws COptQuestException
      Creates a path variable with an optional start node and an optional end node.
      Parameters:
      name - base name of the variable
      nodeNames - names of the candidate nodes; there must be at least two, and each must be unique and must not contain whitespace, a semicolon, a comma or @
      startNode - the node at position 1, or null for any start node
      endNode - the node at the last position, or null for any end node
      Throws:
      COptQuestException - if nodeNames is null, has fewer than two nodes or holds a name that is not valid, or if startNode or endNode is not in nodeNames
    • COptQuestPathVariable

      public COptQuestPathVariable(String name, String[] nodeNames, String startNode, String endNode, String[] requiredNodes) throws COptQuestException
      Creates a path variable with an optional start node, an optional end node and nodes that must be on the path.
      Parameters:
      name - base name of the variable
      nodeNames - names of the candidate nodes; there must be at least two, and each must be unique and must not contain whitespace, a semicolon, a comma or @
      startNode - the node at position 1, or null for any start node
      endNode - the node at the last position, or null for any end node
      requiredNodes - nodes that must be on the path, or null for none
      Throws:
      COptQuestException - if nodeNames is null, has fewer than two nodes or holds a name that is not valid, or if startNode, endNode or a required node is not in nodeNames
  • Method Details

    • getInputVariables

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

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

      Returns:
      an empty list
    • getOutputVariables

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

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

      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