diff --git a/notebooks/tsp.ipynb b/notebooks/tsp.ipynb index f8017c4..0c7898e 100644 --- a/notebooks/tsp.ipynb +++ b/notebooks/tsp.ipynb @@ -157,10 +157,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "03f0dd8e", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(path = [1, 4, 5, 2, 3, 6], distance = 222)" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "@everywhere function tsp_dist_impl(connections,hops,path,current_distance,min_distance,max_hops,jobs_chnl,ftr_result)\n", " num_cities = length(connections)\n", @@ -188,7 +199,7 @@ " end\n", " end \n", " else\n", - " if jobs_channel !== nothing\n", + " if jobs_chnl !== nothing\n", " put!(jobs_chnl,(;hops,path,current_distance))\n", " end\n", " end\n", @@ -208,7 +219,7 @@ " task = @async begin\n", " tsp_dist_impl(connections,hops,path,current_distance,min_distance,max_hops,jobs_chnl,nothing)\n", " for w in workers()\n", - " put!(job_chnl,nothing)\n", + " put!(jobs_chnl,nothing)\n", " end\n", " end\n", " @sync for w in workers()\n", @@ -220,14 +231,15 @@ " if job == nothing\n", " break\n", " end\n", - " hobs = job.hobs\n", + " hops = job.hops\n", " path = job.path\n", " current_distance = job.current_distance\n", - " tsp_dist_impl(connections,hops,path,current_distance,min_distance,max_hops,jobs_chnl,ftr_result)\n", + " tsp_dist_impl(connections,hops,path,current_distance,min_distance,max_hops,jobs_channel,ftr_result)\n", " end\n", " end\n", " end \n", - " (;path=path,distance=min_distance)\n", + " result = fetch(ftr_result)\n", + " (;path = result.path, distance = result.min_distance_ref[])\n", "end\n", "city = 1\n", "tsp_dist(connections,city)" @@ -244,7 +256,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Julia 1.9.0", + "display_name": "Julia 1.9.1", "language": "julia", "name": "julia-1.9" }, @@ -252,7 +264,7 @@ "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.9.0" + "version": "1.9.1" } }, "nbformat": 4,