Skip to content

Commit e54a725

Browse files
committed
03 Naive TSP - text improvements.
1 parent c4b389e commit e54a725

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tutorials/03_Naive_approach.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"cell_type": "markdown",
1212
"metadata": {},
1313
"source": [
14-
"We need this line to have a proper [bra-ket](https://en.wikipedia.org/wiki/Bra–ket_notation) formatting in markdown.\n",
14+
"We need to run this line to have a proper [bra-ket](https://en.wikipedia.org/wiki/Bra–ket_notation) formatting in markdown.\n",
1515
"$$\n",
1616
"\\newcommand{\\ket}[1]{\\left| #1 \\right\\rangle}\n",
1717
"\\newcommand{\\bra}[1]{\\left\\langle #1 \\right|}\n",
@@ -285,7 +285,7 @@
285285
],
286286
"source": [
287287
"tsp_solver = ForestTSPSolverNaive(distance_matrix, use_constraints=True)\n",
288-
"solution, distribution = tsp_solver.solve_tsp()\n",
288+
"solution, naive_distribution = tsp_solver.solve_tsp()\n",
289289
"print(\"The solution is:\", solution)"
290290
]
291291
},
@@ -1264,7 +1264,7 @@
12641264
],
12651265
"source": [
12661266
"tsp_solver = ForestTSPSolverNaive(distance_matrix, use_constraints=True)\n",
1267-
"solution, distribution = tsp_solver.solve_tsp()\n",
1267+
"solution, naive_distribution = tsp_solver.solve_tsp()\n",
12681268
"print(\"The solution is:\", solution)"
12691269
]
12701270
},
@@ -1304,7 +1304,7 @@
13041304
"metadata": {},
13051305
"source": [
13061306
"Since it might be hard for you to decode the bitstrings, let's take a look at the human-readable representation.\n",
1307-
"(The two might actually differ, since many bitstrings for an invalid solution may have the same representation)."
1307+
"The two might actually differ, since many bitstrings may have the same representation in a case of an invalid solution. That's why we call the distribution coming from tsp_solver a `naive_distribution`."
13081308
]
13091309
},
13101310
{
@@ -1325,8 +1325,8 @@
13251325
],
13261326
"source": [
13271327
"solutions_with_probs = []\n",
1328-
"for state in distribution:\n",
1329-
" solutions_with_probs.append(['->'.join(map(str,state)), distribution[state]/10000])\n",
1328+
"for state in naive_distribution:\n",
1329+
" solutions_with_probs.append(['->'.join(map(str,state)), naive_distribution[state]/10000])\n",
13301330
"solutions_with_probs = sorted(solutions_with_probs,key=lambda x: -x[1])\n",
13311331
"\n",
13321332
"plots.plot_state_histogram(solutions_with_probs[:10][::-1])"

0 commit comments

Comments
 (0)