mirror of
https://github.com/fverdugo/XM_40017.git
synced 2025-11-09 01:34:24 +01:00
Debug TSP implementation
This commit is contained in:
parent
d954714bed
commit
9991211f35
@ -157,10 +157,21 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 10,
|
||||||
"id": "03f0dd8e",
|
"id": "03f0dd8e",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"(path = [1, 4, 5, 2, 3, 6], distance = 222)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 10,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"@everywhere function tsp_dist_impl(connections,hops,path,current_distance,min_distance,max_hops,jobs_chnl,ftr_result)\n",
|
"@everywhere function tsp_dist_impl(connections,hops,path,current_distance,min_distance,max_hops,jobs_chnl,ftr_result)\n",
|
||||||
" num_cities = length(connections)\n",
|
" num_cities = length(connections)\n",
|
||||||
@ -188,7 +199,7 @@
|
|||||||
" end\n",
|
" end\n",
|
||||||
" end \n",
|
" end \n",
|
||||||
" else\n",
|
" else\n",
|
||||||
" if jobs_channel !== nothing\n",
|
" if jobs_chnl !== nothing\n",
|
||||||
" put!(jobs_chnl,(;hops,path,current_distance))\n",
|
" put!(jobs_chnl,(;hops,path,current_distance))\n",
|
||||||
" end\n",
|
" end\n",
|
||||||
" end\n",
|
" end\n",
|
||||||
@ -208,7 +219,7 @@
|
|||||||
" task = @async begin\n",
|
" task = @async begin\n",
|
||||||
" tsp_dist_impl(connections,hops,path,current_distance,min_distance,max_hops,jobs_chnl,nothing)\n",
|
" tsp_dist_impl(connections,hops,path,current_distance,min_distance,max_hops,jobs_chnl,nothing)\n",
|
||||||
" for w in workers()\n",
|
" for w in workers()\n",
|
||||||
" put!(job_chnl,nothing)\n",
|
" put!(jobs_chnl,nothing)\n",
|
||||||
" end\n",
|
" end\n",
|
||||||
" end\n",
|
" end\n",
|
||||||
" @sync for w in workers()\n",
|
" @sync for w in workers()\n",
|
||||||
@ -220,14 +231,15 @@
|
|||||||
" if job == nothing\n",
|
" if job == nothing\n",
|
||||||
" break\n",
|
" break\n",
|
||||||
" end\n",
|
" end\n",
|
||||||
" hobs = job.hobs\n",
|
" hops = job.hops\n",
|
||||||
" path = job.path\n",
|
" path = job.path\n",
|
||||||
" current_distance = job.current_distance\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",
|
" 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",
|
"end\n",
|
||||||
"city = 1\n",
|
"city = 1\n",
|
||||||
"tsp_dist(connections,city)"
|
"tsp_dist(connections,city)"
|
||||||
@ -244,7 +256,7 @@
|
|||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Julia 1.9.0",
|
"display_name": "Julia 1.9.1",
|
||||||
"language": "julia",
|
"language": "julia",
|
||||||
"name": "julia-1.9"
|
"name": "julia-1.9"
|
||||||
},
|
},
|
||||||
@ -252,7 +264,7 @@
|
|||||||
"file_extension": ".jl",
|
"file_extension": ".jl",
|
||||||
"mimetype": "application/julia",
|
"mimetype": "application/julia",
|
||||||
"name": "julia",
|
"name": "julia",
|
||||||
"version": "1.9.0"
|
"version": "1.9.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user