Removing outputs

This commit is contained in:
Francesc Verdugo 2024-09-25 14:22:48 +02:00
parent 3b625af8fe
commit 4f6d6566b7

View File

@ -199,21 +199,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"id": "a50706bc", "id": "a50706bc",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"sort_neighbors (generic function with 1 method)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"function sort_neighbors(C)\n", "function sort_neighbors(C)\n",
" n = size(C,1)\n", " n = size(C,1)\n",
@ -236,25 +225,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"id": "6dd0288e", "id": "6dd0288e",
"metadata": {}, "metadata": {},
"outputs": [ "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"
}
],
"source": [ "source": [
"C = [\n", "C = [\n",
" 0 2 3 2\n", " 0 2 3 2\n",
@ -275,27 +249,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": null,
"id": "00608e1d", "id": "00608e1d",
"metadata": { "metadata": {
"scrolled": true "scrolled": true
}, },
"outputs": [ "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"
}
],
"source": [ "source": [
"city = 3\n", "city = 3\n",
"C_sorted[city]" "C_sorted[city]"
@ -342,21 +301,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": null,
"id": "2ddc2ec1", "id": "2ddc2ec1",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"visit_all_paths_recursive! (generic function with 1 method)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"function visit_all_paths(C_sorted,city)\n", "function visit_all_paths(C_sorted,city)\n",
" # Initialize path\n", " # Initialize path\n",
@ -390,23 +338,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"id": "723a0f1a", "id": "723a0f1a",
"metadata": {}, "metadata": {},
"outputs": [ "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"
]
}
],
"source": [ "source": [
"city = 1\n", "city = 1\n",
"visit_all_paths(C_sorted,city)" "visit_all_paths(C_sorted,city)"
@ -449,21 +384,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": null,
"id": "5989f0ac", "id": "5989f0ac",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"tsp_serial_no_prune_recursive! (generic function with 1 method)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"verbose::Bool = true\n", "verbose::Bool = true\n",
"function tsp_serial_no_prune(C_sorted,city)\n", "function tsp_serial_no_prune(C_sorted,city)\n",
@ -503,33 +427,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": null,
"id": "d1be2bfc", "id": "d1be2bfc",
"metadata": {}, "metadata": {},
"outputs": [ "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"
}
],
"source": [ "source": [
"city = 1\n", "city = 1\n",
"verbose = true\n", "verbose = true\n",
@ -563,21 +464,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": null,
"id": "8241e0df", "id": "8241e0df",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"tsp_serial_recursive! (generic function with 1 method)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"function tsp_serial(C_sorted,city)\n", "function tsp_serial(C_sorted,city)\n",
" num_cities = length(C_sorted)\n", " num_cities = length(C_sorted)\n",
@ -621,33 +511,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": null,
"id": "998087f2", "id": "998087f2",
"metadata": {}, "metadata": {},
"outputs": [ "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"
}
],
"source": [ "source": [
"city = 1\n", "city = 1\n",
"verbose = true\n", "verbose = true\n",
@ -665,29 +532,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": null,
"id": "e1eb74d8", "id": "e1eb74d8",
"metadata": {}, "metadata": {},
"outputs": [ "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"
}
],
"source": [ "source": [
"n = 11 # It is safe to test up to n=11 on a laptop\n", "n = 11 # It is safe to test up to n=11 on a laptop\n",
"using Random\n", "using Random\n",