Skip to main content

Is the TSP example's code in Gurobi documentation wrong???

Answered

Comments

2 comments

  • Jacob Jin
    Gurobi-versary
    Curious
    Collaborator
    if len(tour) < n:          
    model.cbLazy(gp.quicksum(model._vars[i, j] for i, j in combinations(tour, 2))
    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Jacob,

    The subtour elimination constraint reads

    \[\begin{align}
    \sum_{e \in E(S)}x_e \leq |S| - 1 \,\,\forall S \subset V, S \neq \emptyset, S \neq V
    \end{align}\]
    This means that for a given subset of nodes \(S\) of \(V\), the sum over all edges between any of the nodes in \(S\) shall be less or equal to the cardinality of \(S\) minus 1. Thus, the lazy constraint constructed in the tsp example is indeed correct.

    Best regards, 
    Jaromił

    0

Please sign in to leave a comment.