mp3: done 1-4

This commit is contained in:
Claudio Maggioni 2020-10-23 09:20:58 +02:00
parent f813322cbd
commit 61f42a782a
14 changed files with 730607 additions and 73080 deletions

View file

@ -10,6 +10,8 @@ addpaths_GP;
nlevels_a = 3;
nlevels_b = 4;
%addpath /Users/maggicl/Git/matlab2tikz/src/;
fprintf(' *********************************************\n')
fprintf(' *** Recursive graph bisection benchmark ***\n');
fprintf(' *********************************************\n')
@ -58,23 +60,102 @@ for c = 1:nc
fprintf('%s %s', cases{c}, spacers);
sparse_matrix = load(cases{c});
if c == 5
g = 1;
else
g = 0;
end
% Recursively bisect the loaded graphs in 8 and 16 subgraphs.
% Steps
% 1. Initialize the problem
[params] = Initialize_case(sparse_matrices(c));
W = params.Adj;
coords = params.coords;
A = params.Adj;
coords = params.coords;
W = A - diag(diag(A));
% 2. Recursive routines
% i. Spectral
% i. Spectral
sp8 = runtest(W, coords, @(a, b) bisection_spectral(a, b, 0), ...
3, '', 0);
sp16 = runtest(W, coords, @(a, b) bisection_spectral(a, b, 0), ...
4, 'Spectral', g);
% ii. Metis
% iii. Coordinate
m8 = runtest(W, coords, @(a, b) bisection_metis(a, b, 0), ...
3, '', 0);
m16 = runtest(W, coords, @(a, b) bisection_metis(a, b, 0), ...
4, 'METIS', g);
% iii. Coordinate
c8 = runtest(W, coords, @(a, b) bisection_coordinate(a, b, 0), ...
3, '', 0);
c16 = runtest(W, coords, @(a, b) bisection_coordinate(a, b, 0), ...
4, 'Coordinate', g);
% iv. Inertial
i8 = runtest(W, coords, @(a, b) bisection_inertial(a, b, 0), ...
3, '', 0);
i16 = runtest(W, coords, @(a, b) bisection_inertial(a, b, 0), ...
4, 'Inertial', g);
close;
% 3. Calculate number of cut edges
% 4. Visualize the partitioning result
fprintf('%6d %6d %10d %6d %10d %6d %10d %6d %d\n',sp8,sp16,...
m8,m16,c8,c16,i8,i16, nnz(diag(A)));
fprintf('%6d %6d %10d %6d %10d %6d %10d %6d\n',0,0,...
0,0,0,0,0,0);
end
% Bisection Spectral Metis 5.0.2 Coordinate Inertial
% Partitions 8 16 8 16 8 16 8 16
% -----------------------------------------------------------------------------------
% airfoil1.mat ... 327 578 320 563 516 819 577 897
% 3elt.mat ....... 372 671 395 651 733 1168 880 1342
% barth4.mat ..... 505 758 405 689 875 1306 891 1350
% mesh3e1.mat .... 72 111 75 117 75 122 67 102
% crack.mat ...... 804 1303 784 1290 1343 1860 1061 1618
function n = runtest(A, xy, algorithm, depth, t, show_graphs)
g = 0;
if show_graphs == 1
g = 1;
title(strcat(t, ' bisection for crack with n=16'));
hold on;
end
n = recurse(A, xy, algorithm, 0.5, depth, g);
if show_graphs == 1
hold off;
%matlab2tikz(sprintf('../../ex4_%s.tex', t));
figure;
end
end
function n = recurse(A, xy, algorithm, color, depth, show_graphs)
[partA, partB] = algorithm(A, xy);
[n, ~] = cutsize(A, partA);
A1 = A(partA, partA);
xy1 = xy(partA, :);
A2 = A(partB, partB);
xy2 = xy(partB, :);
depth = depth - 1;
if depth > 0
n = n + recurse(A1, xy1, algorithm, color * 1.5, depth, show_graphs);
n = n + recurse(A2, xy2, algorithm, color * 0.5, depth, show_graphs);
elseif show_graphs == 1
gplot(A1, xy1);
gplot(A2, xy2);
end
if show_graphs == 1
A12 = sparse(size(A));
A12(partA, partB) = A(partA, partB);
A12(partB, partA) = A(partB, partA);
gplot(A12, xy);
end
end

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

182625
mp3/ex4_Coordinate.tex Normal file

File diff suppressed because it is too large Load diff

182610
mp3/ex4_Inertial.tex Normal file

File diff suppressed because it is too large Load diff

182607
mp3/ex4_METIS.tex Normal file

File diff suppressed because it is too large Load diff

182635
mp3/ex4_Spectral.tex Normal file

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -11,6 +11,8 @@
\usepackage{grffile}
\usepackage{amsmath}
\usepackage{subcaption}
\usepgfplotslibrary{external}
\tikzexternalize
\hyphenation{PageRank}
\hyphenation{PageRanks}
@ -59,7 +61,39 @@ In figure \ref{fig:run1} there are graph outputs respectively from \textit{Grid9
\section{Recursively bisecting meshes \punkte{20}}
Summarize your results in table \ref{table:Rec_bisection}.
I summarize my results in table \ref{table:Rec_bisection}. Additionaly, the graph plots
for a recursive partition in 16 parts of \textit{Crack} are avaliable in figure \ref{fig:bicrack}.
\begin{figure}[h]
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex4_Spectral}}
\caption{Spectral bisection}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex4_Coordinate}}
\caption{Coordinate bisection}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex4_METIS}}
\caption{METIS bisection}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex4_Inertial}}
\caption{Inertial bisection}
\end{subfigure}
\caption{Graph outputs for \textit{Crack} graph with $n=16$}
\label{fig:bicrack}
\end{figure}
\section{Compare recursive bisection to direct $k$-way partitioning\punkte{10}}
@ -84,15 +118,15 @@ Summarize your results in table \ref{table:Compare_Metis}.
\begin{table}[h]
\caption{Edge-cut results for recursive bi-partitioning.}
\caption{Edge-cut results for recursive bi-partitioning (data for $n=8$ on the left and $n=16$ on the right).}
\centering
\begin{tabular}{|l|r|r|r|r|r|} \hline\hline
Case & Spectral & Metis 5.0.2 & Coordinate & Inertial \\ \hline
mesh3e1 & & & & \\
airfoil1 & & & & \\
3elt & & & & \\
barth4 & & & & \\
crack & & & & \\ \hline \hline
\begin{tabular}{|l|r|r|r|r|p{4cm}|} \hline\hline
Case & Spectral & Metis 5.0.2 & Coordinate & Inertial \\ \hline
airfoil1 & 327\hfill578 & 320\hfill563 & 516\hfill819 & 577\hfill897\\
3elt & 372\hfill671 & 395\hfill651 & 733\hfill1168 & 880\hfill1342\\
barth4 & 505\hfill758 & 405\hfill689 & 875\hfill1306 & 891\hfill1350\\
mesh3e1 & 72\hfill111 & 75\hfill117 & 75\hfill122 & 67\hfill102\\
crack & 804\hfill1303 & 784\hfill1290 & 1343\hfill1860 & 1061 \hfill 1618\\\hline\hline
\end{tabular}
\label{table:Rec_bisection}
\end{table}