mirror of
https://github.com/fverdugo/XM_40017.git
synced 2025-11-08 22:14:23 +01:00
More changes
This commit is contained in:
parent
6c681ef324
commit
9372448ef5
@ -124,6 +124,7 @@ makedocs(;
|
||||
"MPI" => "notebooks/mpi_tutorial.md",
|
||||
"Matrix Multiplication"=>"notebooks/matrix_matrix.md",
|
||||
"Jacobi" => "notebooks/jacobi_method.md",
|
||||
"ASP" => "notebooks/asp.md",
|
||||
"Solutions" => "notebooks/solutions.md"
|
||||
]],
|
||||
)
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
"\n",
|
||||
"In this notebook, we will learn\n",
|
||||
"\n",
|
||||
"- How to parallelize the Floyd's algorithm\n",
|
||||
"- How to parallelize Floyd's algorithm\n",
|
||||
"- How communication can affect the correctness of a distributed algorithm\n"
|
||||
]
|
||||
},
|
||||
@ -33,14 +33,14 @@
|
||||
"source": [
|
||||
"## The all pairs of shortest paths (ASP) problem\n",
|
||||
"\n",
|
||||
"Let us start by presenting the all pairs of shortest path (ASP) problem and its solution with the [Floyd–Warshall algorithm](https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm).\n",
|
||||
"Let us start by presenting the all pairs of shortest paths (ASP) problem and its solution with the [Floyd–Warshall algorithm](https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm).\n",
|
||||
"\n",
|
||||
"### Problem statement\n",
|
||||
"\n",
|
||||
"- Given a graph $G$ with a distance table $C$\n",
|
||||
"- Compute the length of the shortest path between any two nodes in $G$\n",
|
||||
"\n",
|
||||
"We represent the distance table as a matrix, where $C_{ij}$ is the distance from node $i$ to node $j$. Next figure shows the input and solution (output) of the ASP problem for a simple 4-node directed graph. For example, the solution of the problem contains the minimum distance from node 2 to node 3, which is $C_{23}=8$ as highlighted in the figure.\n"
|
||||
"We represent the distance table as a matrix, where $C_{ij}$ is the distance from node $i$ to node $j$. Next figure shows the input and solution (output) of the ASP problem for a simple 4-node directed graph. Note that the minimum distance from node 2 to node 3, which is $C_{23}=8$ as highlighted in the figure.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -70,21 +70,10 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": null,
|
||||
"id": "4fe447c5",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"floyd! (generic function with 1 method)"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"function floyd!(C)\n",
|
||||
" n = size(C,1)\n",
|
||||
@ -415,21 +404,10 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": null,
|
||||
"id": "09937668",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"rand_distance_table (generic function with 1 method)"
|
||||
]
|
||||
},
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"function rand_distance_table(n)\n",
|
||||
" threshold = 0.4\n",
|
||||
@ -451,31 +429,10 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": null,
|
||||
"id": "3116096c",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"10×10 Matrix{Int64}:\n",
|
||||
" 0 3 100000 100000 100000 … 3 100000 7 100000\n",
|
||||
" 8 0 3 10 5 9 9 10 10\n",
|
||||
" 100000 7 0 100000 8 100000 100000 7 7\n",
|
||||
" 3 100000 6 0 7 9 5 10 10\n",
|
||||
" 10 5 100000 7 0 100000 100000 8 100000\n",
|
||||
" 5 10 100000 3 9 … 4 10 7 100000\n",
|
||||
" 100000 9 8 10 100000 0 4 100000 4\n",
|
||||
" 5 10 9 100000 6 100000 0 5 100000\n",
|
||||
" 3 10 7 10 3 4 100000 0 100000\n",
|
||||
" 10 100000 9 4 6 3 100000 7 0"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"rand_distance_table(10)"
|
||||
]
|
||||
@ -500,21 +457,10 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": null,
|
||||
"id": "6bc0122b",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"MPI.ThreadLevel(2)"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"using MPIClusterManagers\n",
|
||||
"using Distributed\n",
|
||||
@ -536,21 +482,10 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": null,
|
||||
"id": "22234b2f",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"floyd_dist! (generic function with 1 method)"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"function floyd_dist!(C)\n",
|
||||
" m = size(C,1)\n",
|
||||
@ -567,7 +502,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"execution_count": null,
|
||||
"id": "d5a8d3a8",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@ -603,21 +538,10 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"execution_count": null,
|
||||
"id": "dd77ee3d",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"\u001b[32m\u001b[1mTest Passed\u001b[22m\u001b[39m"
|
||||
]
|
||||
},
|
||||
"execution_count": 24,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"using Test\n",
|
||||
"load = 10\n",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 2.9 MiB After Width: | Height: | Size: 3.0 MiB |
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user