mp3: other corrections

This commit is contained in:
Claudio Maggioni 2020-11-03 14:40:49 +01:00
parent 09a568eaa5
commit 13522202fc
12 changed files with 730309 additions and 75 deletions

View file

@ -79,29 +79,33 @@ for c = 1:nc
% 2. Recursive routines
% i. Spectral
sp8 = runtest(W, coords, @(a, b) bisection_spectral(a, b, 0), ...
3, '', 0);
3, 'Spectral_8', g);
sp16 = runtest(W, coords, @(a, b) bisection_spectral(a, b, 0), ...
4, 'Spectral', g);
% ii. Metis
m8 = runtest(W, coords, @(a, b) bisection_metis(a, b, 0), ...
3, '', 0);
3, 'METIS_8', g);
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);
3, 'Coordinate_8', g);
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);
3, 'Inertial_8', g);
i16 = runtest(W, coords, @(a, b) bisection_inertial(a, b, 0), ...
4, 'Inertial', g);
close;
for ignored = 1:8
% close;
end
% 3. Calculate number of cut edges
% 4. Visualize the partitioning result
@ -111,31 +115,31 @@ for c = 1:nc
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 .... 75 124 75 117 75 122 67 102
%crack.mat ...... 804 1303 784 1290 1343 1860 1061 1618
%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 578 903
%3elt.mat ....... 372 671 395 651 733 1168 880 1342
%barth4.mat ..... 505 758 405 689 875 1306 888 1348
%mesh3e1.mat .... 75 124 75 117 75 122 76 116
%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'));
%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));
%matlab2tikz('showInfo', false, sprintf('../../ex4_%s.tex', t));
figure;
end
end
function n = recurse(A, xy, algorithm, color, depth, show_graphs)
function n = recurse(A, xy, algorithm, color, depth, show_g)
warning('off','MATLAB:eigs:IllConditionedA')
[partA, partB] = algorithm(A, xy);
warning('on', 'MATLAB:eigs:IllConditionedA')
@ -147,14 +151,14 @@ function n = recurse(A, xy, algorithm, color, depth, show_graphs)
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
n = n + recurse(A1, xy1, algorithm, color * 1.5, depth, show_g);
n = n + recurse(A2, xy2, algorithm, color * 0.5, depth, show_g);
elseif show_g == 1
gplot(A1, xy1);
gplot(A2, xy2);
end
if show_graphs == 1
if show_g == 1
A12 = sparse(size(A));
A12(partA, partB) = A(partA, partB);
A12(partB, partA) = A(partB, partA);

View file

@ -20,16 +20,17 @@
% Steps
% 1. Calculate the center of mass.
m = sum(xy, 1) ./ size(xy, 1);
m = mean(xy);
xm = m(1);
ym = m(2);
% 2. Construct the matrix M.
% (Consult the pdf of the assignment for the creation of M)
h = [(xy(:, 1) - xm) (xy(:, 2) - ym)];
X1 = sum(h(:, 1) .^ 2);
X2 = sum(h(:, 1) .* h(:, 2));
X3 = sum(h(:, 2) .^ 2);
sx = (xy(:, 1) - xm);
sy = (xy(:, 2) - ym);
X1 = sum(sx .^ 2);
X2 = dot(sx, sy);
X3 = sum(sy .^ 2);
M = [X1 X2; X2 X3];
@ -39,13 +40,12 @@ a = u(1);
b = u(2);
% 4. Find the line L on which the center of mass lies.
S = -b * (xy(:, 1) - xm) + a * (xy(:, 2) - ym);
Sm = median(S);
v = [-b; a];
v = v / norm(v, 2);
% 5. Partition the points around the line L.
% (you may use the function partition.m)
part1 = find(S < Sm);
part2 = find(S >= Sm);
[part1, part2] = partition(xy, v);
if picture == 1
gplotpart(A,xy,part1);

View file

@ -1,9 +1,5 @@
% This file was created by matlab2tikz.
%
%The latest updates can be retrieved from
% http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz-matlab2tikz
%where you can also make suggestions and rate matlab2tikz.
%
\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}%
\definecolor{mycolor2}{rgb}{0.85000,0.32500,0.09800}%
\definecolor{mycolor3}{rgb}{0.92900,0.69400,0.12500}%
@ -25,8 +21,6 @@ xmax=1,
ymin=0,
ymax=1,
axis background/.style={fill=white},
title style={font=\bfseries},
title={Coordinate bisection for crack with n=16},
axis x line*=bottom,
axis y line*=left
]

182555
mp3/ex4_Coordinate_8.tex Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,5 @@
% This file was created by matlab2tikz.
%
%The latest updates can be retrieved from
% http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz-matlab2tikz
%where you can also make suggestions and rate matlab2tikz.
%
\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}%
\definecolor{mycolor2}{rgb}{0.85000,0.32500,0.09800}%
\definecolor{mycolor3}{rgb}{0.92900,0.69400,0.12500}%
@ -25,8 +21,6 @@ xmax=1,
ymin=0,
ymax=1,
axis background/.style={fill=white},
title style={font=\bfseries},
title={Inertial bisection for crack with n=16},
axis x line*=bottom,
axis y line*=left
]

182552
mp3/ex4_Inertial_8.tex Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,5 @@
% This file was created by matlab2tikz.
%
%The latest updates can be retrieved from
% http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz-matlab2tikz
%where you can also make suggestions and rate matlab2tikz.
%
\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}%
\definecolor{mycolor2}{rgb}{0.85000,0.32500,0.09800}%
\definecolor{mycolor3}{rgb}{0.92900,0.69400,0.12500}%
@ -25,8 +21,6 @@ xmax=1,
ymin=0,
ymax=1,
axis background/.style={fill=white},
title style={font=\bfseries},
title={METIS bisection for crack with n=16},
axis x line*=bottom,
axis y line*=left
]

182552
mp3/ex4_METIS_8.tex Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,5 @@
% This file was created by matlab2tikz.
%
%The latest updates can be retrieved from
% http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz-matlab2tikz
%where you can also make suggestions and rate matlab2tikz.
%
\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}%
\definecolor{mycolor2}{rgb}{0.85000,0.32500,0.09800}%
\definecolor{mycolor3}{rgb}{0.92900,0.69400,0.12500}%
@ -25,8 +21,6 @@ xmax=1,
ymin=0,
ymax=1,
axis background/.style={fill=white},
title style={font=\bfseries},
title={Spectral bisection for crack with n=16},
axis x line*=bottom,
axis y line*=left
]

182556
mp3/ex4_Spectral_8.tex Normal file

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -58,7 +58,7 @@ In figure \ref{fig:run1} there are graph outputs respectively from \textit{Grid9
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{figure}
\begin{subfigure}{0.5\textwidth}
\centering
% \input{ex3_grid9}
@ -83,7 +83,7 @@ Colors to represent the partitions and the eigenvector components are the same a
\section{Recursively bisecting meshes \punkte{20}}
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}.
for a recursive partition in 8 and 16 parts of \textit{Crack} are avaliable in figure \ref{fig:bicrack}.
The figure shows the partitions and edge cuts with colors randomly assigned by MATLAB.
@ -93,32 +93,56 @@ Please note that while computing spectral partitioning for \textit{barth4} MATLA
in the computation of the adjacency matrix eigenvalues stating that the matrix is ill conditioned.
This warning was suppressed so as not to interfere with the table printout.
\begin{figure}[h]
\begin{figure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex4_Spectral_8}}
\caption{Spectral bisection for $n=8$}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex4_Coordinate_8}}
\caption{Coordinate bisection for $n=8$}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex4_METIS_8}}
\caption{METIS bisection for $n=8$}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex4_Inertial_8}}
\caption{Inertial bisection for $n=8$}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex4_Spectral}}
\caption{Spectral bisection}
\caption{Spectral bisection for $n=16$}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex4_Coordinate}}
\caption{Coordinate bisection}
\caption{Coordinate bisection for $n=16$}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex4_METIS}}
\caption{METIS bisection}
\caption{METIS bisection for $n=16$}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
\input{ex4_Inertial}}
\caption{Inertial bisection}
\caption{Inertial bisection for $n=16$}
\end{subfigure}
\caption{Graph outputs for \textit{Crack} graph with $n=16$}
\caption{Graph outputs for \textit{Crack} graph with $n=8$ and $n=16$}
\label{fig:bicrack}
\end{figure}
@ -130,7 +154,7 @@ The figure shows the resulting partitions with colors randomly assigned by MATLA
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{figure}
\begin{subfigure}{0.5\textwidth}
\centering
\resizebox{0.8\linewidth}{!}{
@ -162,7 +186,7 @@ I had the suspicion that k-way partitioning would perform better in all cases, s
\begin{table}[h]
\begin{table}
\caption{Bisection results}
\centering
\begin{tabular}{|l|r|r|r|r|} \hline\hline
@ -180,28 +204,43 @@ I had the suspicion that k-way partitioning would perform better in all cases, s
\end{table}
\begin{table}[h]
\caption{Edge-cut results for recursive bi-partitioning (data for $n=8$ on the left and $n=16$ on the right).}
\begin{table}
\caption{Edge-cut results for recursive bi-partitioning (data for $n=8$ on the top and $n=16$ on the bottom).}
\centering
\begin{tabular}{|l|r|r|r|r|p{4cm}|} \hline\hline
Case & Spectral & Metis 5.0.2 & Coordinate & Inertial \\ \hline
airfoil1 & 327 \hfill 578 & 320 \hfill 563 & 516 \hfill 819 & 577 \hfill 897\\
3elt & 372 \hfill 671 & 395 \hfill 651 & 733 \hfill 1168 & 880 \hfill 1342\\
barth4 & 505 \hfill 758 & 405 \hfill 689 & 875 \hfill 1306 & 891 \hfill 1350\\
mesh3e1 & 75 \hfill 124 & 75 \hfill 117 & 75 \hfill 122 & 67 \hfill 102\\
crack & 804 \hfill 1303 & 784 \hfill 1290 & 1343 \hfill 1860 & 1061 \hfill 1618\\\hline\hline
Case $n=8$ & Spectral & Metis 5.0.2 & Coordinate & Inertial \\ \hline
airfoil1 & 327 & 320 & 516 & 578 \\
3elt & 372 & 395 & 733 & 880 \\
barth4 & 505 & 405 & 875 & 888 \\
mesh3e1 & 75 & 75 & 75 & 76 \\
crack & 804 & 784 & 1343 & 1061 \\\hline\hline
\end{tabular}\\
\vspace{10pt}
\begin{tabular}{|l|r|r|r|r|p{4cm}|} \hline\hline
Case $n=16$ & Spectral & Metis 5.0.2 & Coordinate & Inertial \\ \hline
airfoil1 & 578 & 563 & 819 & 903\\
3elt & 671 & 651 & 1168 & 1342\\
barth4 & 758 & 689 & 1306 & 1348\\
mesh3e1 & 124 & 117 & 122 & 116\\
crack & 1303 & 1290 & 1860 & 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. Results for recursive partitioning shown on the left, k-way on the right.}
\begin{table}
\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 top, k-way on the bottom table.}
\centering
\begin{tabular}{|l|r|r|r|r|} \hline\hline
Partitions & crack & airfoil1 \\ \hline
16 & 10055 \hfill 10077 & 580 \hfill 564 \\
32 & 10824 \hfill 10943 & 967 \hfill 947 \\ \hline \hline
Recursive part. & crack & airfoil1 \\ \hline
16 & 10055 & 580 \\
32 & 10824 & 967 \\ \hline \hline
\end{tabular} \\
\vspace{10pt}
\begin{tabular}{|l|r|r|r|r|} \hline\hline
K-way part. & crack & airfoil1 \\ \hline
16 & 10077 & 564 \\
32 & 10943 & 947 \\ \hline \hline
\end{tabular}
\label{table:Compare_Metis}
\end{table}