\subsection{Kernel density estimation}


%% \section{Co-occurrence Modeling}
%% \label{sec:code}

\appendix
%%\appendixsection{Algorithm}
%%\label{sec:algorithm}
%% [!! remove this part]
%% In this section, we briefly describe the components of our algorithm.
%% Section~\ref{sec:subcomp} presents the motive and the method for
%% computation of substitute vectors, our paradigmatic representations
%% for the word contexts.  We combine the substitute vectors with the
%% identity and features of the target word for part of speech induction
%% using the a co-occurrence modeling framework.

\appendixsection{Computation of Substitute Distributions}
\label{app:subcomp}

In this study, we predict the syntactic category of a word in a given
context based on its substitute distribution.  The sample space of the
substitute distribution is the vocabulary of the language model
including the unknown word tag \unk.  Note that the substitute
distribution is a function of the context only and is indifferent to
the target word.

%% The dimensions of the
%% substitute distribution represent words in the vocabulary of the
%% language model, and the entries in the substitute distribution
%% represent the probability of those words being used in the given
%% context.

% how are the substitutes computed
It is best to use both the left and the right context when estimating
the probabilities for potential lexical substitutes.  For example, in
\emph{``He lived in San Francisco suburbs.''}, the token \emph{San}
would be difficult to guess from the left context but it is almost
certain looking at the right context.  We define $c_w$ as the $2n-1$
word window centered around the target word position: $w_{-n+1} \ldots
w_0 \ldots w_{n-1}$ ($n=4$ is the n-gram order we have used).  The
probability of a substitute word $w$ in a given context $c_w$ can be
estimated as:
\begin{eqnarray}
  \label{eq:lm1}P(w_0 = w | c_w) & \propto & P(w_{-n+1}\ldots w_0\ldots w_{n-1})\\
  \label{eq:lm2}& = & P(w_{-n+1})P(w_{-n+2}|w_{-n+1})\nonumber\\
  &&\ldots P(w_{n-1}|w_{-n+1}^{n-2})\\
  \label{eq:lm3}& \approx & P(w_0| w_{-n+1}^{-1})P(w_{1}|w_{-n+2}^0)\nonumber\\
  &&\ldots P(w_{n-1}|w_0^{n-2})
\end{eqnarray}
where $w_i^j$ represents the sequence of words $w_i w_{i+1} \ldots
w_{j}$.  In Equation \ref{eq:lm1}, $P(w|c_w)$ is proportional to
$P(w_{-n+1}\ldots w_0 \ldots w_{n-1})$ because the words of the
context are fixed.  Terms without $w_0$ are identical for each
substitute in Equation \ref{eq:lm2} therefore they have been dropped
in Equation \ref{eq:lm3}.  Finally, because of the Markov property of
n-gram language model, only the closest $n-1$ words are used in the
experiments.

Near the sentence boundaries the appropriate terms were truncated in
Equation \ref{eq:lm3}.  Specifically, at the beginning of the sentence
shorter n-gram contexts were used and at the end of the sentence terms
beyond the end-of-sentence token were dropped.

To obtain a discrete representation of the context, the
random-substitutes algorithm pairs each word token with a substitute
sampled from the pre-computed substitute distribution generated from
the word token's context and then word ($W$) -- random-substitute
($S$) pairs are fed to the S-CODE algotihm as input.

\appendixsection{The CODE and S-CODE Models}
\label{app:codethr}

In this section we review the unsupervised method that we use to model
co-occurrence statistics: the Co-occurrence Data Embedding
(CODE)\ \cite{globerson2007euclidean} method and its spherical
extension (S-CODE) introduced by \cite{maron2010sphere}.

Let $W$ and $C$ be two categorical variables with finite cardinalities
$|W|$ and $|C|$.  We observe a set of pairs $\{w_i, c_i\}_{i=1}^n$
drawn IID from the joint distribution of $W$ and $C$.  The basic idea
behind CODE and related methods is to represent (embed) each value of
$W$ and each value of $C$ as points in a common Euclidean space
$\mathbf{R}^d$ such that values that frequently co-occur lie close to
each other.  There are several ways to formalize the relationship
between the distances and co-occurrence statistics, in this paper we
use the following:
\begin{equation} \label{eq:probability}
p(w,c) = \frac{1}{Z} \bar{p}(w) \bar{p}(c) e^{-d^2_{w,c}}
\end{equation}
\noindent where $d^2_{w,c}$ is the squared distance between the
embeddings of $w$ and $c$, $\bar{p}(w)$ and $\bar{p}(c)$ are empirical
probabilities, and $Z=\sum_{w,c} \bar{p}(w) \bar{p}(c) e^{-d^2_{w,c}}$
is a normalization term.  If we use the notation $\phi_w$ for the
point corresponding to $w$ and $\psi_c$ for the point corresponding to
$c$ then $d^2_{w,c} = \|\phi_w-\psi_c\|^2$.  The log-likelihood of a
given embedding $\ell(\phi, \psi)$ can be expressed as:
\begin{eqnarray}
&&\ell(\phi, \psi) = \sum_{w,c} \bar{p}(w,c) \log p(w,c) \label{eq:likelihood} \\
&&= \sum_{w,c} \bar{p}(w,c) (-\log Z + \log \bar{p}(w)\bar{p}(c) - d^2_{w,c}) \nonumber \\
&&= -\log Z + \mathit{const} - \sum_{w,c} \bar{p}(w,c) d^2_{w,c} \nonumber
\end{eqnarray}
The likelihood is not convex in $\phi$ and $\psi$.  We use gradient
ascent to find an approximate solution for a set of $\phi_w$, $\psi_c$
that maximize the likelihood.  The gradient of the $d^2_{w,c}$ term
pulls neighbors closer in proportion to the empirical joint
probability:
\begin{equation}
\frac{\partial}{\partial\phi_w} \sum_{w,c} -\bar{p}(w,c) d^2_{w,c} =
\sum_y 2 \bar{p}(w,c) (\psi_c - \phi_w) \label{eq:attract}
\end{equation}
The gradient of the $Z$ term pushes neighbors apart in proportion to the
estimated joint probability:
\begin{equation}
\frac{\partial}{\partial\phi_x} (-\log Z) = \sum_y 2 p(w,c) (\phi_w -
\psi_c) \label{eq:repulse}
\end{equation}
Thus the net effect is to pull pairs together if their estimated
probability is less than the empirical probability and to push them
apart otherwise.  The gradients with respect to $\psi_c$ are similar.
S-CODE \cite{maron2010sphere} additionally restricts all $\phi_w$ and
$\psi_c$ to lie on the unit sphere.  With this restriction, $Z$ stays
around a fixed value during gradient ascent.  This allows S-CODE to
substitute an approximate constant $\tilde{Z}$ in gradient
calculations for the real $Z$ for computational efficiency.  In our
experiments, we used S-CODE with its sampling based stochastic
gradient ascent algorithm and smoothly decreasing learning rate.

\appendixsection{S-CODE with More than Two Variables}

In order to accommodate multiple feature types the S-CODE model in the
previous section needs to be extended to handle more than two
variables.  Globerson et. al \shortcite{globerson2007euclidean}
suggest the following likelihood function:

\begin{eqnarray}
&\ell(\phi,& \psi^{(1)}, \ldots, \psi^{(K)}) = \label{eq:multicode}
  \bar{p}(w,c) \log p(w,c) + \sum_i^K \sum_{w,f^{(i)}} \bar{p}(w,f^{(i)}) \log p(w,f^{(i)})
\end{eqnarray}

\noindent where $\bar{p}(w,c)$ is the empirical joint distribution of
context $C$ with $W$, $F^{(1)}, \ldots, F^{(K)}$ are extra $K$
different variables whose empirical joint distributions with $W$,
$\bar{p}(w,f^{(1)})\ldots\bar{p}(w,f^{(K)})$, are known.
Eq.~\ref{eq:multicode} then represents a set of CODE models
$p(w,f^{(k)})$ where each $F^{(k)}$ has an embedding $\psi_f^{(k)}$
but all models share the same $\phi_w$ embedding.

We adopt this likelihood function, let $W$ represent a word, $C$
represent a context (i.e., random substitute), and $F^{(1)}, \ldots,
F^{(K)}$ stand for morphological and orthographic features of the word
thus each co-occurrence is a (K+1)-tuple, $(W, C, F^{(1)}, \hdots
F^{(K)})$.  With this setup, the training procedure needs to change
little: instead of sampling a word ($w$) -- context ($c$), the word
($w$) -- context ($c$) -- features ($f_1,\hdots,f_K$) tuple is sampled
and input to the gradient ascent algorithm.  The gradient search
algorithm updates the embeddings according to $p(w,c)$ and
$p(w,f^{(i)})$ where $i=1\hdots k$ and no updates are performed
between $c$ and $f^{(i)}$s since they do not have any co-occurrence
statistics and $w$ is the only shared variable.

Tuples might have null values due to unobserved features.  For example
in the case of POS induction, the word ``\textbf{car}'' has no
morphological or orthographic features therefore all the elements of
the tuple have null value except the word type ($w$) and the context
($c$).  We do not perform any pull or push updates on embeddings
during the gradient search if the corresponding $f^{(k)}$ is
null\footnote{In the POS induction problem $w$ and $c$ represents the
  word type and context therefore they are always observed.}.

\appendixsection{Language Statistics}

This section explains the language model training and feature
extraction of each language that we apply our model in
Section~\ref{sec:multilang}.

\paragraph{Statictical Language Modeling}For all languages except
Serbian, English and Turkish, we train the language models by using
the corresponding Wikipedia dump files\footnote{Latest Wikipedia dump
  files are freely available at \url{http://dumps.wikimedia.org/} and
  the text in the dump files can be extracted using WP2TXT
  (\url{http://wp2txt.rubyforge.org/})}.  Serbian shares a common
basis with Croatian and Bosnian therefore we trained 3 different
language models using Wikipedia dump files of Serbian together with
these two languages and measured the perplexities on the MULTEXT-East
Serbian corpus.  We chose the Croatian language model since it
achieved the lowest perplexity score and unknown word ratio on the
MULTEXT-East Serbian corpus.  To train the statistical language model
of English, we use Wall Street Journal data (1987-1994) extracted from
CSR-III Text \cite{csr3text} (excluding sections of the PTB) and for
the Turkish language modeling we use the web corpus collected from
Turkish news and blog sites \cite{sak2008turkish}.

In order to reduce the unknown word ratio of resource poor languages
and to standardize the process we set the vocabulary threshold to 2
for all languages except English.  English has a relatively low
unknown word ratio therefore we set the threshold to 20 instead of 2.
Table~\ref{tab:lmstatistics} summarizes the language model related
statistics and scores that vary across the languages in terms of
quality and quantity.

\paragraph{Feature extraction}Morphological features of each language
are extracted using the training sections of the corresponding
MULTEXT-East and CoNLL-X corpora.  We don't use the language model
corpora to extract morphological features.  Number of morphological
feature of each language is presented in Table~\ref{tab:lmstatistics}.
We use the same set of orthographic features described in
Section~\ref{sec:feat} except we add an ``Only-Punctuation'' feature
to the languages of MULTEXT-East corpora.  The ``Only-Punctuation''
feature is generated when a token only consists of punctuation
characters.

\input{datatable.tex}
%% S-CODE handles two variables, whereas underlying syntactic categories
%% can be captured by more than two different variables such as
%% contextual, morphologic and ortographic features.  S-CODE can be
%% extented to handle more than two variables in a way similar to the
%% multi variable extension of CODE \cite{globerson2007euclidean} with
%% the unit sphere restriction.  The log-likelihood at
%% Equation~\ref{eq:likelihood} can be redefined for $n+1$ different
%% categorical variables $X$, $Y_i$, $\hdots$ and $Y_n$ with finite
%% cardinalities $|X|$, $|Y_1|$, $\hdots$ and $|Y_n|$, respectively, as:
%% \begin{eqnarray}
%% &&\ell(\phi, \psi_1,\hdots,\psi_n) = \sum_{i=1}^n\sum_{x,y_i} \bar{p}(x,y_i) \log p(x,y_i) \label{eq:multiscode} \\
%% &&= \sum_{i=1}^n\sum_{x,y_i} \bar{p}(x,y_i) (-\log Z_i + \log \bar{p}(x)\bar{p}(y_i) - d^2_{x,y_i}) \nonumber \\
%% &&=-\sum_{i=1}^n(\log Z_i + \mathit{const}_i - \sum_{x,y_i} \bar{p}(x,y_i) d^2_{x,y_i}) \nonumber
%% \end{eqnarray}
%% where $\psi_i$ is the embedding of $y_i \in Y_i$ and $Z_i$ is the
%% normalization term of $p(x,y_i)$.  Thus the model is able to jointly
%% learn the embeddings when the pairwise co-occurence statistics,
%% $\bar{p}(x,y_i)$, are available for all $i$.

%% One problem with these setting is, not every $(x,y_i)$ pair is
%% observed in the data.  For example, the stem word ``\textbf{car}''
%% doesn't have any morphological feature, thus its morphological feature
%% is represented by a null value, ``X''.  However setting the unobserved
%% features to ``X'' leads to pulling the words with unobserved features
%% together even they are from different clusters or pushing the ones
%% with observed features apart even they are from same clusters.  To
%% solve this, during the gradient search we don't perform any pull or
%% push updates on embeddings if the value of $y_i$ is set to null.


\section{Uniformisation and its Consequences}
\subsection{The Uniformisation Theorem}
\begin{theorem}
    Every simply connected Riemann surfaces is conformally equivalent to either $\mathbb C_\infty$, $\mathbb C$ or $\mathbb D=D(0,1)$.
\end{theorem}
\begin{proof}
    Well beyond the scope of this course (duh!).
\end{proof}
Note that despite the existence of conformal equivalence, it might be very difficult to actually find one.
\begin{remark}
    The three items on this list are all conformally distinct.
    $\mathbb C_\infty$ is obviously distinct from the two others since it is compact.
    To see $\mathbb D$ and $\mathbb C$ are conformally distinct, just observe that there is no nonconstant analytic map $\mathbb C\to\mathbb D$ by Liouville's Theorem yet there is the (nonconstant) analytic natural inclusion $\mathbb C\hookrightarrow\mathbb C_\infty$.
\end{remark}
The uniformisation is extremely useful as it links together the topological properties and possible analytic structures of certain topological surfaces.
\begin{corollary}
    Any conformal structure on $S^2$ is conformally equivalent to $\mathbb C_\infty$.
\end{corollary}
\begin{proof}
    $S^2$ is compact and simply connected.
\end{proof}
How about surfaces with positive genus?
They are not simply connected, but we know that it has a nice universal cover (Algebraic Topology again!).
\begin{theorem}
    Every Riemann surface $R$ has a regular covering map $\pi:\tilde{R}\to R$ such that $\tilde{R}$ is simply connected.
    Furthermore, there is a group $G$ acting freely and properly discontinuously by conformal equivalences on $\tilde{R}$ and the covering map descends to a conformal equivalence $G\backslash\tilde{R}\cong R$.
\end{theorem}
\begin{proof}
    Algebraic Topology.
\end{proof}
Therefore
\begin{corollary}
    Every Riemann surface $R$ is conformally equivalent to a quotient $R\cong G\backslash\tilde{R}$ where $\tilde{R}$ is conformally equivalent to one of $\mathbb C_\infty,\mathbb C,\mathbb D$, and $G$ acts freely and properly discontinuously
\end{corollary}
\begin{proof}
    Immediate.
\end{proof}
\begin{remark}
    In fact, $G$ is just $\pi_1(R)$ acting by deck transformations.
    Or in this context, $G$ is the collection of conformal equivalences $\phi:\tilde{R}\to\tilde{R}$ such that $\pi\circ\phi=\pi$.
\end{remark}


\documentclass{memoir}
\usepackage{notestemplate}
\usetikzlibrary{matrix,arrows.meta}

\logo{~/LibreMath/Auxiliary Resources/resources/png/logo.png}
\institute{Rice University}
%\faculty{Faculty of Whatever Sciences}
\department{Department of Mathematics}
\title{Introduction to UFDs, Modules, Finite Fields, and Galois Theory}
\subtitle{Based on MATH 357 at Rice University}
\author{\textit{Author}\\ Gabriel \textsc{Gress}}
%\supervisor{Linus \textsc{Torvalds}}
%\context{Well, I was bored...}
\date{\today}

%\makeindex

\begin{document}

\maketitle

\tableofcontents

\setcounter{chapter}{-1}

\chapter{Preamble}
\label{cha:preamble}
\input{Introduction}

\input{Lecture1 - RingReview}

\section{Rings with Divison Structures}
\label{sec:rings_with_divison_structures}

\input{Lecture2 - ED_UFD_PID}
\input{~/LibreMath/Ring Theory/Notes/source/Ideals}
\input{Lecture3 - GaussLemma_IntroPolyRings}
\input{Lecture4 - PolyIrreducibilityCrit}
\input{Lecture5 - IntroModules}
\input{Lecture6 - Submodules_ModHomo}
\input{Lecture7 - QuotModules_IsoThms_Prod}
\input{Lecture8 - GeneratingSets_FreeModules}

\chapter{Group Representation Theory}
\label{cha:group_representation_theory}

\section{Ties to Group Representation Theory}
\label{sec:ties_to_group_representation_theory}
\input{Lecture9 - GroupRepresentationThy}
\input{Lecture10 - Subrepresentations}
\input{Lecture11 - CompleteReducibility}
\input{Lecture12 - GHomo_SchursLemma}
\input{Lecture13 - CharacterThry}

\chapter{Field Extensions}
\label{cha:field_extensions}

\input{Lecture14 - IntroField}
\input{Lecture15 - IntroFieldExtn}
\input{Lecture16 - MinimalPoly}
\input{Lecture17 - TowerThm}
\input{Lecture18 - CompositeSplittingFields}
\input{Lecture19 - SplittingFieldUniqueness}
\input{Lecture20 - CyclotomicField}
\input{Lecture21 - Algebraic_Closure}
\input{Lecture22 - Separability_Polynomials}
\input{Lecture23 - Polynomial_Fields_Over_Fp}
\input{Lecture24 - Finite_Fields_Simple_Extensions}
\input{Lecture25 - AutoGroups_FixedFields}
\input{Lecture26 - GalGroups_GalExtensions}
\input{Lecture27 - GalExamples}
\input{Lecture28 - FundThmGalThry}
\input{Lecture29 - GalThry_FiniteFields}
\input{Lecture30 - GalThry_CompFields}

%\par\noindent\rule[5pt]{\textwidth}{0.4pt}
%Everything from here on out is optional.

\input{Lecture31 - SolvableGrps_GalCriterion}

%\printindex

\end{document}

Abstract Algebra - Introductory/Algebra II/Notes/source/AlgebraII.tex


\documentclass[a4paper,12pt]{article}
\usepackage{epsfig,latexsym,amsmath,amssymb,epic,eepic,psfrag,subfigure,float,euscript,array}
\usepackage[latin1]{inputenc}
\usepackage{standalone}
\usepackage{tikz,pgf,pgfplots}

\newenvironment{exercise}[1][Uppgift]{\begin{trivlist} \item[\hskip
    \labelsep {\stepcounter{exerctr}\bfseries #1
      \arabic{exerctr}}]}{\end{trivlist}\vspace{10mm}}

\newcounter{exerctr}
\newcounter{abcctr}[exerctr]

\newcommand{\abc}{\noindent\vspace{1mm}\\ {\bf
    \stepcounter{abcctr}(\alph{abcctr})\ }}
\newcommand{\bbm}{\begin{bmatrix}}
\newcommand{\ebm}{\end{bmatrix}}
\newcommand{\point}[1]{\hfill {\bf (#1p)}\\ \vspace{-5mm}}
\newcommand{\ctrb}{\EuScript{S}}
\newcommand{\Lap}{\mathcal{L}}
\newcommand{\obsv}{\EuScript{O}}
\newcommand{\realdel}[1]{\text{Re}\left\{#1\right\}}
\newcommand{\imagdel}{\text{Im}}
\newcommand{\bC}{\mathbb{C}}
\newcommand{\bR}{\mathbb{R}}
\newcommand{\bmpv}{\begin{minipage}[t]}
\newcommand{\bmps}{\begin{minipage}[t]{45mm}}
\newcommand{\bmpm}{\begin{minipage}[t]{90mm}}
\newcommand{\bmpl}{\begin{minipage}[t]{140mm}}
\newcommand{\emp}{\end{minipage}}
\newcommand*{\zethree}{\big(z - \mexp{-3h}\big)}
\newcommand*{\mexp}[1]{\ensuremath{\mathrm{e}^{#1}}}

\addtolength{\topmargin}{-1cm}
\textheight 23.5cm
%\oddsidemargin 0.61cm
%\evensidemargin 0.61cm

\def\OctaveG{tf([0.5 1], [1 0 -1])}

\title{Computerized control partial exam 1 -- Dummy exam from fall semester 2016}
\author{Kjartan Halvorsen}

\begin{document}

\maketitle

\begin{description}
\item[Time] Whenever suits you best. Each problem should not take more than 30 min to solve. \textbf{The actual exam will have only three problems.}
\item[Place] Somewhere quiet
\item[Permitted aids] For the exam: The single colored page with your own notes, table of Laplace transforms, calculator
\end{description}

All answers should be readable and well motivated (if nothing else is written). Solutions/motivations should be written on the provided spaces in this exam. Use the last page if more space is needed.

\begin{center}
{\Large Good luck!} \\
\end{center}

\begin{tabular}{|l|l|}
\hline
\multicolumn{2}{|l|}{\bmpl
Matricula and name
\vspace*{14mm}
\emp}\\
\hline

\end{tabular}

\clearpage

%-----------------------------------------------------------------
\subsection*{Problem 1}
Consider the continuous-time system with the following transfer function
\[ G(s) = \frac{s+1}{s(s+3)}. \]
The system is sampled with sampling interval $h$ using step-invariant (zero-order hold) sampling. \textbf{Show that the pulse-transfer function for the sampled system is}
\[ H(z) = \frac{(2z-2+3h)\zethree{} - 2(z-1)^2}{9(z-1)\zethree{}}. \]

\noindent
\fbox{
\bmpl
{\bf Derivation:}\\
\vspace*{130mm}
\emp}

\clearpage
\subsection*{Problem 2}

The sampled system in Problem 1 is controlled using proportional control with gain equal to 1.
\begin{center}
  \includestandalone[width=0.5\linewidth]{feedback}
\end{center}

Calculate the closed-loop pulse-transfer function

\noindent
\fbox{
\bmpl
{\bf Solutions:}\\
\vspace*{130mm}
\emp}

\clearpage
\subsection*{Problem 3}
What is the steady-state value of the control error $e(kh) = y_{ref}(kh) - y(kh)$? when $y_{ref}(kh)$ is a step?

\noindent
\fbox{
\bmpl
{\bf Solution:}\\
\vspace*{70mm}
\emp}

\subsection*{Problem 4 NOT RELEVANT FOR 2017ENE-MAY}
Instead of designing a discrete-time controller, a continuous-time controller was designed, given by
\[ 2\frac{d}{dt} u + u = 2\frac{d}{dt}e + 5e  \]
Discretize the controller using Tustin's approximation. Determine the poles and zeroes of the discrete-time controller.

\noindent
\fbox{
\bmpl
{\bf Solution:}\\
\vspace*{70mm}
\emp}

\clearpage

\subsection*{Problem 5}
Below is a plot of a discrete-time signal $x(k)=\realdel{a^k}$. Mark out $a$ in the complex plane below. Motivate your answer.
\begin{center}
\includegraphics[width=1.0\linewidth]{discrete-signal-decaying-sinusoid.png}
\end{center}

\fbox{
\includegraphics[width=0.4\linewidth]{imaginary-plane-empty}
\bmpm
{\bf Motivation:}\\
\vspace*{70mm}
\emp}

\clearpage

\noindent
{\bf If necessary,} you can continue your solutions on this page. Mark clearly which problem the solution corresponds to.

%\end{document}
%*****************************************************************
%*****************************************************************
\newpage
\setcounter{page}{1}

\section*{Solutions}
\subsection*{Problem 1}
   First calculate the step-response of the continous-time system
   \[G(s)\frac{1}{s} = \frac{s+1}{s^2(s+3)} = \frac{2}{9s} + \frac{1}{3s^2} - \frac{2}{9(s+3)}.\]
   The inverse Laplace-transform gives
   \[ y(t) = \frac{2}{9} + \frac{1}{3}t - \frac{2}{9}\mexp{-3t}. \]
   Sampling this function gives
   \[ y(kh) = \frac{2}{9} + \frac{1}{3}kh - \frac{2}{9}\big(\mexp{-3h}\big)^k, \]
   which has the Z-transform
   \[Y(z) = \frac{2z}{9(z-1)} + \frac{hz}{3(z-1)^2} - \frac{2z}{9\zethree{}}. \]
   Dividing the z-transform of the system response to that of the input (the step) gives
   \begin{align*}
   H(z) &= \frac{Y(z)}{U(z)} = \frac{z-1}{z}Y(z) = \frac{2}{9} + \frac{h}{3(z-1)} - \frac{2(z-1)}{9\zethree{}}\\
        &= \frac{2(z-1)\zethree{} + 3h\zethree{} - 2(z-1)^2}{9(z-1)\zethree{}}\\
	&= \frac{(2z-2+3h)\zethree - 2(z-1)^2}{9(z-1)\zethree{}}.
   \end{align*}

\subsection*{Problem 2}
Write the open-loop pulse-transfer function
\[ H(z) = \frac{B(z)}{A(z)} = \frac{(2z-2+3h)\zethree - 2(z-1)^2}{9(z-1)\zethree{}}. \]
The closed-loop pulse transfer function from the reference signal to the output becomes
\begin{equation*}
\begin{split}
  H_c(z) &= \frac{H(z)}{1+H(z)} = \frac{B(z)}{A(z) + B(z)}\\
  &= \frac{(2z-2+3h)\zethree - 2(z-1)^2}{ 9(z-1)\zethree{} + (2z-2+3h)\zethree - 2(z-1)^2}
\end{split}
\end{equation*}

\subsection*{Problem 3}
The steady-state control error becomes
\[ \lim_{k\to\infty} \big(y_{ref}(kh) - y(kh)\big) = \lim_{k\to\infty} y_{ref}(kh) - \lim_{k\to\infty}  y(kh). \]
The first limit is simply the steady-state value of the unit step input signal which is $1$. The second limit can be computed using the final value theorem
\begin{equation*}
\begin{split}
  \lim_{k\to\infty} y(kh) &= \lim_{z\to 1} (z-1)Y(z) = \lim_{z\to 1} (z-1)\frac{H(z)}{1+H(z)} Y_{ref}(z)\\
  &= \lim_{z\to 1} (z-1) \frac{B(z)}{A(z) + B(z)} \frac{z}{z-1} = \lim_{z\to 1} \frac{zB(z)}{A(z) + B(z)}\\
  &= \lim_{z\to 1} z \frac{(2z-2+3h)\zethree - 2(z-1)^2}{ 9(z-1)\zethree{} + (2z-2+3h)\zethree - 2(z-1)^2}
  = \frac{3h(1-\mexp{-3h})}{3h(1-\mexp{-3h})} = 1.
\end{split}
\end{equation*}
So the steady-state error is zero.

\subsection*{Problem 4}
The controller has transfer function

\[ F(s) = \frac{2s + 5}{2s + 1}. \]
Inserting for the Tustin's approximation gives
\begin{equation*}
\begin{split}
  F_d(z) &= F(s)|_{s=\frac{2}{h}\frac{z-1}{z+1}}\\
  &= \frac{2\frac{2}{h}\frac{z-1}{z+1} + 5}{2\frac{2}{h}\frac{z-1}{z+1} + 1}\\
  &= \frac{4(z-1) + 5h(z+1)}{4(z-1) + h(z+1)} = \frac{(4 + 5h)z - (4 -5h)}{(4+h)z - (4 - h)}
\end{split}
\end{equation*}
The pole is in \(z = \frac{4-h}{4+h}\) and the zero in \(z = \frac{4-5h}{4+5h}\).

\subsection*{Problem 5}
$\mathrm{Re}\{a^k\}$ is the operation of taking the real part of the expression $a^k$, where $a$ is a complex number. Seen in the complex plane, we project the point $a^k$ onto the real line in order to find the real part.

In polar form we have
\[ x(k) = \realdel{\Big(r\mexp{i\theta}\Big)^k}. \]

The discrete-time signal in the graph is a decaying discrete cosine. The period is clearly 10 samples, so we must have
\[ x(k) = \realdel{\Big(r\mexp{i\frac{\pi}{5}}\Big)^k}. \]
The signal is decaying at a rate such that the amplitude is approximately 0.1 after 20 samples.
\[ r^{20} \approx 0.1\]
Hence \[ r \approx 0.1^{1/20} = 0.89 \] (In fact, $r=0.9$)

\end{document}


\documentclass{article}

\usepackage{showframe} % To render a frame marking the margins

\usepackage{tikz}
\usetikzlibrary{
    arrows.meta, % for the special arrow tip
    backgrounds, % for the two rectangular areas that are behind the two main parts
    decorations.pathmorphing, % for the “snaking line” in the middle
    fit, % to easily compute the sizes of these rectangles
    petri, % defines a place style
    positioning % for placing nodes relative to other nodes
}

% epigraph for quote at start of section
\usepackage{epigraph}
\setlength\epigraphwidth{8cm}
\setlength\epigraphrule{0pt}
\renewcommand{\epigraphsize}{\small\itshape}

% for hyperlinks and URL links
\usepackage{hyperref}

% to manage images
\usepackage{graphicx}
\graphicspath{ {./images/} }

\title{\LaTeX{} Experiments\\ Part III-B: PGF/TikZ - A Petri net example}

\author{AeAeA}

\begin{document}

\maketitle

\vspace{20pt}

\begin{figure}[h] \centering
    \begin{tikzpicture}[
        node distance=1.3cm,on grid,>={Stealth[round]},bend angle=45,auto,
        every place/.style      = {minimum size=6mm,thick,draw=blue!75,fill=blue!20},
        every transition/.style = {thick,draw=black!75,fill=black!20},
        blue label/.style       = {blue!50!black}
    ]

    % Petri net with capacity place

        \node [place,tokens=1] (w1)               [label={[blue label]above:$w1$}] {};
        \node [place]          (c1) [below=of w1] [label={[blue label]above:$c1$}] {};
        \node [place]          (s)  [below=of c1] [label={[red]above:$s\le 3$}]    {};
        \node [place]          (c2) [below=of s]  [label={[blue label]above:$c2$}] {};
        \node [place,tokens=1] (w2) [below=of c2] [label={[blue label]above:$w2$}] {};

        \node [transition] (e1) [left=of c1] [label=left:$e1$]  {}
            edge [pre,bend left]                  (w1)
            edge [post,bend right]                (s)
            edge [post]                           (c1);
        \node [transition] (e2) [left=of c2] [label=left:$e2$]  {}
            edge [pre,bend right]                 (w2)
            edge [post,bend left]                 (s)
            edge [post]                           (c2);
        \node [transition] (l1) [right=of c1] [label=right:$l1$] {}
            edge [pre]                            (c1)
            edge [pre,bend left]                  (s)
            edge [post,bend right] node[swap] {2} (w1);
        \node [transition] (l2) [right=of c2] [label=right:$l2$] {}
            edge [pre]                            (c2)
            edge [pre,bend right]                 (s)
            edge [post,bend left]  node {2}       (w2);

    \end{tikzpicture}
\end{figure}

\newpage
%==============================================================================
\section{What is a Petri net?}

\epigraph
{There is a theory which states that if ever anyone discovers exactly what the
Universe is for and why it is here, it will instantly disappear and be replaced
by something even more bizarre and inexplicable. \\
\hfill \break
There is another theory which states that this has already happened.}
{--- \textup{Douglas Adams},\\ The Restaurant at the End of the Universe}

\begin{itemize}

    \item Quick intro:\\
          \url{https://en.wikipedia.org/wiki/Petri_net}

    \item A good basic explanation of what is a
          \href{https://www.techfak.uni-bielefeld.de/~mchen/BioPNML/Intro/pnfaq.html}
          {Petri net}, with a
          \href{https://www.techfak.uni-bielefeld.de/~mchen/BioPNML/Intro/MRPN.html}
          {well-illustrated example}.

    \item Petri nets and algebraic specifications
          \href{https://www.sciencedirect.com/science/article/pii/030439759190203E?via%3Dihub}
          {paper} (1991).

\end{itemize}

\newpage
%==============================================================================
\section{The Complete Code}

\epigraph
{The story so far: \\
\hfill \break
In the beginning the Universe was created.\\
\hfill \break
This has made a lot of people very angry and been widely regarded as a bad move.}
{--- \textup{Douglas Adams},\\ The Restaurant at the End of the Universe}

\begin{tikzpicture}[
    node distance=1.3cm,on grid,>={Stealth[round]},bend angle=45,auto,
    every place/.style      = {minimum size=6mm,thick,draw=blue!75,fill=blue!20},
    every transition/.style = {thick,draw=black!75,fill=black!20},
    red place/.style        = {place,draw=red!75,fill=red!20}
]

% Petri net with capacity place (left)

    \node [place,tokens=1] (w1)               [label=above:$w1$]            {};
    \node [place]          (c1) [below=of w1] [label=above:$c1$]            {};
    \node [place]          (s)  [below=of c1] [label={[red]above:$s\le 3$}] {};
    \node [place]          (c2) [below=of s]  [label=above:$c2$]            {};
    \node [place,tokens=1] (w2) [below=of c2] [label=above:$w2$]            {};

    \node [transition] (e1) [left=of c1] [label=left:$e1$]  {}
        edge [pre,bend left]                  (w1)
        edge [post,bend right]                (s)
        edge [post]                           (c1);
    \node [transition] (e2) [left=of c2] [label=left:$e2$]  {}
        edge [pre,bend right]                 (w2)
        edge [post,bend left]                 (s)
        edge [post]                           (c2);
    \node [transition] (l1) [right=of c1] [label=right:$l1$] {}
        edge [pre]                            (c1)
        edge [pre,bend left]                  (s)
        edge [post,bend right] node[swap] {2} (w1);
    \node [transition] (l2) [right=of c2] [label=right:$l2$] {}
        edge [pre]                            (c2)
        edge [pre,bend right]                 (s)
        edge [post,bend left]  node {2}       (w2);

% Equivalent Petri net with place complementation (right)

\begin{scope}[xshift=7cm]

    \node [place,tokens=1]     (w1')                                                          {};
    \node [place]              (c1') [below=of w1']                                           {};
    \node [red place]          (s1') [below=of c1',xshift=-5mm] [label={[red]left:$s$}]       {};
    \node [red place,tokens=3] (s2') [below=of c1',xshift=5mm]  [label={[red]right:$\bar s$}] {};
    \node [place]              (c2') [below=of s1',xshift=5mm]                                {};
    \node [place,tokens=1]     (w2') [below=of c2']                                           {};

    \node [transition] (e1') [left=of c1']  {}
        edge [pre,bend left]                  (w1')
        edge [post]                           (s1')
        edge [pre]                            (s2')
        edge [post]                           (c1');
    \node [transition] (e2') [left=of c2']  {}
        edge [pre,bend right]                 (w2')
        edge [post]                           (s1')
        edge [pre]                            (s2')
        edge [post]                           (c2');
    \node [transition] (l1') [right=of c1'] {}
        edge [pre]                            (c1')
        edge [pre]                            (s1')
        edge [post]                           (s2')
        edge [post,bend right] node[swap] {2} (w1');
    \node [transition] (l2') [right=of c2'] {}
        edge [pre]                            (c2')
        edge [pre]                            (s1')
        edge [post]                           (s2')
        edge [post,bend left]  node {2}       (w2');

\end{scope}

% background
\begin{scope}[on background layer]
    \node (r1) [fill=black!10,rounded corners,fit=(w1)(w2)(e1)(e2)(l1)(l2)] {};
    \node (r2) [fill=black!10,rounded corners,fit=(w1')(w2')(e1')(e2')(l1')(l2')] {};
\end{scope}

% snake
    \draw [
        shorten >=1mm,-to,thick,decorate,
        decoration={snake,amplitude=.4mm,segment length=2mm,pre=moveto,pre length=1mm,post length=2mm}
    ]
        (r1) -- (r2)
        node [above=1mm,midway,text width=3cm,align=center]
            {replacement of the \textcolor{red}{capacity} by \textcolor{red}{two places}};

\end{tikzpicture}

%--------------------------------------
\subsection{Transitions}

\begin{tikzpicture}[
    node distance=1cm,on grid,>={Stealth[round]},bend angle=45,auto,
    every place/.style      = {minimum size=6mm,thick,draw=blue!75,fill=blue!20},
    every transition/.style = {thick,draw=black!75,fill=black!20},
    red place/.style        = {place,draw=red!75,fill=red!20},
    every label/.style      = {red}
]

% M0
\begin{scope}[xshift=0cm]

    \node [place,tokens=1]     (w1')                                                   {};
    \node [place]              (c1') [below=of w1']                                    {};
    \node [red place]          (s1') [below=of c1',xshift=-5mm] [label=left:$s$]       {};
    \node [red place,tokens=3] (s2') [below=of c1',xshift=5mm]  [label=right:$\bar s$] {};
    \node [place]              (c2') [below=of s1',xshift=5mm]                         {};
    \node [place,tokens=1]     (w2') [below=of c2']                                    {};

    \node [transition] (e1') [left=of c1']  {}
        edge [pre,bend left]                  (w1')
        edge [post]                           (s1')
        edge [pre]                            (s2')
        edge [post]                           (c1');
    \node [transition] (e2') [left=of c2']  {}
        edge [pre,bend right]                 (w2')
        edge [post]                           (s1')
        edge [pre]                            (s2')
        edge [post]                           (c2');
    \node [transition] (l1') [right=of c1'] {}
        edge [pre]                            (c1')
        edge [pre]                            (s1')
        edge [post]                           (s2')
        edge [post,bend right] node[swap] {2} (w1');
    \node [transition] (l2') [right=of c2'] {}
        edge [pre]                            (c2')
        edge [pre]                            (s1')
        edge [post]                           (s2')
        edge [post,bend left]  node {2}       (w2');

\end{scope}

% M1
\begin{scope}[xshift=3cm]

    \node [place]              (w1')                                                   {};
    \node [place,tokens=1]     (c1') [below=of w1']                                    {};
    \node [red place,tokens=2] (s1') [below=of c1',xshift=-5mm] [label=left:$s$]       {};
    \node [red place,tokens=1] (s2') [below=of c1',xshift=5mm]  [label=right:$\bar s$] {};
    \node [place,tokens=1]     (c2') [below=of s1',xshift=5mm]                         {};
    \node [place]              (w2') [below=of c2']                                    {};

    \node [transition] (e1') [left=of c1']  {}
        edge [pre,bend left]                  (w1')
        edge [post]                           (s1')
        edge [pre]                            (s2')
        edge [post]                           (c1');
    \node [transition] (e2') [left=of c2']  {}
        edge [pre,bend right]                 (w2')
        edge [post]                           (s1')
        edge [pre]                            (s2')
        edge [post]                           (c2');
    \node [transition] (l1') [right=of c1'] {}
        edge [pre]                            (c1')
        edge [pre]                            (s1')
        edge [post]                           (s2')
        edge [post,bend right] node[swap] {2} (w1');
    \node [transition] (l2') [right=of c2'] {}
        edge [pre]                            (c2')
        edge [pre]                            (s1')
        edge [post]                           (s2')
        edge [post,bend left]  node {2}       (w2');

\end{scope}

% M2
\begin{scope}[xshift=6cm]

    \node [place,tokens=2]     (w1')                                                   {};
    \node [place]              (c1') [below=of w1']                                    {};
    \node [red place]          (s1') [below=of c1',xshift=-5mm] [label=left:$s$]       {};
    \node [red place,tokens=3] (s2') [below=of c1',xshift=5mm]  [label=right:$\bar s$] {};
    \node [place]              (c2') [below=of s1',xshift=5mm]                         {};
    \node [place,tokens=2]     (w2') [below=of c2']                                    {};

    \node [transition] (e1') [left=of c1']  {}
        edge [pre,bend left]                  (w1')
        edge [post]                           (s1')
        edge [pre]                            (s2')
        edge [post]                           (c1');
    \node [transition] (e2') [left=of c2']  {}
        edge [pre,bend right]                 (w2')
        edge [post]                           (s1')
        edge [pre]                            (s2')
        edge [post]                           (c2');
    \node [transition] (l1') [right=of c1'] {}
        edge [pre]                            (c1')
        edge [pre]                            (s1')
        edge [post]                           (s2')
        edge [post,bend right] node[swap] {2} (w1');
    \node [transition] (l2') [right=of c2'] {}
        edge [pre]                            (c2')
        edge [pre]                            (s1')
        edge [post]                           (s2')
        edge [post,bend left]  node {2}       (w2');

\end{scope}

% M3
\begin{scope}[xshift=9cm]

    \node [place,tokens=1]     (w1')                                                   {};
    \node [place,tokens=1]     (c1') [below=of w1']                                    {};
    \node [red place,tokens=2] (s1') [below=of c1',xshift=-5mm] [label=left:$s$]       {};
    \node [red place,tokens=1] (s2') [below=of c1',xshift=5mm]  [label=right:$\bar s$] {};
    \node [place,tokens=1]     (c2') [below=of s1',xshift=5mm]                         {};
    \node [place,tokens=1]     (w2') [below=of c2']                                    {};

    \node [transition] (e1') [left=of c1']  {}
        edge [pre,bend left]                  (w1')
        edge [post]                           (s1')
        edge [pre]                            (s2')
        edge [post]                           (c1');
    \node [transition] (e2') [left=of c2']  {}
        edge [pre,bend right]                 (w2')
        edge [post]                           (s1')
        edge [pre]                            (s2')
        edge [post]                           (c2');
    \node [transition] (l1') [right=of c1'] {}
        edge [pre]                            (c1')
        edge [pre]                            (s1')
        edge [post]                           (s2')
        edge [post,bend right] node[swap] {2} (w1');
    \node [transition] (l2') [right=of c2'] {}
        edge [pre]                            (c2')
        edge [pre]                            (s1')
        edge [post]                           (s2')
        edge [post,bend left]  node {2}       (w2');

\end{scope}

\end{tikzpicture}

\newpage
%==============================================================================
\section{Final thoughts}

\epigraph
{The story so far: \\
\hfill \break
In the beginning the Universe was created. \\
\hfill \break
This has made a lot of people very angry and been widely regarded
as a bad move. \\
\hfill \break
Many races believe that it was created by some sort of god,
though the Jatravartid people of Viltvodle VI believe that the
entire Universe was in fact sneezed out of the nose of a being
called the Great Green Arkleseizure. \\
\hfill \break
The Jatravartids, who live in perpetual fear of the time they
call The Coming of the Great White Handkerchief, are small blue
creatures with more than fifty arms each, who are therefore
unique in being the only race in history to have invented the
aerosol deodorant before the wheel. \\
\hfill \break
However, the Great Green Arkleseizure Theory is not widely
accepted outside Viltvodle VI and so, the Universe being the
puzzling place it is, other explanations are constantly being
sought.}
{--- \textup{Douglas Adams},\\ The Restaurant at the End of the Universe}

\begin{figure}[h] \centering
    \includegraphics[width=\textwidth]{dont-panic-elon-musk-tesla} % [width=\textwidth]
\end{figure}

\end{document}


\begin{appendices}

\chapter{Appendix to Chapter \ref{ch:1}}\label{cha:append-chapt-refch:1}

\section{Auxiliary Lemmata}
Fundamental identity
\begin{equation}
  \label{eq:A}
  e^{i\pi}=-1.
\end{equation}
Equivalence relation
\begin{equation}
  \label{eq:B}
  A=B.
\end{equation}

\section{Proofs}

\chapter{Appendix to Chapter \ref{ch:3}}

\section{Proofs}

\section{Supplementary Tables and Figures}
\begin{longtable}{cc}
% Caption to appear on the first page and in the list of tables
\caption[Optional Short caption (used in list of tables)]{A long table} \label{grid_mlmmh} \\

Heading that appears & on first page only\\
\hline
\endfirsthead
\caption[]{(continued)}\\
Heading that appears & on all pages\\
\hline
\endhead
% optional footer
\hline \multicolumn{2}{r}{{Continued on next page}} \\
\endfoot
% footer to appear on tha last page (empty)
\endlastfoot

Contrary to popular & belief, Lorem Ipsum \\ is & not \\ simply &
random \\ text &. It \\ has & roots \\ in & a \\ piece & of \\ classical & Latin
\\ literature & from \\ 45 & BC \\, making & it \\ over & 2000 \\ years old. Richard & Mc \\Clintock &, a \\ Latin & professor \\ at & Hampden \\-Sydney
& College \\ in & Virginia \\, looked & up \\ one & of \\ the & more
\\obscure & Latin \\ words &, consectetur \\, from & a \\ Lorem & Ipsum \\
passage &, and \\ going & through \\ the & cites \\ of & the word in \\
classical & literature , discovered the \\ undoubtable & source. Lorem Ipsum
\\ comes & from \\ sections & 1 \\.10 &.32 \\ and & 1 \\.10 &.33 \\ of
&"de \\ Finibus & Bonorum \\ et & Malorum \\" (The & Extremes \\ of & Good \\
and & Evil \\) by & Cicero \\, written & in \\ 45 & BC \\. This & book \\ is & a
\\ treatise & on \\ the & theory \\ of & ethics \\, very & popular \\ during
&the \\ Renaissance &. The \\ first & line \\ of & Lorem \\ Ipsum, "Lorem ipsum
& dolor \\ sit & amet \\..", comes from a & line \\ in & section
1.10.32.\\
\end{longtable}

\begin{sidewaysfigure}
  \centering Supplementary figures and tables should be placed in the appendix,
  not at the end of a chapter. To rotate big tables and figures $90^{\circ}$,
  use the rotating package and the sidewaystable and sidewaysfigure
  environments. This ensures that the figure and caption get rotated, but the
  page number stays at the bottom of the page.
  \caption{Supplementary Figure}
  \label{fig:figuresup1}
\end{sidewaysfigure}

\begin{figure}[ht]
  \centering
  This is another supplementary figure.
  \caption{Another Figure}
  \label{fig:figuresup3}
\end{figure}

\end{appendices}


\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage[margin=1in]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{DAFoam User Guides}
\rhead{}
\usepackage{biblatex}
\addbibresource{bibliography.bib}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{xurl}
\usepackage{hyperref}
\thispagestyle{empty}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=red,
    urlcolor=blue,
    citecolor=blue,
}

\author{
Author: Janeita Reid\\
\linebreak
Reviewed by: Ping He\\
}

\date{\today}

\renewcommand*\contentsname{Contents}
\sloppy

\begin{document}
\title{Free-Form Deformation (FFD)}

\maketitle

\tableofcontents

\section{General Theoretical and Mathematical Preliminaries}

Before we explain how to setup the FFD points for the pyGeo\footnote{https://github.com/mdolab/pygeo} module from the \href{https://github.com/mdolab/MACH-Aero}{MACH-Aero framework}, it's essential to first understand underlying theoretical and mathematical formulations. In doing so, the user will gain a better understanding of pyGeo's strengths and weaknesses and how these influence constrained optimization in any of the disciplines supported by DAFoam (aerodynamics, solid mechanics and hydrodynamics). The guidelines covered in this section are for general applications using FFD. More specific guidelines  will be given in the sections that follow to highlight the features of the FFD module in MACH-Aero.\vspace{4mm}

\begin{figure}[ht]
    \centering
    \includegraphics[width=1\textwidth]{pygeo.PNG}
    \caption{The pyGeo module for geometry parametrization (node 3) in the MACH-Aero framework \cite{machaero}}.
    \label{fig:my_label}
\end{figure}

\noindent pyGeo is closely tied to the concepts supporting free form deformation (FFD). FFD was first presented by Sederberg and Perry as a method for sculpting solid models by conducting global or local deformations \cite{sederberg}. The classic method involves a $R^3$ $\rightarrow$ $R^3$ mapping using trivariate tensor product Bernstein polynomials\cite{sederberg}, but this approach has evolved to also use  tri-variate Bézier, B-spline or NURBS volumes \cite{kenway} for mapping and remapping object points. The FFD approach adopted in pyGeo was developed by Kenway and Martins \cite{kenway}.\vspace{4mm}

\noindent To get a better understanding of how FFD works, one can imagine putting an object or any geometry into a clear, flexible plastic-like shape that is transparent. In other words, by using FFD the geometry of the object is embedded into a volume that can be manipulated by moving points at the surface known as FFD points \cite{He2018}. \vspace{4mm}

\noindent In order to manipulate the object and arrive at an optimized geometry, there are three steps involved in FFD, namely :

\begin{enumerate}
    \item Create an initial FFD box with volumetric control points (aka. FFD points).
    \item Embed the design surface into the FFD box and find the mapping between the design surface's physical coordinates (x,y,z) and the FFD's parameter space (u,v,w).
    \item Deform the design surface by moving the FFD control points.
\end{enumerate}

\noindent To transform the steps above into mathematical formulations we take four things into consideration: the vertices of the initial embedded object given by $\overrightarrow{P}(u,v,w)$, the parametric space represented by $(u_0,v_0,w_0)$, control points (FFD points) on the initial deformation lattice given by $\overrightarrow{Q}_{i,j,k}$, and the vertices of the deformed object represented by $P^{new}(u_0,v_0,w_0)$ with new FFD points$\overrightarrow{Q}_{i,j,k}^{new}$ .\vspace{4mm}

\noindent Additionally, basic knowledge of B-spline curves, surfaces or volumes presented by Kenway and Martins \cite{kenway} is also necessary to understand the parametrization of different objects.\vspace{4mm}

For curves we have:
\begin{equation}
    C(u)=\sum_{i=0}^{N_{u}-1}N_{i,m_u}(u)Q_i
\end{equation}

For surfaces we have:\vspace{4mm}
\begin{equation}
    S(u,v)= \sum^{N_{u}-1}_{i=0}\sum^{N_{v}-1}_{j=0}N_{i,m_u}(u)N_{j,m_v}(v)Q_{i,j}
\end{equation}

And for volumes we have: \vspace{4mm}
\begin{equation}
    V(u,v,w)= \sum^{N_{u}-1}_{i=0}\sum^{N_{v}-1}_{j=0}\sum^{N_{w}-1}_{k=0} N_{i,m_u}(u)N_{j,m_v}(v)N_{k,m_w}(w) Q_{i,j,k}
\end{equation}

\noindent A good explanation of B-spline can be found here~\cite{Bspline}. With these in mind we develop the steps mentioned above considering the mathematical theory behind each of the three steps.\vspace{4mm}

\textbf{Step 1}\\
The first step mentioned above represents the FFD module coupled with pyGeo. This tool will be elaborated further on in the tutorial. \vspace{4mm}

\textbf{Step 2}\\
We need to consider that the embedded object which lies in a cartesian space is mapped into an initial trivariate B-spline volume using the equations below as given by Kenway and Martins \cite{kenway} and Ronzheimer \cite{Ronzheimer2004}. We have adopted the notations and overview presented by Ronzheimer \cite{Ronzheimer2002,Ronzheimer2004} with a small modification considering $Q_{i,j,k}^{new}$ instead of $R_{i,j,k}$. \vspace{4mm}

\noindent For the mapping, a Newton method is used to calculate the parametric coordinates from given Cartesian coordinates\cite{Ronzheimer2006, He2018}. In other words, a mapping is determined between the FFD points (parameter space) and the surface geometry (physical space) \cite{He2018}. This is done by applying the Newton search on Equation 4 for each vertex of  $\overrightarrow{P}$ by solving for $u_0, v_0, w_0$ with the aim of mapping the points to the B-spline volume.

\begin{equation}
    \overrightarrow{P}(u,v,w)= \sum_{i=0}^{n_u}N_{i,m_{u}}(u),N_{j,m_{v}}(v),N_{k,m_{w}}(w)Q_{i,j,k}
\end{equation}

$N_{i,m_{u}}$, $N_{j,m_{v}}$ and $N_{k,m_{w}}$ are B-spline basis functions of degree $m_u$, $m_v$, and $m_w$. These are defined as knot vectors as follows:\vspace{4mm}
\begin{enumerate}
    \item $N_i:{0,..,0,U_{m_{u+1}}...,U_{n_{u}},1,...,1}$
    \item $N_j:{0,..,0,v_{m_{v+1}}...,v_{n_{v}},1,...,1}$
    \item $N_k:{0,..,0,w_{m_{w+1}}...,w_{n_{w}},1,...,1}$
\end{enumerate}

The basis functions mentioned previously are calculated recursively using:

\begin{equation}
   N_{i,1_{u}} = \begin{cases}
0, & u_i \le u <u_{i+1},\\
1, & \text{otherwise}.
\end{cases}
\end{equation}
and
$$N_{i,m_{u}}(u) = \frac{u -u_i}{u_{i+m_{u-1}}-u_i}N_{i,m_{u-1}}(u) + \frac{u_{i+m_{u}}-u}{u_{i+m_{u}-u_{i+1}}}N_{i+1,m_{u-1}}(u)$$

\noindent \textbf{Step 3}\\
Finally, the B-spline volume that was calculated in Equation 4 is replaced by a new B-spline volume with control points $Q_{i,j,k}^{new}$. This is done by remapping the $u_0, v_0, w_0$ values previously calculated to obtain the deformed object point represented by $P^{new}(u_0,v_0,w_0)$. \vspace{4mm}

\begin{equation}
    \overrightarrow{P}^{new}(u_0,v_0,w_0)= \sum_{i=0}^{n_u}N_{i,m_{u}}(u_0),N_{j,m_{v}}(v_0),N_{k,m_{w}}(w_0)Q_{i,j,k}^{new}
\end{equation}

\noindent The initial control point lattice $\overrightarrow{Q}_{i,j,k}$ in Equation 4  and the new one in Equation 6 $Q_{i,j,k}^{new}$ perform the same function: to control the deformation of the embedded geometry. The final deformation of the embedded object is determined by $Q_{i,j,k}^{new}$. From Figure 2 it can be seen that the control lattice been deformed. This means that the initial points for $Q_{i,j,k}$ are no longer at their original position and have shifted creating a new control lattice $Q_{i,j,k}^{new}$.

\begin{figure}[ht]
    \centering
    \includegraphics[width=0.75\textwidth]{deformedFFD.PNG}
    \caption{Before and after FFD points \cite{machaeroffd}}.
    \label{fig:my_label}
\end{figure}

\section{FFD considerations}
FFD is best suited for small to medium deformations \cite{Samareh2004} and proper constraints should be in place to ensure feasible geometry changes \cite{Anderson2012}. As a volumetric deformation method, FFD offers three advantages \cite{Anderson2012}: the embedded surface geometry has minimal effect on the computational cost, it is impartial to discrete geometry format, and the deformation quality is independent of the surface discretization quality. The main driver behind these advantages is that FFD volume parametrizes the \emph{geometry change} rather than the geometry itself \cite{kenway}; therefore, FFD eliminates the need for geometry abstraction and surface grid generation \cite{Samareh2004}. \vspace{4mm}

\noindent However, despite these advantages it's worth nothing that the grid topology is held fixed to ensure that as the design variables are modified, the function gradients are unaffected and remain continuous\cite{kenway}. The implication of this is that lattice controls the deformation of the object and there is no continuous interactive deformation involved.

\section{FFD in DAFoam: pyGeo}
At the start of this tutorial, we noted that FFD allows the user to conduct both global and local deformation. Within pyGeo we can also control both the local and global shape of the geometry during optimization \cite{He2018}.The parametrization using pyGeo can be applied to structural domain, wetted surface of an aircraft \cite{kenway}, airfoil surface and wind turbine blade geometry.\vspace{4mm}

\noindent In the example that follows, we will look at how to conduct a aerodynamic analysis of the NACA 0012 airfoil and the steps taken by pyGeo to parametrize the geometry.

\subsubsection{Initial setup}
Before you configure the settings in your FFD folder its important to perform the following steps first:
\begin{enumerate}
    \item Load your mesh in the appropriate folder. You can either use a mesh you generated from another program or run the meshing option configured in DAFoam. If you plan to use another mesh generated from another program, it won't be necessary to run the \textbf{preProcessing.sh} command to generate your mesh in DAFoam. You'll need to type blockMeshDict to populate your Polymesh file in the case folder if you use a grid generated from another program.
    \item Configure your runscript.py with the appropriate values for your particular case. For the case of optimizing for drag with lift constrained, you will need to first generate the correct angle of attack using the following command in your terminal: \textbf{mpirun -np 4 python runScript.py --task=solveCL}. But before you do that, continue to configure your runscript.py script until you reach the section \textbf{Design Variable Setup}. In the next sections we'll elaborate some more on what to do next.
\end{enumerate}

\subsubsection{Point selection and Troubleshooting}

Within DAFoam you will be working with two files to modify your FFD points and control the geometric changes that are linked to the design variables in the adjoint equations: the Design Variable Setup section in the \textbf{runscript.py} and the \textbf{genFFD.py}.\vspace{4mm}

\begin{figure}[ht]
    \centering
    \includegraphics[width=1\textwidth]{FFDcodeshot.PNG}
    \caption{Code snippet from runscript.py highlighting the genFFD.py section credit: DAFoam}
    \label{fig:my_label}
\end{figure}

\noindent Before changing the parameters for the FFD points, assess your geometry to determine which parts of should be optimized and which should remain fixed. Parts of the geometry that will be optimized will be enclosed with FFD control point lattices. These points will then be manipulated according to the mathematical formulations explained above.\vspace{4mm}

\noindent The number of FFD control points will influence the design freedom of an optimization problem. Hence, the number of FFD control points used does affect the fidelity of the final design: too few control points and we risk ignoring certain possibilities in the design space; too many design points and we could have issues with mesh overlap, an over crowded lattice and slower optimization. This is why it is important to choose the correct number of design points through trial and error and assess the final design to determine if the results reflect feasible applications.\vspace{4mm}

\noindent The effect of the number of design control points was clearly seen in a study conducted by Ronzheimer \cite{Ronzheimer2006}. In the study it was shown that by doubling the number of FFD points from 4 to 8, the lift to drag ratio increased from 12\% to 16\% respectively. The optimization cycle also increased when the design points were doubled and clear differences in the final optimized shapes were noticed. Similar studies by Lyu, Kenway and Martins \cite{Lyu2014a} demonstrated that the effect of reducing the number of airfoil control points from 48 to 24 resulted in negligible effect on optimal shape and pressure while further decrease to 12 and then to 6 showed noticeable differences in drag and pressure coefficients.     \vspace{4mm}

\noindent As a general guide we usually use 20 points for an airfoil section. However, users can use more or less depending on optimization goals.

\subsubsection{Setting the Design Variables}

We set the design variable using the pyGeo module in the MACH-Aero framework by following the steps below in the \textbf{Design Variable Setup} section of the runscript.py script:

\begin{enumerate}
\item Open the FFD folder in the case you are using for design optimization. It should look something like this below with the corresponding contents:

\begin{figure}[ht]
    \centering
    \includegraphics[width=0.85 \textwidth]{FFDcasefolder.PNG}
    \caption{ Typical case setup after running a simulation  credit:DAFoam}
    \label{fig:my_label}
\end{figure}

\begin{figure}[ht]
    \centering
    \includegraphics[width=0.55 \textwidth]{genFFd.PNG}
    \caption{FFD folder contents  credit: DAFoam}
    \label{fig:my_label}
\end{figure}

    \item Create a DVGeo object (DVGeo = DVGeometry(“./FFD/wingFFD.xyz”)) to manipulate the design surface geometry using the free-form deformation (FFD) approach. \textbf{NOTE: the FFD volume should completely contain the design surface}. The FFD file wingFFD.xyz is generated by running “python genFFD.py” in the FFD folder. We then add a reference axis (“addRefAxis”) for twist. Note that in this case we run 2D airfoil optimization, so no twist is needed, and “bodyAxis” is not used \cite{DAFoam}.

    There are two options to visualize the FFD points:

    \begin{itemize}
        \item First copy the constant folder, the system folder, and paraview.foam to the FFD folder, then go to the FFD folder and run this command to convert the FFD mesh (plot3D format) to the OpenFoam mesh (plot3DToFoam -noBlank wingFFD.xyz) and use Paraview to load the FFD/paraview.foam file to view the FFD points.

        \item In version 2.2.1, we added a new utility to convert the plot3D file (*.xyz) format to the Tecplot format, such that you can load the FFD point in Paraview more easily (Paraview sometimes crashes when loading Plot3D files). To use it, just copy over the dafoam/dafoam/scripts/dafoam\_plot3d2tecplot.py file and run \texttt{python dafoam\_plot3d2tecplot.py wingFFD.xyz wingFFDTecplot.dat}. \textbf{NOTE: Be sure to copy dafoam\_plot3d2tecplot.py script to where you store the wingFFD.xyz file or else you will encounter problems}.

    \end{itemize}

    Now that you have done the necessary configurations in the genFFD.py file, the next step is to modify the runscript.py script at the Design variable setup mentioned earlier.

    \item Once the FFD file is loaded and the reference axis is created, we select FFD points to move. The FFD file supports multi block meshes, but in this case we have only one block in the FFD, so we select “iVol = 0”. We allow all the points to move so we set “pts[:, :, :]” for “indexList”. Alternatively, we can select a subset of indices to move by setting a range for pts to move, e.g., indexList = pts[1:2, 3, 5:6].flatten() \cite{DAFoam}.

    \begin{figure}[ht]
    \centering
    \includegraphics[width= 0.85 \textwidth]{FFDairfoil.PNG}
    \caption{Example with 8 FFD points where D9 and D10 are fixed \cite{Ronzheimer2004}}
    \label{fig:my_label}
\end{figure}

  \end{enumerate}

\noindent If you intend to use one block to run your simulation then your block setup will look like this below.\vspace{4mm}

    \begin{figure}[ht]
    \centering
    \includegraphics[width= 1 \textwidth]{FFDPY.PNG}
    \caption{FFD setup in genFFD.py}
    \label{fig:my_label}
\end{figure}

\noindent We'll notice that there is a nx, ny, nz. These mean the number of points in the x, y, z coordinates.\vspace{4mm}

\noindent For corners = np.zeros([nBlocks,8,3]):\vspace{4mm}

\noindent The first entry is the FFD block number. In this case, there is only one block, that is why it is always zero. For examples using more than one blocks you can check the \href{https://dafoam.github.io/mydoc_tutorials_aero_dpw4.html}{DPW4} case or the \href{https://dafoam.github.io/mydoc_tutorials_aero_30n30p.html}{30N30P Multi-element airfoil} case where multiple FFD blocks are used, e.g., one for the wing and one for the tail.\vspace{4mm}

\noindent The 2nd entry is the 8 corner indices, and the 3rd entry is the x,y,z coordinates of the corners.\vspace{4mm}

\noindent If you intend to use two blocks then you'll need to modify the code to consider this type of configuration.

\subsubsection{Simulation Example: NACA 0012}

In this section we'll do a few examples to practice how to setup the getFFD.py and configure runscript.py. \vspace{4mm}

\noindent \textbf{Step 1: Understand the Geometry You have}\\
\noindent Before we do any changes in the FFD files, we need to understand the type of geometry we are working with to know the limits of the FFD control points to consider. For a 2D airfoil such as NACA 0012 this means that were interested in the variations along the x and y axis. In this case we are using an airfoil with a blunt trailing edge where we removed a section. The coordinates the airfoil have been provided below for clarity.

\begin{multicols}{2}
\noindent 0.0000000 0.0000000\\
 0.0005839 -.0042603\\
 0.0023342 -.0084289\\
 0.0052468 -.0125011\\
 0.0093149 -.0164706\\
 0.0145291 -.0203300\\
 0.0208771 -.0240706\\
 0.0283441 -.0276827\\
 0.0369127 -.0311559\\
 0.0465628 -.0344792\\
 0.0572720 -.0376414\\
 0.0690152 -.0406310\\
 0.0817649 -.0434371\\
 0.0954915 -.0460489\\
 0.1101628 -.0484567\\
 0.1257446 -.0506513\\
 0.1422005 -.0526251\\
 0.1594921 -.0543715\\
 0.1775789 -.0558856\\
 0.1964187 -.0571640\\
 0.2159676 -.0582048\\
 0.2361799 -.0590081\\
 0.2570083 -.0595755\\
 0.2784042 -.0599102\\
 0.3003177 -.0600172\\
 0.3226976 -.0599028\\
 0.3454915 -.0595747\\
 0.3686463 -.0590419\\
 0.3921079 -.0583145\\
 0.4158215 -.0574033\\
 0.4397317 -.0563200\\
 0.4637826 -.0550769\\
 0.4879181 -.0536866\\
 0.5120819 -.0521620\\
 0.5362174 -.0505161\\
 0.5602683 -.0487619\\
 0.5841786 -.0469124\\
 0.6078921 -.0449802\\
 0.6313537 -.0429778\\
 0.6545085 -.0409174\\
 0.6773025 -.0388109\\
 0.6996823 -.0366700\\
 0.7215958 -.0345058\\
 0.7429917 -.0323294\\
 0.7638202 -.0301515\\
 0.7840324 -.0279828\\
 0.8035813 -.0258337\\
 0.8224211 -.0237142\\
 0.8405079 -.0216347\\
 0.8577995 -.0196051\\
 0.8742554 -.0176353\\
 0.8898372 -.0157351\\
 0.9045085 -.0139143\\
 0.9182351 -.0121823\\
 0.9309849 -.0105485\\
 0.9427280 -.0090217\\
 0.9534372 -.0076108\\
 0.9630873 -.0063238\\
 0.9716559 -.0051685\\
 0.9791229 -.0041519\\
 0.9854709 -.0032804\\
 0.9906850 -.0025595\\
 0.9947532 -.0019938\\
 0.9976658 -.0015870\\
 0.9994161 -.0013419\\
 \end{multicols}

\noindent From the airfoil coordinates above, we see that your largest $x$ value is 0.9994161, while our largest $y$ value is 0.0600172. This means that the lattice/ block we create needs to be a bit bigger than 0.9994161 x 0.0600172. Let us choose one that is 1.01 x 0.07. It is important that the control lattice is body-fitted. If the lattice is too big for example 100 x 100 for the example above, then the gradient of dCD/dFFD will become very small (because the FFD point is far away from the design surface). The problem with this is that dCD/dFFD will have very different magnitudes compared with other design variables, say dCD/dAlpha with Alpha being the angle of attack. This will cause problems for the optimizer because it always wants to receive gradients with similar orders of magnitude. Hence, body-fitted FFD points should be used at all times. \vspace{4mm}

\noindent \textbf{Step 2: Setup the FFD control points}

\noindent We know that we intend to use one block and that this one will have a dimension of 1.01 x 0.07. We now need to map out the points in this block. These points will represent the vertices of our control lattice. \vspace{4mm}

\noindent To create our FFD points we need to remember that NACA 0012 is a symmetric airfoil. We put our axis in the symmetric plane xy = 00 and start to map out our FFD control points.The order we choose to map out the control points is as follow: start with leading edge and then move to trailing edge. We have chosen to use 8 vertices for our block and will modify our genFFD.py to represent this.\vspace{4mm}

\noindent The first point we enter is our coordinate with vertice (x,y) = (0,0). Although we have 2D airfoil, we are actually mapping out points for a 3D lattice as shown in the corners = np.zeros([nBlocks,8,3]). Taking this into consideration the point (0,0) will have coordinates $(-0.010,-.0700,0.0)$ on our lattice. This represents the leading edge control point in the negative y direction. The second point we consider is $(-0.010,-0.0700,0.1)$ which takes into consideration the thickness of our airfoil. Still at the leading edge we consider two more points to reflect the symmetry of our airfoil:[-0.010,0.0700,0.0] and [-0.010,0.0700,0.1]. The first point represents control point on the positive y direction, while the second point takes the thickness into consideration.\vspace{4mm}

\noindent You will notice that so far only the leading edge and trailing edge points have been considered. This is because we need to prescribe the corners points for the FFD box, then the genFFD.py script will generate the coordinates for all other FFD points. To get a better understanding of this, check the \textbf{writeFFDFile} and \textbf{returnBlockPoints} functions in genFFD.py. \vspace{4mm}

\noindent \textbf{Step 3: Visualize the control points}

\noindent It's important that the control points cover the geometry, otherwise there will be errors. To visualize the control points, you can choose from two options as mentioned above. \vspace{4mm}

\noindent \textbf{Step 4: Apply constraints}

\noindent Next we need to setup constraints to ensure that the optimized geometry is within feasible limits. To do this we use our runscript.py to modify the constraints. Here we can apply thickness constraints and volume constraints. FFD allows one to maintain constant volume even after geometry changes. \vspace{4mm}

\noindent Lower and upper projection points are used by the FFD during optimization to calculate the new thickness and volume change. An example of this is shown in the image below. More details can be obtained at \href{https://mdolab-mach-aero.readthedocs-hosted.com/en/latest/machAeroTutorials/opt_aero.html#geometric-constraints}{Mach Aero Tutorials}. \vspace{4mm}

 \begin{figure}[ht]
    \centering
    \includegraphics[width=1.0\textwidth]{thicknessconstraint.PNG}
    \caption{Example showing how volume and thickness constraints are calculated \cite{machaero2021}}.
    \label{fig:my_label}
\end{figure}

 \noindent \textbf{Step 5: Run simulation}

\noindent When all the necessary parameters are entered the next step is to run \textbf{mpirun -np 4 python runScript.py}. Check the result and move the control points if needed once the optimization is complete.

\section{Advanced Tips and Tricks}
\textbf{Ensure that your FFD points fully cover the design surface of your airfoil.}
You can convert *.xyz file (FFD file) to the OpenFOAM format using this command: plot3dToFoam -noBlank wingFFD.xyz  Then you can load the FFD points and your OpenFOAM mesh into Paraview to check if FFD points fully contain the design surface.\vspace{4mm}

\section{Forum}
There is no better way to learn than to ask questions. You can post questions on the DAFoam \href{https://github.com/mdolab/dafoam/discussions}{forum} to get answers on bugs, general questions, tutorials, and installation. Before you post a question, first check out the best practices below:

\begin{enumerate}
    \item Check first to see if your question has already been answered.
    \item If your question has not been answered create a new discussion ensuring that:
    \begin{itemize}
        \item The title of the question matches the details you'll provide.
        \item The most appropriate category has been selected for your question.
        \item Your question covers all the necessary details: what you did, what did not work, screenshots clearly showing details of your question, the results you were expecting and so on.
    \end{itemize}
\item If you find that you'll need to ask multiple questions on different topics, consider posting each topic separately as a new discussion. This way people are more likely to find the question instead of scrolling through a long thread. Of course, if keeping the discussion in one thread reduces the likelihood of confusion and makes it easier to follow how the problem gets solved then consider doing so.
\end{enumerate}
 \printbibliography
\end{document}


\subsection{Static data sets}

\noindent The possibility to de-anonymise data was introduced and demonstrated by \citeA{sweeney2000}. In the study, Sweeney used public 1990 U.S. Census summary data to investigate the potential of identifying unique individuals. It was found that 87\% of the population in the United States had reported characteristics that likely made them unique based on the quasi-identifier attributes 5-digit ZIP2, gender, date of birth \cite{sweeney2000}.
\\
In order to develop a method to protect released data against re-identification attacks, \citeA{kanonymity2002} introduced the method \textit{k-anonymity}:

\begin{definition}[$k$-Anonymity]
Let RT$(A_1,...,A_n)$ be a table of $n$ attributes and $QID_{RT}$ be the quasi-identifier associated with it, that is, a subset of the attrib. RT is said to satisfy $k$-anonyutesmity if and only if each sequence of values in RT[$QID_{RT}$] appears with at least $k$ occurrences in RT[$QID_{RT}$]. \cite{kanonymity2002}
\end{definition}
\\
\noindent The quasi-identifier $QID_{RT}$ is the minimal set of attributes $QID_{RT} \subset (A_1,...,A_n)$ that can be used in an re-identification attack to join the data with external information in order to uniquely identify individuals. That means that $k$-Anonymity guarantees privacy protection by making each combination of values of the quasi-identifier indistinguishable from at least $k-1$ other individuals. In traditional database domains, $k$-Anonymity has been proved efficient for privacy protection \cite{li2008}.\\

\begin{example}[3-Anonymization] \label{3ano}
Let us consider an example for the QID \{postcode, occupation, age\} and sensitive attribute \{income\}:
\begin{table}[H]
\centering
\begin{tabular}{@{}llll@{}}
\toprule
postcode & occupation             & age & income \\ \midrule
10230    & high school teacher    & 32  & 65 k   \\
21032    & physician              & 42  & 95 k   \\
21030    & dentist                & 40  & 110 k  \\
10210    & primary school teacher & 38  & 58 k   \\
21030    & surgeon                & 46  & 150 k  \\
10285    & sessional instructor   & 28  & 42 k   \\ \bottomrule
\end{tabular}
\caption{Table T of micro data}
\label{vulnerableData}
\end{table}
\noindent The following generalization of the table is 3-anonymous and therefore an attacker with  background information can't reliably identify the individuals:
\begin{table}[H]
\centering
\begin{tabular}{@{}llll@{}}
\toprule
postcode & occupation     & age       & income \\ \midrule
102**    & teacher        & (27-38{]} & 65 k   \\
2103*    & medical doctor & (38-46{]} & 95 k   \\
2103*    & medical doctor & (38-46{]} & 110 k  \\
102**    & teacher        & (27-38{]} & 58 k   \\
2103*    & medical doctor & (38-46{]} & 150 k  \\
102**    & teacher        & (27-38{]} & 42 k   \\ \bottomrule
\end{tabular}
\caption{3-anonymous Table T' on QID}
\label{genData}
\end{table}

\end{example}

\noindent In order to achieve $k$-Anonymity, generalization needs to be used. As can be seen from example \ref{3ano}, this is, the process of replacing values by a more general value, for example by an interval, shortening the value, a more general description or in the worst case it might be necessary to completely suppress the value and replace it entirely by an asterisk. \\
\\
Even though \citeA{kanonymity2002} proves that this measure protects privacy against a variety of attacks, however \citeA{ldiversity2006} show that it has two major shortcomings. The first problem that they point out is the lack of diversity within the sensitive attribute. They reason that the data set can be $k$-anonymous, but if the $k$ tuples of an equivalence class all have the same sensitive value, the attacker can still make inferences about an individual with the appropriate background information, they call this a \textbf{homogeneity attack}. The second shortcoming that \citeA{ldiversity2006} point out is that if an attacker has additional background knowledge he can detect the sensitive information. Referring to example \ref{3ano}, assume a friend of yours, that means having this knowledge, is a high school teacher in the postcode area 10230 with age 32. Additionally, you know that any high school teacher starts with a salary higher than 60 k, now even if you possess only the generalized table T', you can still infer your friend's exact salary. \citeA{ldiversity2006} call this a \textbf{background knowledge attack}.\\
\\
By showing that the ideal definition of privacy called \textit{bayes-optimal}, where both, the data publisher and the adversary, have full (and identical) background knowledge, can hardly be guaranteed in a real-world context, \citeA{ldiversity2006} arrive at a practical principle, they call $l$-diversity:

\begin{definition}[$l$-Diversity principle]
A equivalence class, that is a group of tuples with the same generalized QID, is $l$-diverse if it contains at least $l$ "well-represented" values for the sensitive attribute S. A table is $l$-diverse if every equivalence class is $l$-diverse. \cite{ldiversity2006}
\end{definition}

\noindent Based on this principle \citeA{ldiversity2006} define five instantiations of $l$-Diversity. With these definitions, they prove that $l$-diversity provides privacy even if the data publisher lacks information about the knowledge possessed by the attacker. Furthermore, they show that existing algorithms for $k$-anonymity can be easily adapted to $l$-diversity, and with experiments they underline that their method is practical and implementable in an efficient way.

\subsection{Streamed data}
The optimization of \textit{k-anonymity} as well as \textit{l-diversity} was proven to be NP-hard \cite{kanonymitynphard, ldiversitynphard}. In a streamed environment the methods may imply a delay of the publication of all or some tuples. This is especially critical when the utility of the the data decreases with the time that is passed in between data generation, that is, event occurrence, and the time the data is analyzed. A possible application could be a credit card provider, who wishes to outsource the task of credit risk predictions to an external organization, and therefore needs to the stream the transactional data to the service provider, if possible in real-time.\\
\\
A natural extension of the two methods introduced in the previous section would be an incremental approach. That means waiting until a certain amount of data has arrived and subsequently treating this data as if it were a static data set, applying $l$-diversity or $k$-anonymity as described before. \citeA{xiao2007} studied a situation that is closely related to the incremental approach, namely the implications of the previous section's approaches in the context of the re-publication of micro data sets that have been updated with insertions or deletions. \citeA{byun2006} studied privacy attacks on re-publication of datasets with insertions only and developed a solution to effectively prevent those attacks. \citeA{xiao2007} start from this solution and extend it by the possibility of deletions in order to preserve privacy in fully dynamic datasets. The problem inherent in re-publication is illustrated by the following example:

\begin{example}[The re-publication problem of varying diversity]
Consider the following equivalence class is part of a published and generalized dataset:
\begin{table}[H]
\centering
\begin{tabular}{llll}
\toprule
postcode & occupation     & age       & income \\ \midrule
2103*    & medical doctor & (38-46{]} & 95 k   \\
2103*    & medical doctor & (38-46{]} & 110 k  \\ \bottomrule
\end{tabular}
\caption{Equivalence class in first release}
\label{ecRelease1}
\end{table}
Now consider a republication of the dataset where the previous equivalence class becomes the following:
\begin{table}[H]
\centering
\begin{tabular}{llll}
\toprule
postcode & occupation     & age       & income \\ \midrule
2103*    & medical doctor & (38-46{]} & 95 k   \\
2103*    & medical doctor & (38-46{]} & 65 k  \\ \bottomrule
\end{tabular}
\caption{Equivalence class in second release}
\label{ecRelease2}
\end{table}
An adversary having the following knowledge about an individual \{21031, dentist, 40\}, and knowing that the individual had to be present in both releases, can now infer that this individual's income must be 95 k, due to the fact that the diversity has changed.
\end{example}

\noindent To tackle the shortcoming illustrated in the previous example, \citeA{xiao2007} introduced two new methods, first of all $m$-variance and a new generalization technique called \textit{counterfeit generalization}. The idea behind these approaches is to add so called counterfeit tuples to equivalence classes where necessary, in order to preserve the original diversity, and add accompanying statistics about in which equivalence class these counterfeit tuples were added in order to enhance the effectiveness of data analysis. They find that the a key characteristic for preserving privacy in re-publication is to ensure a certain "in-variance" in all the equivalence classes. While this approach works well for re-publication in the case of minor insertions and incremental enhancements to data sets, for a data stream it is very impractical for various reasons. One of the reasons is that streams are characterized by high velocities and frequencies at which the data arrives, these large volumes will result in problems in the case of re-publication, since the data set will always be growing, and the previously mentioned methods will require several scans through the table to be published. Furthermore, since the utility of the data decreases with the time that has passed, there is no reason to republish the data again. The goal is to publish the data as fast as possible, one it arrived. Another reason is the characteristic of a data stream that as soon as the anonymized data stream is output, it can not be revisited again. Therefore, the previously mentioned problem of an adversary being able to analyse two releases jointly is not applicable to the streaming scenario.\\
\\
\citeA{li2008} were the first researchers to adapt the $k$-anonymity approach entirely to a streaming setting. They propose an algorithm that guarantees $k$-anonymity and furthermore their algorithm poses a constraint on the degree of how much "out-of-order" the output stream is compared to the input. Additionally, the goal of the algorithm is to retain as much information in the outputted stream.
Experiments show that the algorithm is effective and efficient \cite{li2008}. \citeA{CpppOfDataStreams} go further and developed an approach that considers both the distribution of the data values to be released and the statistical distribution of the data stream, which resulted in various anonymization quality measures and a group of randomized methods. With these approaches \citeA{CpppOfDataStreams} tackle the problem of heavy information loss in the case of outliers, that the previous methods can't cope with. Their algorithm makes the decision whether a set of elements should be anonymized and released at a certain point of time, based on the current information loss compared to a later release, where the expected future information loss is inferred from the statistical distribution of the data in the stream.\\
\\
Having discussed the pitfalls and advantages of the previously conducted research in the field, we are now ready to introduce our novel approach in the next section, that is based on a combination of the SKY-algorithm by \citeA{li2008} and the findings of \citeA{CpppOfDataStreams}, but extends it and applies it in a parallel computation environment. There will be more details about the two approaches provided in the description of our algorithm.


\section{Node Leaf factors}

%this file needs scenes with normal , bvh , perf data to show how the sah factors behave for several N and L with different scenes (and subdivisions?)

To calculate the cost of a node in relation to the cost of a leaf we can use the following values: (Time of Node / node intersection count) / (Time of Leaf/ Leaf intersection count)

This only holds for the pc the performance data was collected. (in this case my laptop). It seems that the values are the same on most "normal" scenes.

\begin{figure}[!htb]
	\begin{minipage}[t]{0.5\textwidth}
		\begin{tikzpicture}
		\begin{axis}
		[
		xlabel = \leafs,
		ylabel = \branchf,
		colorbar style={title = Sah Node Factor},
		xtick = {4, 8, ..., 16},
		ytick = {4, 8, ..., 16},
		]
		\addplot[matrix plot*,point meta=\thisrow{sahNodeFactor}]
		table[x = leafSize, y = branchFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTableWithSpace.txt};
		\end{axis}
		\end{tikzpicture}
	\end{minipage}
\caption{Computation cost of one node relative to the computation cost of one leaf}
\end{figure}

\pgfplotsset{
	every axis/.append style={colorbar = false},
}

\begin{figure}[!htb]
	\begin{minipage}[t]{0.5\textwidth}
		\begin{tikzpicture}
		\begin{axis}
		[
		%view={90}{0} for x, view={0}{0} for y restriction
		view={0}{0},
		xlabel = Branching factor,
		ylabel = node Factor,
		cycle list name = linestyles*,
		legend style={at={(0.05,0.95)}, anchor = north west},
		xtick = {4, 8, ..., 16},
		%xticklabels={$8$,$16$,$24$,$32$,$40$,$48$,$56$,$64$,$72$,$80$,$88$,$96$,$104$,$112$,$120$,$128$},
		]
		\addplot+[thick, mark=none]table[discard if not={leafSize}{4}, x = branchFactor, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={leafSize}{8}, x = branchFactor, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={leafSize}{12}, x = branchFactor, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={leafSize}{16}, x = branchFactor, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};

		\legend{L4, L8, L12, L16}
		\end{axis}
		\end{tikzpicture}
	\end{minipage}
	\begin{minipage}[t]{0.5\textwidth}
		\begin{tikzpicture}
		\begin{axis}
		[
		%view={90}{0} for x, view={0}{0} for y restriction
		view={0}{0},
		xlabel = Leaf size,
		ylabel = node Factor,
		cycle list name = linestyles*,
		legend style={at={(0.65,0.95)}, anchor = north west},
		xtick = {4, 8, ..., 16},
		%xticklabels={$8$,$16$,$24$,$32$,$40$,$48$,$56$,$64$,$72$,$80$,$88$,$96$,$104$,$112$,$120$,$128$},
		]
		%x expr = \thisrow{subdivision}
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{4}, x = leafSize, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{8}, x = leafSize, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{12}, x = leafSize, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{16}, x = leafSize, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};

		\legend{N4, N8, N12, N16}
		\end{axis}
		\end{tikzpicture}
	\end{minipage}
	\caption{Same as Figure 1 but better readable}
\end{figure}

\iffalse
\begin{figure}[!htb]
	\begin{minipage}[t]{0.5\textwidth}
		\begin{tikzpicture}
		\begin{axis}
		[
		%view={90}{0} for x, view={0}{0} for y restriction
		view={0}{0},
		xlabel = Branching factor,
		ylabel = perNodeCost,
		cycle list name = linestyles*,
		legend style={at={(0.25,1.25)}, anchor = north west},
		xtick = {4, 8, ..., 16},
		%xticklabels={$8$,$16$,$24$,$32$,$40$,$48$,$56$,$64$,$72$,$80$,$88$,$96$,$104$,$112$,$120$,$128$},
		]

%0.019372227533326004

		\addplot+[thick, mark=none]table[discard if not={leafSize}{4}, x = branchFactor, y = perNodeCost, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={leafSize}{8}, x = branchFactor, y = perNodeCost, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={leafSize}{12}, x = branchFactor, y = perNodeCost, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={leafSize}{16}, x = branchFactor, y = perNodeCost, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};

		\legend{L4, L8, L12, L16}
		\end{axis}
		\end{tikzpicture}
	\end{minipage}
	\begin{minipage}[t]{0.5\textwidth}
		\begin{tikzpicture}
		\begin{axis}
		[
		%view={90}{0} for x, view={0}{0} for y restriction
		view={0}{0},
		xlabel = Leaf size,
		ylabel = perLeafCost,
		cycle list name = linestyles*,
		legend style={at={(0.25,1.25)}, anchor = north west},
		xtick = {4, 8, ..., 16},
		%xticklabels={$8$,$16$,$24$,$32$,$40$,$48$,$56$,$64$,$72$,$80$,$88$,$96$,$104$,$112$,$120$,$128$},
		]

%0.033044329284923554

		%x expr = \thisrow{subdivision}
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{4} , x = leafSize, y = perLeafCost, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{8} , x = leafSize, y = perLeafCost, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{12}, x = leafSize, y = perLeafCost, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{16}, x = leafSize, y = perLeafCost, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};

		\legend{N4, N8, N12, N16}
		\end{axis}
		\end{tikzpicture}
	\end{minipage}
	\caption{As expected the }
\end{figure}

\begin{figure}[!htb]
	\begin{minipage}[t]{0.5\textwidth}
		\begin{tikzpicture}
		\begin{axis}
		[
		%view={90}{0} for x, view={0}{0} for y restriction
		view={0}{0},
		xlabel = Branching factor,
		ylabel = node Factor,
		legend style={at={(0.05,1.25)}, anchor = north west},
		xtick = {4, 8, ..., 16},
		%xticklabels={$8$,$16$,$24$,$32$,$40$,$48$,$56$,$64$,$72$,$80$,$88$,$96$,$104$,$112$,$120$,$128$},
		]
		\addplot+[thick, mark=none]table[discard if not={leafSize}{4}, x = branchFactor, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/breakfastTable.txt};
		\addplot+[thick, mark=none]table[discard if not={leafSize}{4}, x = branchFactor, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/galleryTable.txt};
		\addplot+[thick, mark=none]table[discard if not={leafSize}{4}, x = branchFactor, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={leafSize}{4}, x = branchFactor, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardExteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={leafSize}{4}, x = branchFactor, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardCombinedExteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={leafSize}{4}, x = branchFactor, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/sanMiguelTable.txt};

		\legend{Breakfast, Gallery}
		\end{axis}
		\end{tikzpicture}
	\end{minipage}
	\begin{minipage}[t]{0.5\textwidth}
		\begin{tikzpicture}
		\begin{axis}
		[
		%view={90}{0} for x, view={0}{0} for y restriction
		view={0}{0},
		xlabel = Leaf size,
		ylabel = node Factor,
		legend style={at={(0.05,1.25)}, anchor = north west},
		xtick = {4, 8, ..., 16},
		%xticklabels={$8$,$16$,$24$,$32$,$40$,$48$,$56$,$64$,$72$,$80$,$88$,$96$,$104$,$112$,$120$,$128$},
		]
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{4}, x = leafSize, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/breakfastTable.txt};
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{4}, x = leafSize, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/galleryTable.txt};
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{4}, x = leafSize, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{4}, x = leafSize, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardExteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{4}, x = leafSize, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardCombinedExteriorTable.txt};
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{4}, x = leafSize, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/sanMiguelTable.txt};

		\legend{Breakfast, Gallery}
		\end{axis}
		\end{tikzpicture}
	\end{minipage}
	\caption{Aabb and Triangle intersections}
\end{figure}

\begin{figure}[!htb]
	\begin{minipage}[t]{0.5\textwidth}
		\begin{tikzpicture}
		\begin{axis}
		[
		%view={90}{0} for x, view={0}{0} for y restriction
		view={0}{0},
		xlabel = Subdivisions,
		ylabel = node Factor,
		cycle list name = linestyles*,
		legend style={at={(0.05,1.4)}, anchor = north west},
		xtick = {4, 8, ..., 16},
		%xticklabels={$8$,$16$,$24$,$32$,$40$,$48$,$56$,$64$,$72$,$80$,$88$,$96$,$104$,$112$,$120$,$128$},
		]
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{4}, discard if not={leafSize}{4}, x = subdivision, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorSubTable.txt};
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{8}, discard if not={leafSize}{4}, x = subdivision, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorSubTable.txt};
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{12}, discard if not={leafSize}{4}, x = subdivision, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorSubTable.txt};
		\addplot+[thick, mark=none]table[discard if not={branchFactor}{16}, discard if not={leafSize}{4}, x = subdivision, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorSubTable.txt};

		\legend{N4L4, N8L4, N12L4, N16L4}
		\end{axis}
		\end{tikzpicture}
	\end{minipage}
	\begin{minipage}[t]{0.5\textwidth}
		\begin{tikzpicture}
		\begin{axis}
		[
		%view={90}{0} for x, view={0}{0} for y restriction
		view={0}{0},
		xlabel = Leaf size,
		ylabel = node Factor,
		cycle list name = linestyles*,
		legend style={at={(0.05,1.4)}, anchor = north west},
		xtick = {4, 8, ..., 16},
		%xticklabels={$8$,$16$,$24$,$32$,$40$,$48$,$56$,$64$,$72$,$80$,$88$,$96$,$104$,$112$,$120$,$128$},
		]
		%x expr = \thisrow{subdivision}
		\addplot+[thick, mark=none]table[discard if not={leafSize}{4}, discard if not={branchFactor}{4}, x = subdivision, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorSubTable.txt};
		\addplot+[thick, mark=none]table[discard if not={leafSize}{8}, discard if not={branchFactor}{4}, x = subdivision, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorSubTable.txt};
		\addplot+[thick, mark=none]table[discard if not={leafSize}{12}, discard if not={branchFactor}{4}, x = subdivision, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorSubTable.txt};
		\addplot+[thick, mark=none]table[discard if not={leafSize}{16}, discard if not={branchFactor}{4}, x = subdivision, y = sahNodeFactor, col sep=comma]{Data/NodeFactor/amazonLumberyardInteriorSubTable.txt};
		\legend{N4L4, N4L8, N4L12, N4L16}
		\end{axis}
		\end{tikzpicture}
	\end{minipage}
	\caption{Data of different subdivisions. There seems to be no significant difference to the node factor introduced by subdivision}
\end{figure}

\fi