Skip to main content

Adding time window constraints on VRP gets an unexpected result

Answered

Comments

1 comment

  • Maliheh Aramon
    • Gurobi Staff Gurobi Staff

    Hi Daisuke, 

    The issue is likely happening because of the very big M value \(\texttt{numpy.inf}\) you are using in the RHS of the arrival time constraints. 

    The arrival time constraints ensure 

    if edges[j, i] = 1, then arrTime[i] >= arrTime[j] + dist_matrix[j, i]

    I would suggest to use the Gurobi API for indicator constraints and implement them as below:

    model.addConstrs(
    (
    (edges[j, i] == 1) >> (arrTime[i] >= arrTime[j] + dist_matrix[j][i])
    for i in range(n)
    for j in range(n)
    ),
    name="arrival_time",
    )
    Best regards,
    Maliheh
    0

Please sign in to leave a comment.