Clear outputs

This commit is contained in:
Gelieza K 2023-11-02 13:22:12 +01:00
parent f7de703973
commit a7b86b4a38
3 changed files with 77 additions and 510 deletions

View File

@ -37,21 +37,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"id": "7e93809a", "id": "7e93809a",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"ge_dep_check (generic function with 1 method)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"using Printf\n", "using Printf\n",
"function answer_checker(answer,solution)\n", "function answer_checker(answer,solution)\n",
@ -160,21 +149,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"id": "e4070214", "id": "e4070214",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"gaussian_elimination! (generic function with 1 method)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"function gaussian_elimination!(B)\n", "function gaussian_elimination!(B)\n",
" n,m = size(B)\n", " n,m = size(B)\n",
@ -206,24 +184,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"id": "eb30df0d", "id": "eb30df0d",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"3×4 Matrix{Float64}:\n",
" 1.0 3.0 1.0 9.0\n",
" 0.0 1.0 2.0 8.0\n",
" 0.0 0.0 1.0 4.0"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"A = Float64[1 3 1; 1 2 -1; 3 11 5]\n", "A = Float64[1 3 1; 1 2 -1; 3 11 5]\n",
"b = Float64[9,1,35]\n", "b = Float64[9,1,35]\n",
@ -288,18 +252,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"id": "078e974e", "id": "078e974e",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"It's not correct. Keep trying! 💪\n"
]
}
],
"source": [ "source": [
"answer = \"x\" # replace x with a, b, c, or d \n", "answer = \"x\" # replace x with a, b, c, or d \n",
"ge_par_check(answer)" "ge_par_check(answer)"
@ -412,18 +368,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": null,
"id": "e0565e92", "id": "e0565e92",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"It's not correct. Keep trying! 💪\n"
]
}
],
"source": [ "source": [
"answer = \"x\" # replace x with a, b, c, or d \n", "answer = \"x\" # replace x with a, b, c, or d \n",
"ge_dep_check(answer)" "ge_dep_check(answer)"
@ -476,21 +424,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"id": "a65cf8e6", "id": "a65cf8e6",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"tridiagonal_matrix (generic function with 1 method)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"function tridiagonal_matrix(n)\n", "function tridiagonal_matrix(n)\n",
" C = zeros(n,n)\n", " C = zeros(n,n)\n",

View File

@ -38,21 +38,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": null,
"id": "1dc78750", "id": "1dc78750",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"floyd_impl_check (generic function with 1 method)"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"using Printf\n", "using Printf\n",
"\n", "\n",
@ -111,21 +100,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": null,
"id": "4fe447c5", "id": "4fe447c5",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"floyd! (generic function with 1 method)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"function floyd!(C)\n", "function floyd!(C)\n",
" n = size(C,1)\n", " n = size(C,1)\n",
@ -151,25 +129,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": null,
"id": "860e537c", "id": "860e537c",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"4×4 Matrix{Int64}:\n",
" 0 9 6 1\n",
" 2 0 8 3\n",
" 5 3 0 6\n",
" 10 8 5 0"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"inf = 1000\n", "inf = 1000\n",
"C = [\n", "C = [\n",
@ -303,21 +266,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": null,
"id": "75cac17e", "id": "75cac17e",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"floyd2! (generic function with 1 method)"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"function floyd2!(C)\n", "function floyd2!(C)\n",
" n = size(C,1)\n", " n = size(C,1)\n",
@ -343,19 +295,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"id": "907bc8c9", "id": "907bc8c9",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
" 3.927992 seconds\n",
" 6.501955 seconds\n"
]
}
],
"source": [ "source": [
"n = 1000\n", "n = 1000\n",
"C = rand(n,n)\n", "C = rand(n,n)\n",
@ -527,18 +470,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": null,
"id": "1bf4de56", "id": "1bf4de56",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"It's not correct. Keep trying! 💪\n"
]
}
],
"source": [ "source": [
"answer = \"x\" # replace x with a, b, c or d\n", "answer = \"x\" # replace x with a, b, c or d\n",
"floyd_check(answer)" "floyd_check(answer)"
@ -638,21 +573,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"id": "6bc0122b", "id": "6bc0122b",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"MPI.ThreadLevel(2)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"using MPIClusterManagers\n", "using MPIClusterManagers\n",
"using Distributed\n", "using Distributed\n",
@ -676,21 +600,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": null,
"id": "22234b2f", "id": "22234b2f",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"floyd_dist! (generic function with 1 method)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"function floyd_dist!(C)\n", "function floyd_dist!(C)\n",
" m = size(C,1)\n", " m = size(C,1)\n",
@ -715,7 +628,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"id": "d5a8d3a8", "id": "d5a8d3a8",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -774,18 +687,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": null,
"id": "4f4a57de", "id": "4f4a57de",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"It's not correct. Keep trying! 💪\n"
]
}
],
"source": [ "source": [
"answer = \"x\" # replace x with a, b, c or d\n", "answer = \"x\" # replace x with a, b, c or d\n",
"floyd_impl_check(answer)" "floyd_impl_check(answer)"
@ -801,21 +706,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 20, "execution_count": null,
"id": "09937668", "id": "09937668",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"rand_distance_table (generic function with 1 method)"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"function rand_distance_table(n)\n", "function rand_distance_table(n)\n",
" threshold = 0.4\n", " threshold = 0.4\n",
@ -837,37 +731,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 21, "execution_count": null,
"id": "dd77ee3d", "id": "dd77ee3d",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[91m\u001b[1mTest Failed\u001b[22m\u001b[39m at \u001b[39m\u001b[1mIn[21]:7\u001b[22m\n",
" Expression: C_seq == C_par\n",
" Evaluated: [0 6 … 3 5; 6 0 … 8 9; … ; 7 8 … 0 6; 3 9 … 5 0] == [0 6 … 3 5; 6 0 … 8 9; … ; 7 8 … 0 6; 3 9 … 5 0]\n",
"\n"
]
},
{
"ename": "LoadError",
"evalue": "\u001b[91mThere was an error during testing\u001b[39m",
"output_type": "error",
"traceback": [
"\u001b[91mThere was an error during testing\u001b[39m",
"",
"Stacktrace:",
" [1] record(ts::Test.FallbackTestSet, t::Union{Test.Error, Test.Fail})",
" @ Test C:\\Users\\gelie\\AppData\\Local\\Programs\\julia-1.9.1\\share\\julia\\stdlib\\v1.9\\Test\\src\\Test.jl:960",
" [2] do_test(result::Test.ExecutionResult, orig_expr::Any)",
" @ Test C:\\Users\\gelie\\AppData\\Local\\Programs\\julia-1.9.1\\share\\julia\\stdlib\\v1.9\\Test\\src\\Test.jl:670",
" [3] top-level scope",
" @ C:\\Users\\gelie\\AppData\\Local\\Programs\\julia-1.9.1\\share\\julia\\stdlib\\v1.9\\Test\\src\\Test.jl:478"
]
}
],
"source": [ "source": [
"using Test\n", "using Test\n",
"load = 10\n", "load = 10\n",

View File

@ -38,21 +38,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 43, "execution_count": null,
"id": "7e93809a", "id": "7e93809a",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"tsp_check_3 (generic function with 1 method)"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"using Printf\n", "using Printf\n",
"function answer_checker(answer,solution)\n", "function answer_checker(answer,solution)\n",
@ -194,18 +183,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 25, "execution_count": null,
"id": "ce2f2c8a", "id": "ce2f2c8a",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"It's not correct. Keep trying! 💪\n"
]
}
],
"source": [ "source": [
"answer = -1 # Replace this with any positive integer value\n", "answer = -1 # Replace this with any positive integer value\n",
"tsp_check_1(answer)" "tsp_check_1(answer)"
@ -231,21 +212,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": null,
"id": "a50706bc", "id": "a50706bc",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"sort_neighbors (generic function with 1 method)"
]
},
"execution_count": 9,
"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",
@ -260,25 +230,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": null,
"id": "2eeecdd6", "id": "2eeecdd6",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"4×4 Matrix{Int64}:\n",
" 0 2 3 2\n",
" 2 0 4 1\n",
" 3 4 0 3\n",
" 2 1 3 0"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"C = [\n", "C = [\n",
" 0 2 3 2\n", " 0 2 3 2\n",
@ -298,25 +253,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "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": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"C_sorted = sort_neighbors(C)" "C_sorted = sort_neighbors(C)"
] ]
@ -331,27 +271,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "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": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"city = 3\n", "city = 3\n",
"C_sorted[city]" "C_sorted[city]"
@ -390,21 +315,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "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": 6,
"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",
@ -438,23 +352,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": null,
"id": "723a0f1a", "id": "723a0f1a",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 2, 4, 3]\n",
"[1, 2, 3, 4]\n",
"[1, 4, 2, 3]\n",
"[1, 4, 3, 2]\n",
"[1, 3, 4, 2]\n",
"[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)"
@ -487,21 +388,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "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": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"function tsp_serial_no_prune(C_sorted,city)\n", "function tsp_serial_no_prune(C_sorted,city)\n",
" num_cities = length(C_sorted)\n", " num_cities = length(C_sorted)\n",
@ -540,21 +430,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": null,
"id": "d1be2bfc", "id": "d1be2bfc",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"6"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"city = 1\n", "city = 1\n",
"min_distance = tsp_serial_no_prune(C_sorted,city)" "min_distance = tsp_serial_no_prune(C_sorted,city)"
@ -587,21 +466,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 38, "execution_count": null,
"id": "8241e0df", "id": "8241e0df",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"tsp_serial_recursive! (generic function with 1 method)"
]
},
"execution_count": 38,
"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",
@ -644,21 +512,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": null,
"id": "998087f2", "id": "998087f2",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"6"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"city = 1\n", "city = 1\n",
"min_distance = tsp_serial(C_sorted,city)" "min_distance = tsp_serial(C_sorted,city)"
@ -675,25 +532,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 41, "execution_count": null,
"id": "e1eb74d8", "id": "e1eb74d8",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"ename": "LoadError",
"evalue": "UndefVarError: `tsp_serial_no_prune` not defined",
"output_type": "error",
"traceback": [
"UndefVarError: `tsp_serial_no_prune` not defined",
"",
"Stacktrace:",
" [1] top-level scope",
" @ .\\timing.jl:273 [inlined]",
" [2] top-level scope",
" @ .\\In[41]:0"
]
}
],
"source": [ "source": [
"n = 12 # It is safe to test up to n=12\n", "n = 12 # It is safe to test up to n=12\n",
"using Random\n", "using Random\n",
@ -837,18 +679,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"id": "95e952af", "id": "95e952af",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"It's not correct. Keep trying! 💪\n"
]
}
],
"source": [ "source": [
"answer = -1 # Replace with any integer value \n", "answer = -1 # Replace with any integer value \n",
"tsp_check_2(answer)" "tsp_check_2(answer)"
@ -879,18 +713,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 46, "execution_count": null,
"id": "fff58498", "id": "fff58498",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"It's not correct. Keep trying! 💪\n"
]
}
],
"source": [ "source": [
"answer = \"x\" # Replace x with a,b,c or d\n", "answer = \"x\" # Replace x with a,b,c or d\n",
"tsp_check_3(answer)" "tsp_check_3(answer)"
@ -940,7 +766,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": null,
"id": "354f5abb", "id": "354f5abb",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -950,7 +776,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": null,
"id": "7f8f6702", "id": "7f8f6702",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -972,7 +798,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": null,
"id": "5c0603a1", "id": "5c0603a1",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -1048,26 +874,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 32, "execution_count": null,
"id": "02801b66", "id": "02801b66",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"path = [1, 2, 0, 0]\n",
"path = [1, 4, 0, 0]\n",
"path = [1, 3, 0, 0]\n",
" From worker 2:\tpath = [1, 2, 4, 3]\n",
" From worker 3:\tpath = [1, 4, 2, 3]\n",
" From worker 4:\tpath = [1, 3, 4, 2]\n",
" From worker 4:\tpath = [1, 3, 2, 4]\n",
" From worker 2:\tpath = [1, 2, 3, 4]\n",
" From worker 3:\tpath = [1, 4, 3, 2]\n"
]
}
],
"source": [ "source": [
"C = [\n", "C = [\n",
" 0 2 3 2\n", " 0 2 3 2\n",
@ -1117,24 +927,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 34, "execution_count": null,
"id": "d0303392", "id": "d0303392",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
" From worker 3:\tmin_distance = 9223372036854775807\n",
" From worker 3:\tdistance = 10\n",
" From worker 2:\tmin_distance = 10\n",
" From worker 2:\tdistance = 5\n",
" From worker 4:\tmin_distance = 5\n",
" From worker 4:\tdistance = 6\n",
"min_distance = 5\n"
]
}
],
"source": [ "source": [
"buffer = 1 # Very important\n", "buffer = 1 # Very important\n",
"min_distance_chnl = RemoteChannel(()->Channel{Int}(buffer))\n", "min_distance_chnl = RemoteChannel(()->Channel{Int}(buffer))\n",
@ -1166,7 +962,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 35, "execution_count": null,
"id": "96c649b7", "id": "96c649b7",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -1260,21 +1056,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 36, "execution_count": null,
"id": "67888155", "id": "67888155",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"6"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"city = 1\n", "city = 1\n",
"max_hops = 2\n", "max_hops = 2\n",
@ -1292,32 +1077,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 42, "execution_count": null,
"id": "9d950905", "id": "9d950905",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"Sequential time = 39.7130992\n",
"Parallel time = 17.0584423\n",
"Speedup = 2.328061290801447\n",
"Optimal speedup = 3\n",
"Efficiency = 77.6020430267149%\n"
]
},
{
"data": {
"text/plain": [
"\u001b[32m\u001b[1mTest Passed\u001b[22m\u001b[39m"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"n = 18 # Safe to run up to 18\n", "n = 18 # Safe to run up to 18\n",
"using Random\n", "using Random\n",