mp3: preparing for submission

This commit is contained in:
Claudio Maggioni 2020-10-25 15:05:25 +01:00
parent 61f42a782a
commit 4d16502d92
16 changed files with 512942 additions and 22 deletions

2
.gitignore vendored
View File

@ -145,4 +145,6 @@ sympy-plots-for-*.tex/
!*.pdf
*.zip
**/*-figure*.pdf
*~

View File

@ -1,20 +1,73 @@
function [cut_recursive,cut_kway] = Bench_metis(picture)
% Compare recursive bisection and direct k-way partitioning,
function Bench_metis
% Compare recursive bisection and direct k-way partitioning,
% as implemented in the Metis 5.0.2 library.
% Add necessary paths
addpaths_GP;
% Graphs in question
% load 'airfoil1.mat' ;
% load 'crack.mat';
load('airfoil1.mat');
G1 = Problem.A;
w1 = Problem.aux.coord;
map_r1_16 = metismex('PartGraphRecursive',G1,16);
map_k1_16 = metismex('PartGraphKway',G1,16);
map_r1_32 = metismex('PartGraphRecursive',G1,32);
map_k1_32 = metismex('PartGraphKway',G1,32);
% Steps
% 1. Initialize the cases
% 2. Call metismex to
% a) Recursively partition the graphs in 16 and 32 subsets.
% b) Perform direct k-way partitioning of the graphs in 16 and 32 subsets.
% 3. Visualize the results for 32 partitions
load('crack.mat');
G2 = Problem.A;
w2 = Problem.aux.coord;
map_r2_16 = metismex('PartGraphRecursive',G2,16);
map_k2_16 = metismex('PartGraphKway',G2,16);
map_r2_32 = metismex('PartGraphRecursive',G2,32);
map_k2_32 = metismex('PartGraphKway',G2,32);
figure;
title('Recursive METIS partition of Airfoil graph for n=32');
drawgraph(G1, w1, map_r1_32, 'air_n');
figure;
title('K-way METIS partition of Airfoil graph for n=32');
drawgraph(G1, w1, map_k1_32, 'air_k');
figure;
title('Recursive METIS partition of Crack graph for n=32');
drawgraph(G2, w2, map_r2_32, 'crack_n');
figure;
title('K-way METIS partition of Crack graph for n=32');
drawgraph(G2, w2, map_k2_32, 'crack_k');
fprintf('Algorithm\tAirfoil16\tAirfoil32\t Crack16\t Crack32\n');
fprintf('Recursive\t%9d\t%9d\t%9d\t%9d\n', ...
ec(G1, map_r1_16), ec(G1, map_r1_32), ...
ec(G1, map_r2_16), ec(G1, map_r2_32));
fprintf('K-way \t%9d\t%9d\t%9d\t%9d\n', ...
ec(G1, map_k1_16), ec(G1, map_k1_32), ...
ec(G1, map_k2_16), ec(G1, map_k2_32));
end
function n = ec(A, map)
EG = A;
hold on;
for i = min(map):max(map)
part = find(map == i)';
EG(part, part) = 0;
end
n = nnz(triu(EG));
end
function drawgraph(A, xy, map, n)
EG = A;
hold on;
for i = min(map):max(map)
part = find(map == i)';
EG(part, part) = 0;
A_p = A(part, part);
coord = xy(part, :);
gplot(A_p, coord);
end
gplot(EG, xy, '-k');
hold off;
%matlab2tikz('showInfo', false, sprintf('../../ex5_%s.tex', n));
end

View File

@ -3,12 +3,12 @@ addpaths_GP;
[A, xy] = grid9(50);
bisection_spectral(A, xy, 2);
%matlab2tikz('../../ex3_grid9.tex');
%matlab2tikz('showInfo', false, '../../ex3_grid9.tex');
figure;
bisection_spectral(Smallmesh, Smallmesh_coords, 2);
%matlab2tikz('../../ex3_small.tex');
%matlab2tikz('showInfo', false, '../../ex3_small.tex');
figure;
bisection_spectral(Eppstein, Eppstein_coords, 2);
%matlab2tikz('../../ex3_eppstein.tex');
%matlab2tikz( '../../ex3_eppstein.tex');

73867
mp3/ex5_air_k.tex Normal file

File diff suppressed because it is too large Load Diff

73867
mp3/ex5_air_n.tex Normal file

File diff suppressed because it is too large Load Diff

182545
mp3/ex5_crack_k.tex Normal file

File diff suppressed because it is too large Load Diff

182545
mp3/ex5_crack_n.tex Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -28,6 +28,8 @@
\assignmentpolicy
Please note all scripts used can be found under the folder \texttt{Project\_3\_Maggioni\_Claudio/src}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Install METIS 5.0.2, and the corresponding Matlab mex interface}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -38,20 +40,25 @@ can be generated at will with the script \texttt{ex2\_bisection\_table.m}.
\section{Visualize the Fiedler eigenvector\punkte{10}}
In figure \ref{fig:run1} there are graph outputs respectively from \textit{Grid9}, \textit{Small}, and \textit{Eppstein}.
In figure \ref{fig:run1} there are graph outputs respectively from \textit{Grid9}, \textit{Small}, and \textit{Eppstein}. Please note that these results can be reproduced using script \texttt{ex3\_plots.m}.
Colors to represent the partitions and the eigenvector components are the same as the ones used in the the assignment's Figure 3. It is quite easy to evince from these plots that spectral partitioning indeed partitions the graph verticies based on the sign of their respective Fiedler eigenvector component: the only intersection between the Graph plane and the surface the eigenvector entries lay corresponds to the edgecut produced by spectral partitioning. This is due to the fact that in the figure the graph is positioned at $z = 0$.
\begin{figure}[h]
\begin{subfigure}{0.5\textwidth}
\centering
% \input{ex3_grid9}
\includegraphics[trim=50 200 50 200,clip,width=\textwidth]{ex3_grid9.pdf}
\caption{Plot for \textit{Grid9}}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
% \input{ex3_small}
\includegraphics[trim=50 200 50 200,clip,width=\textwidth]{ex3_small.pdf}
\caption{Plot for \textit{Small}}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
% \input{ex3_eppstein)
\includegraphics[trim=50 200 50 200,clip,width=\textwidth]{ex3_eppstein.pdf}
\caption{Plot for \textit{Eppstein}}
\end{subfigure}
@ -61,9 +68,11 @@ In figure \ref{fig:run1} there are graph outputs respectively from \textit{Grid9
\section{Recursively bisecting meshes \punkte{20}}
I summarize my results in table \ref{table:Rec_bisection}. Additionaly, the graph plots
I summarize my results in table \ref{table:Rec_bisection}. Additionally, the graph plots
for a recursive partition in 16 parts of \textit{Crack} are avaliable in figure \ref{fig:bicrack}.
Again the data shown here can reproduced using a MATLAB script (\texttt{Bench\_rec\_bisection.m}). Please note that the given recursion helper function \texttt{rec\_bisection} was not used. Instead, the function \texttt{runtest} was implemented to allow for partitioning graphs to be generated at will.
\begin{figure}[h]
\begin{subfigure}{0.5\textwidth}
\centering
@ -93,11 +102,43 @@ for a recursive partition in 16 parts of \textit{Crack} are avaliable in figure
\label{fig:bicrack}
\end{figure}
\section{Compare recursive bisection to direct $k$-way partitioning\punkte{10}}
Summarize your results in table \ref{table:Compare_Metis}.
I summarize my results in table \ref{table:Compare_Metis}. Additionally, plots for the $n = 32$ cases can be found in figure \ref{fig:bikmetis}. Please note that both the table and the plots can be reproduced using script \texttt{Bench\_metis.m}.
I had the suspicion that k-way partitioning would perform better in all cases, since in this the partitioning algorithm has a chance to see the entire problem and to perform decision that could affect all partitions. Instead, for the \texttt{Crack} mesh, recursive partitioning surprisedly performed better than k-way for both $n = 16$ and $n = 32$, producing slighly smaller edge cuts.
\begin{figure}[h]
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex5_air_n}}
\caption{\textit{Airfoil} with recursive partitioning}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex5_air_k}}
\caption{\textit{Airfoil} with k-way partitioning}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex5_crack_n}}
\caption{\textit{Crack} with recursive partitioning}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex5_crack_k}}
\caption{\textit{Crack} with k-way partitioning}
\end{subfigure}
\caption{Graph outputs for \textit{METIS} recursive and k-way partitioning with $n=32$. Edge cuts are displayed in black}
\label{fig:bikmetis}
\end{figure}
\begin{table}[h]
\caption{Bisection results}
@ -126,19 +167,19 @@ Summarize your results in table \ref{table:Compare_Metis}.
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
crack & 804 \hfill 1303 & 784\hfill1290 & 1343\hfill1860 & 1061 \hfill 1618\\\hline\hline
\end{tabular}
\label{table:Rec_bisection}
\end{table}
\begin{table}[h]
\caption{Comparing the number of cut edges for recursive bisection and direct multiway partitioning in Metis 5.0.2.}
\caption{Comparing the number of cut edges for recursive bisection and direct multiway partitioning in Metis 5.0.2. Results for recursive partitioning shown on the left, k-way on the right.}
\centering
\begin{tabular}{|l|r|r|r|r|} \hline\hline
Partitions & crack & airfoil1 \\ \hline
16 & & \\
32 & & \\ \hline \hline
16 & 10055 \hfill 10077 & 580 \hfill 564 \\
32 & 10824 \hfill 10943 & 967 \hfill 947 \\ \hline \hline
\end{tabular}
\label{table:Compare_Metis}
\end{table}