Skip to content

Commit

Permalink
Removing outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
fverdugo committed Sep 25, 2024
1 parent 3b625af commit 4f6d656
Showing 1 changed file with 20 additions and 172 deletions.
192 changes: 20 additions & 172 deletions notebooks/tsp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -199,21 +199,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "a50706bc",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"sort_neighbors (generic function with 1 method)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"function sort_neighbors(C)\n",
" n = size(C,1)\n",
Expand All @@ -236,25 +225,10 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "6dd0288e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4-element Vector{Vector{Tuple{Int64, Int64}}}:\n",
" [(1, 0), (2, 2), (4, 2), (3, 3)]\n",
" [(2, 0), (4, 1), (1, 2), (3, 4)]\n",
" [(3, 0), (1, 3), (4, 3), (2, 4)]\n",
" [(4, 0), (2, 1), (1, 2), (3, 3)]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"C = [\n",
" 0 2 3 2\n",
Expand All @@ -275,27 +249,12 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "00608e1d",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"4-element Vector{Tuple{Int64, Int64}}:\n",
" (3, 0)\n",
" (1, 3)\n",
" (4, 3)\n",
" (2, 4)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"city = 3\n",
"C_sorted[city]"
Expand Down Expand Up @@ -342,21 +301,10 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "2ddc2ec1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"visit_all_paths_recursive! (generic function with 1 method)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"function visit_all_paths(C_sorted,city)\n",
" # Initialize path\n",
Expand Down Expand Up @@ -390,23 +338,10 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "723a0f1a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I just completed route [1, 2, 4, 3]\n",
"I just completed route [1, 2, 3, 4]\n",
"I just completed route [1, 4, 2, 3]\n",
"I just completed route [1, 4, 3, 2]\n",
"I just completed route [1, 3, 4, 2]\n",
"I just completed route [1, 3, 2, 4]\n"
]
}
],
"outputs": [],
"source": [
"city = 1\n",
"visit_all_paths(C_sorted,city)"
Expand Down Expand Up @@ -449,21 +384,10 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "5989f0ac",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"tsp_serial_no_prune_recursive! (generic function with 1 method)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"verbose::Bool = true\n",
"function tsp_serial_no_prune(C_sorted,city)\n",
Expand Down Expand Up @@ -503,33 +427,10 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "d1be2bfc",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I just completed route [1, 2, 4, 3]. Min distance so far is 6\n",
"I just completed route [1, 2, 3, 4]. Min distance so far is 6\n",
"I just completed route [1, 4, 2, 3]. Min distance so far is 6\n",
"I just completed route [1, 4, 3, 2]. Min distance so far is 6\n",
"I just completed route [1, 3, 4, 2]. Min distance so far is 6\n",
"I just completed route [1, 3, 2, 4]. Min distance so far is 6\n"
]
},
{
"data": {
"text/plain": [
"6"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"city = 1\n",
"verbose = true\n",
Expand Down Expand Up @@ -563,21 +464,10 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "8241e0df",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"tsp_serial_recursive! (generic function with 1 method)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"function tsp_serial(C_sorted,city)\n",
" num_cities = length(C_sorted)\n",
Expand Down Expand Up @@ -621,33 +511,10 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "998087f2",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I just completed route [1, 2, 4, 3]. Min distance so far is 6\n",
"I am pruning at [1, 2, 3]\n",
"I am pruning at [1, 4, 2, 3]\n",
"I am pruning at [1, 4, 3, 2]\n",
"I am pruning at [1, 3, 4]\n",
"I am pruning at [1, 3, 2]\n"
]
},
{
"data": {
"text/plain": [
"6"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"city = 1\n",
"verbose = true\n",
Expand All @@ -665,29 +532,10 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"id": "e1eb74d8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 1.214294 seconds (1 allocation: 144 bytes)\n",
" 0.002645 seconds (1 allocation: 144 bytes)\n"
]
},
{
"data": {
"text/plain": [
"\u001b[32m\u001b[1mTest Passed\u001b[22m\u001b[39m"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"n = 11 # It is safe to test up to n=11 on a laptop\n",
"using Random\n",
Expand Down

0 comments on commit 4f6d656

Please sign in to comment.