[Python] Enforce conditional constraints with OR-Tools for a routing problem

Discussão em 'Python' iniciado por Stack, Dezembro 1, 2024.

  1. Stack

    Stack Membro Participativo

    I have a routing problem where I want a set of waypoints to be done one after another without anything in between as long as one has been started in the set.

    For example:

    • Waypoints (A, B, C, D, E)
    • A, C, E must be done together as long as one is started

    Which gives us:

    • The driver goes to B, then A, then they must do C and E so (B, A, C, E, D) or (B, A, E, C, D) but (B, A, D, E, C) is wrong.

    I would have wanted to use something like OnlyEnforceIf for a constraint but I can see it does not work with the routing solver.

    Does anyone have an idea of a solution? I assume I need conditional constraints but cannot work out a way of doing it.

    Continue reading...

Compartilhe esta Página