|
11 | 11 | "cell_type": "markdown", |
12 | 12 | "metadata": {}, |
13 | 13 | "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", |
15 | 15 | "$$\n", |
16 | 16 | "\\newcommand{\\ket}[1]{\\left| #1 \\right\\rangle}\n", |
17 | 17 | "\\newcommand{\\bra}[1]{\\left\\langle #1 \\right|}\n", |
|
285 | 285 | ], |
286 | 286 | "source": [ |
287 | 287 | "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", |
289 | 289 | "print(\"The solution is:\", solution)" |
290 | 290 | ] |
291 | 291 | }, |
|
1264 | 1264 | ], |
1265 | 1265 | "source": [ |
1266 | 1266 | "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", |
1268 | 1268 | "print(\"The solution is:\", solution)" |
1269 | 1269 | ] |
1270 | 1270 | }, |
|
1304 | 1304 | "metadata": {}, |
1305 | 1305 | "source": [ |
1306 | 1306 | "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`." |
1308 | 1308 | ] |
1309 | 1309 | }, |
1310 | 1310 | { |
|
1325 | 1325 | ], |
1326 | 1326 | "source": [ |
1327 | 1327 | "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", |
1330 | 1330 | "solutions_with_probs = sorted(solutions_with_probs,key=lambda x: -x[1])\n", |
1331 | 1331 | "\n", |
1332 | 1332 | "plots.plot_state_histogram(solutions_with_probs[:10][::-1])" |
|
0 commit comments