Class COptQuestDAGVariable


public class COptQuestDAGVariable extends COptQuestManifoldVariable
A DAG variable. Its value is a directed acyclic graph (DAG) over the given nodes: a set of directed edges with no cycle. Use a DAG variable when the decision is a set of one-way links with no loop, such as dependencies between tasks or a flow network.

In every solution that the engine generates, the edges form no cycle. Any DAG over the nodes can occur, including the graph with no edges.

Variable names: <name>@<nodeFrom>,<nodeTo> for every ordered pair of nodes, including a node paired with itself: the full n by n adjacency matrix, row by row in the order of nodeNames. The value of each name is 1 if the edge from nodeFrom to nodeTo is present and 0 if it is not. The diagonal is always 0. Each name contains a comma, so write it in brackets in an expression: [<name>@A,B].

In a suggested solution, a value greater than 0.5 is an edge. The engine keeps a suggested DAG as it is. If the suggested edges form a cycle, the engine removes edges until no cycle remains.

In most programs, you add this variable with OptQuestModel.AddDAGVariable 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:
  • Constructor Details

    • COptQuestDAGVariable

      public COptQuestDAGVariable(String name, String[] nodeNames) throws COptQuestException
      Creates a DAG variable over the given nodes.
      Parameters:
      name - base name of the variable
      nodeNames - names of the nodes; there must be at least one, and each must be unique and must not contain whitespace, a semicolon, a comma or @
      Throws:
      COptQuestException - if nodeNames is null or empty, or holds a name that is not valid
    • COptQuestDAGVariable

      public COptQuestDAGVariable(String name, String[] nodeNames, String startNode, String endNode, boolean connected, Map<String,List<String>> predecessors) throws COptQuestException
      Creates a DAG variable over the given nodes, with an optional start node, an optional end node, the connected option and optional precedences.
      Parameters:
      name - base name of the variable
      nodeNames - names of the nodes; there must be at least one, and each must be unique and must not contain whitespace, a semicolon, a comma or @
      startNode - the node that has no incoming edge and comes first, or null or empty
      endNode - the node that has no outgoing edge and comes last, or null or empty
      connected - true to make every node reachable from the start node and able to reach the end node; it needs a start node, an end node or both
      predecessors - map from a node to the nodes that must come before it, or null. No directed path runs from a node to one of its predecessors. Names that are not nodes are ignored.
      Throws:
      COptQuestException - if nodeNames is null or empty, holds a name that is not valid, if the start or end node is not one of the nodes, if the start node and the end node are the same node, if connected is true with no start node and no end node, if the start node has a predecessor, if the end node is a predecessor, if a node lists itself as a predecessor, or if the precedences form a cycle
  • Method Details

    • getInputVariables

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

      The values of a DAG variable are in the list that getProjectedInputVariables() returns. That list has one variable <name>@<nodeFrom>,<nodeTo> for every ordered pair of nodes.

      Returns:
      an empty list
    • getOutputVariables

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

      The values of a DAG variable are in the list that getProjectedInputVariables() returns. That list has one variable <name>@<nodeFrom>,<nodeTo> for every ordered pair of nodes.

      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