Skip to main content

Generate all paths that consists of specified number of visits of nodes / edges

Answered

Comments

4 comments

  • Ronald van der Velden
    • Gurobi Staff Gurobi Staff

    Hi Huib,

    You could add two sets of constraints for each (node, i) combination:

    • Incoming: The sum of all actions[edge, i] that point towards node should equal states[node, i] 
    • Outgoing: The sum of all actions[edge, i+1] that leave from node should equal states[node, i] 

    Kind regards,
    Ronald

    0
  • Ronald van der Velden
    • Gurobi Staff Gurobi Staff

    Just a few additional thoughts:

    • You can calculate SUL_i and SUL_j without generating paths. Their values only depend on the values of GRC_i, GRB_j, RVL_i, RVL_j and the desired end state.
    • Once you know these, your model knows the exact number of states, removing the need for min_N and max_N.
    • Generating all possible path can lead to an exponentially large number of solutions. You can try our solution pool feature. Are you really looking for all of them?

    Kind regards,
    Ronald

    0
  • Huib Meulenbelt
    • Gurobi-versary
    • Curious
    • Conversationalist

    Hi Ronald, thank you for your insights. I am mainly interested in finding the value of `SUL_i` and `SUL_j`.

    You stated that its possible to retrieve these values without the paths. Is the following function correct

    from typing import Literal, Tuple


    def get_SUL(TDL_i: int, TDL_j: int, RVL_i: int, RVL_j: int, final_state: Literal['ST', 'GRC_i', 'GRC_j']) -> Tuple[int, int]:
    SUL_i = TDL_j + RVL_j - RVL_i
    SUL_j = TDL_i + RVL_i - RVL_j

    if final_state == 'GRC_i':
    SUL_j -= 1
    elif final_state == 'GRC_j':
    SUL_i -= 1
    else:
    pass

    return SUL_i, SUL_j
    0
  • Ronald van der Velden
    • Gurobi Staff Gurobi Staff

    The approach is roughly what I had in mind. The best way to verify if it's 100% correct, would be by testing it on several datasets.

    Kind regards,
    Ronald

    0

Please sign in to leave a comment.