Skip to content

Commit

Permalink
Merge pull request #24 from venaturum/GH23_tsp_dict
Browse files Browse the repository at this point in the history
Reworking dictionary update for GH23
  • Loading branch information
Marika-K authored Apr 24, 2024
2 parents ae28d0c + 487308a commit 8968cac
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions traveling_salesman/tsp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,8 @@
"# Variables: is city 'i' adjacent to city 'j' on the tour?\n",
"vars = m.addVars(dist.keys(), obj=dist, vtype=GRB.BINARY, name='x')\n",
"\n",
"# Symmetric direction: Copy the object\n",
"for i, j in vars.keys():\n",
" vars[j, i] = vars[i, j] # edge in opposite direction\n",
"# Symmetric direction: use dict.update to alias variable with new key\n",
"vars.update({(j,i):vars[i,j] for i,j in vars.keys()})\n",
"\n",
"# Constraints: two edges incident to each city\n",
"cons = m.addConstrs(vars.sum(c, '*') == 2 for c in capitals)"
Expand Down

0 comments on commit 8968cac

Please sign in to comment.