メインコンテンツへスキップ

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

回答済み

コメント

3件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support.
  • 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

    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

投稿コメントは受け付けていません。