% !TEX root =  paper.tex
\section{Experimental Results}

We evaluate our method by comparing it to a state-of-the-art pixel-based reconstruction approach using datasets from two different species.

\subsection{Datasets}
\label{sec:dataset}

\paragraph{Kasthuri.}
The Kasthuri dataset consists of scanning electron microscope images of the neocortex of a mouse brain~\cite{kasthuri2015saturated}. This dataset is $5342 \times 3618 \times 338$ voxels in size. The resolution of the dataset is $\SI[product-units=single]{3 x 3 x 30}{\nano\meter}^3$ per voxel. We evaluate our methods using the left cylinder of this 3-cylinder dataset. We downsample the dataset in the $x$ and $y$ dimensions to give a final resolution of $\SI[product-units=single]{6 x 6 x 30}{\nano\meter}^3$ per voxel. We divide the dataset into two volumes (Vol. 1 and Vol. 2) along the $x$ dimension, where each volume is $\SI[product-units=single]{8.0 x 10.9 x 10.1}{\micro\meter}^3$ or $1335 \times 1809 \times 338$ voxels.

\paragraph{FlyEM.}
The FlyEM dataset comes from the mushroom body of a 5-day old adult male \textit{Drosophila} fly imaged by a focused ion-beam milling scanning electron microscopy~\cite{takemura2017connectome}. The mushroom body in this species is the primary site of associative learning. The original dataset contains a $\SI[product-units=single]{40 x 50 x 120}{\micro\meter}^3$ volume with a resolution of $\SI[product-units=single]{10 x 10 x 10}{\nano\meter}^3$ per voxel. We use two cubes (Vol. 1 and Vol. 2) of size $\SI[product-units=single]{10 x 10 x 10}{\micro\meter}^3$ or $1000 \times 1000 \times 1000$ voxels.

\subsection{Pixel-Based Segmentations}
\label{sec:neuroproof}

The segmentation of the Kasthuri dataset was computed by agglomerating 3D supervoxels produced by the z-watershed algorithm from 3D affinity predictions~\cite{zlateski2015image}. A recent study by Funke et al.~\cite{schlegel2017learning} demonstrated superior performance of such methods over existing ones on anisotropic data. We learn 3D affinities using MALIS loss with a U-net~\cite{ronneberger2015u,Turaga:2009}. We apply the z-watershed algorithm with suitable parameters to compute a 3D oversegmentation of the volume. The resulting 3D oversegmentation is then agglomerated using the technique of context-aware delayed agglomeration to generate the final segmentation~\cite{10.1371/journal.pone.0125825}.

For the FlyEM data, based on the authors' suggestion~\cite{takemura2017connectome}, we applied a context-aware delayed agglomeration algorithm~\cite{10.1371/journal.pone.0125825} that shows improved performance on this dataset over the pipeline used in the original publication. This segmentation framework learns voxel and supervoxel classifiers with an emphasis to minimize under-segmentation error. At the same time this framework produces lower over-segmentation than standard algorithms. The algorithm first computes multi-channel 3-D predictions for membranes, cell interiors, and mitochondria, among other cell features. The membrane prediction channel is used to produce an over-segmented volume using 3D watershed, which is then agglomerated hierarchically up to a certain confidence threshold. We used exactly the same parameters as the publicly available code for this algorithm.

\subsection{Graph Pruning Parameters}

The two parameters for the graph pruning algorithm (Sec.~\ref{sec:skeletonization}) are $t_{low}$ and $t_{high}$. Ideally, the merge candidates output by this algorithm will contain all possible positive examples with a very limited number of negative examples. After considering various thresholds, we find that $t_{low} = \SI{240}{\nano\meter}$ and $t_{high} = \SI{600}{\nano\meter}$ produce the best results considering this objective.

In our implementation we use nanometers for these thresholds and not voxels. Connectomics datasets often have lower sample resolutions in $z$ because of limitations during sample preparation. Using nanometers allows us to have uniform units across all of these datasets and calculate the thresholds in voxels at runtime. For example, the thresholds in voxels are $t_{low} = (40, 40, 8)$ and $t_{high} = (100, 100, 20)$ for the anisotropic Kasthuri dataset and $t_{low} = (24, 24, 24)$ and $t_{high} = (60, 60, 60)$ for the isotropic FlyEM dataset.

%Table \ref{table:skeletonization} shows the overall success of our graph creation method with candidate pruning. \hp{not clear what this table is showing--explain. put this in the experiment section where you discuss the results}

\subsection{Classifier Training}
\label{sec:network-parameters}

We use the left cylinder of the Kasthuri dataset for training and validation. We train on 80\% of the potential merge candidates for this volume.
We validate the CNN classifier on the remaining 20\% of candidates. We apply data augmentation to the generated examples to increase the size of the training datasets. We consider all rotations of $90$ degrees along the $xy$-plane in addition to mirroring along the $x$ and $z$ axes. This produces 16 times more training data.

We consider networks with varying input sizes, optimizers, loss functions, filter sizes, learning rates, and activation functions. The supplemental material includes information on the experiments that determined these final parameters. Table~\ref{table:architecture} provides the parameters of the final network. There are 7,294,705 learnable parameters in our final architecture. All the parameters are randomly initialized following the Xavier uniform distribution~\cite{glorot2010understanding}. Training concluded after 34 epochs.

\begin{table}[h!]
	\centering
	\begin{tabular}{l l} \hline
		\textbf{Parameters} & \textbf{Values} \\ \hline
		Loss Function & Mean Squared Error \\
		Optimizer & SGD  with Nesterov Momentum \\
		Momentum & 0.9 \\
		Initial Learning Rate & 0.01 \\
		Decay Rate & $5 * 10^{-8}$ \\
		Activation & LeakyReLU $(\alpha = 0.001)$ \\
		Kernel Sizes & $3 \times 3 \times 3$ \\
		Filter Sizes & $16 \to 32 \to 64$ \\ \hline
	\end{tabular}
	\caption{Training parameters.}
	\label{table:architecture}
\end{table}

%\subsection{Graph-based Strategies}

%Applying a top-down globally optimal partitioning function allows us to enforce some domain-specific constraints on the reconstruction.
%In connectomics, we want to enforce the topological restrictions that each partition in the graph has a genus of zero.
%The greedy-additive heuristic solves the multicut graph partitioning problem by enforcing this constraint.
%Previous agglomeration strategies at the per-region level consider neighboring superpixels in order of merge probability.
%These superpixels are clustered hierarchically without concern for global constraints.
%We compare the benefits of a top-down partitioning function versus the traditional bottom-up clustering methods.


To produce predictions for the DCOs that are detectable with LISA, we use a synthesised population of DCOs, simulated using the methods described in Section~\ref{sec:COMPAS_explained}. In Section~\ref{sec:galaxy_synthesis} we describe our model for the Milky Way and how we place DCOs in randomly sampled Milky Way instances. We evolve the orbit of each DCO in a Milky Way instance up to the LISA mission and calculate the detection rate for that instance using the methods presented in Section~\ref{sec:gw_detection}.

\subsection{Binary population synthesis}\label{sec:COMPAS_explained}

We use the grid of \nModels{} binary population synthesis simulations recently presented in \citet{Broekgaarden+2021} and Broekgaarden et al.\ (in prep.). This grid of simulations is synthesised using the rapid population synthesis code \href{https://compas.science}{COMPAS} \citep{Stevenson+2017,Vigna-Gomez+2018,Stevenson+2019,Broekgaarden+2019}. COMPAS follows the approach of the population synthesis code BSE \citep{Hurley+2000,Hurley+2002} and uses fitting formula and rapid algorithms to efficiently predict the final fate of binary systems. The code is open source and documented in the papers listed above, the online documentation\footnote{\url{https://compas.science}} and in the methods paper \citep{COMPAS:2021methodsPaper}. We summarise the main assumptions and settings relevant for this work in Appendix~\ref{app:pop_synth}.

The result of the simulations is a sample of binaries, which, for each metallicity $Z$, have $N_{\rm binaries}$ binaries with parameters
\begin{equation}
    \mathbf{b}_{{Z, i}} = \{m_1, m_2, a_{\rm DCO}, e_{\rm DCO}, t_{\rm evolve}, t_{\rm inspiral}, w\},
\end{equation}
for $i = 1, 2, \dots, N_{\rm binaries}$, where $m_1$ and $m_2$ are the primary and secondary masses, $a_{\rm DCO}$ and $e_{\rm DCO}$ are the semi-major axis and eccentricity at the moment of double compact object (DCO) formation, $t_{\rm evolve}$ is the time between the binary's zero-age main sequence and DCO formation, $t_{\rm inspiral}$ is the time between DCO formation (that is, immediately after the second supernova in the system) and gravitational-wave merger and $w$ is the adaptive importance sampling weight assigned by STROOPWAFEL \cite[][Eq.~7]{Broekgaarden+2019}. We sample from these sets of parameters when creating synthetic galaxies.

\subsection{Galaxy synthesis}\label{sec:galaxy_synthesis}

In order to estimate a detection rate of DCOs with statistical uncertainties, we create a series of random instances of the Milky Way, each populated with a subsample drawn (with replacement) from the synthesised binaries described in Section~\ref{sec:COMPAS_explained}.

Most previous studies that predict a detection rate for LISA place binaries in the Milky Way independently of their age or evolution. We improve upon this as the first study to use an empirically-informed analytical model of the Milky Way that takes into account the galaxy's enrichment history by applying the metallicity-radius-time relation from \citet{Frankel+2018}. Those authors developed this relation in order to measure the global efficiency of radial migration in the Milky Way and calibrated it using a sample of red clump stars measured with APOGEE \citep{Majewski+2017}.

In Section~\ref{sec:mw_model}, we outline our model for the Milky Way and in Section~\ref{sec:combining_pop_gal} we explain how we combine our population of synthesised DCOs with this Milky Way model.

\subsubsection{Milky Way model}\label{sec:mw_model}

\begin{figure*}[t]
    \centering
    \includegraphics[width=\textwidth]{fig1_galaxy_diagram.png}
    \caption{A schematic illustrating how we model the Milky Way. The left panel illustrates the different model aspects: star formation history of three galactic components (individually shown in the dotted lines), radial distribution, metallicity-radius-time relation, and height distribution. The right panel shows an example instance of the Milky Way with $250000$ binaries shown as points coloured by metallicity. The top panel shows a side-on view and the bottom panel a face-on view. \href{https://github.com/TomWagg/detecting-DCOs-in-LISA/blob/main/paper/figures/fig1_galaxy_diagram.png}{\faFileImage} \href{https://github.com/TomWagg/detecting-DCOs-in-LISA/blob/main/paper/figure_notebooks/galaxy_creation_station.ipynb}{\faBook}.}
    \label{fig:galaxy_schematic}
\end{figure*}

Fig.~\ref{fig:galaxy_schematic} shows the distributions and relations outlined in this section and also displays an example random galaxy drawn using this model.

Our model for the Milky Way accounts for the low-\achem\footnote{Nomenclature used to describe the enhancement of $\alpha$ elements compared to iron in stellar atmospheres}~disc, high-\achem~disc and a central component approximating a bar/bulge. The low- and high-\achem~discs are often also referred to as the thin and thick discs because the stellar vertical distribution is better fit by a double exponential rather than a single one. However, this doesn't allow one to assign a star to either the thin or thick disk purely based on its height above the Galactic plane. Therefore, we instead use the chemical definition of the two disks (applying the \achem~nomenclature) as there is a clear bimodal distribution in the chemical plane, allowing stars to be assigned to each of the disc components based on their chemical abundances. For each of the three components, we use a separate star formation history and spatial distribution, which we combine into a single model, weighting each component by its present-day stellar mass. \citet{Licquia+2015} gives that the stellar mass of the bulge is $0.9 \times 10^{10} \unit{M_{\odot}}$ and the stellar mass of the disc is $5.2 \times 10^{10} \unit{M_\odot}$, which we split equally between the low- and high-\achem~discs \citep[e.g.,][]{Snaith+2014}.

\textit{Star formation history:}
We use an exponentially declining star formation history \citep{Frankel+2018} (inspired by the average cosmic star formation history) for the combined low- and high-\achem~discs,
\begin{equation}\label{eq:thin_disc_tau}
    p(\tau) \propto \exp \qty(-\frac{(\tau_m - \tau)}{\tau_{\rm SFR}}),
\end{equation}
where $\tau$ is the lookback time (the amount of time elapsed between the binary's zero-age main sequence and today), $\tau_m = 12 \unit{Gyr}$ is the assumed age of the Milky Way and $\tau_{\rm SFR} = 6.8 \unit{Gyr}$ is the star formation timescale \citep{Frankel+2018}. The two discs form stars in mutually exclusive time periods, such that the high-\achem~disc forms stars in the early history of the galaxy ($8$--$12 \unit{Gyr}$ ago) and the low-\achem~disc forms stars more recently ($0$--$8 \unit{Gyr}$ ago). Both distributions are normalised so that an equal amount of mass is formed in each of the two components over their respective star forming periods.

The star formation history of the Milky Way bulge (which we assume here to be dominated by the central bar) has many uncertainties due to the (1) sizeable age measurement uncertainties at large ages in observational studies, (2) complex selection processes affecting the observed age distributions, and (3) formation mechanisms that are still under debate. However, the central bar was shown to contain stars with an extended age range, with most observed stars between $6$ and $12 \unit{Gyr}$ with a younger tail of ages that could come from the subsequent secular growth of the Galactic bar \citep[e.g.,][]{Bovy+2019}. To model the bar's age distribution more realistically than in previous studies (which assume an old bulge coming from a single starburst), we choose to adopt a more extended star formation history using a $\beta(2,3)$ distribution, shifted and scaled such that stars are only formed in the range $[6, 12] \unit{Gyr}$. We show these distributions in the top left panel of Fig.~\ref{fig:galaxy_schematic}.

\textit{Radial distribution:} For each of the three components we employ the same single exponential distribution (but with different scale lengths)
\begin{equation}\label{eq:galaxy_R}
    p(R) = \exp(-\frac{R}{R_d}) \frac{R}{R_d^2},
\end{equation}
where $R$ is the Galactocentric radius and $R_d$ is the scale length of the component. For the low-\achem~disc, we set $R_d = R_{\rm exp}(\tau)$, where $R_{\rm exp}(\tau)$ is the scale length presented in \citet[][Eq.~6]{Frankel+2018}
\begin{equation}
    R_{\rm exp}(\tau) = 4 \unit{kpc} \qty(1 - \alpha_{R_{\rm exp}} \qty(\frac{\tau}{8 \unit{Gyr}})),
\end{equation}
where $\alpha_{R_{\rm exp}} = 0.3$ is the inside-out growth parameter\footnote{We find that $R_{\rm exp}(\tau) = 4$ kpc fits the data well and adopt this value rather than the 3 kpc quoted in \cite{Frankel+2018}, which was a fixed parameter (not a fit).}

This scale length accounts for the inside-out growth of the low-\achem~disc and hence is age dependent. We assume $R_d = (1 / 0.43) \unit{kpc}$ for the high-\achem~disc \citep[][Table~1]{Bovy+2016} and $R_d = 1.5 \unit{kpc}$ for the bar component \citep{Bovy+2019}. We show the combination of these distributions in the second panel on the left in Fig.~\ref{fig:galaxy_schematic}.

\textit{Vertical distribution}: Similar to the radial distribution, we use the same single exponential distribution (but with different scale heights) for each component, given by
\begin{equation}\label{eq:galaxy_z}
    p(\abs{z}) = \frac{1}{z_d} \exp\qty(-\frac{z}{z_d}),
\end{equation}
where $z$ is the vertical displacement above the Galactic plane and $z_d$ is the scale height. We set $z_d = 0.3 \unit{kpc}$ for the low-\achem~disc \citep{McMillan+2011} and $z_d = 0.95 \unit{kpc}$ for the high-\achem~disc \citep{Bovy+2016}. For the bar, we set $z_d = 0.2 \unit{kpc}$ \citep{Wegg+15}. We show the combination of these distributions in the bottom left panel of Fig.~\ref{fig:galaxy_schematic}.

\textit{Metallicity-radius-time relation:} To account for the chemical enrichment of star forming gas as the Milky Way evolves, we adopt the relation given by \citep[][Eq. 7]{Frankel+2018}
\begin{equation}\label{eq:galaxy_FeH}
    \begin{split}
        [{\rm Fe} / {\rm H}] (R, \tau) &= F_m + \nabla [{\rm Fe} / {\rm H}] R \\
        &- \qty(F_m + \nabla [{\rm Fe} / {\rm H}] R^{\rm now}_{[{\rm Fe} / {\rm H}] = 0} ) f(\tau),
    \end{split}
\end{equation}
where
\begin{equation}
    f(\tau) = \qty(1 - \frac{\tau}{\tau_m})^{\gamma_{[{\rm Fe} / {\rm H}]}},
\end{equation}
$F_m = -1 \unit{dex}$ is the metallicity of the gas at the center of the disc at $\tau = \tau_m$, $\nabla [{\rm Fe} / {\rm H}] = -0.075 \unit{kpc^{-1}}$ is the metallicity gradient, $R^{\rm now}_{[{\rm Fe} / {\rm H}] = 0} = 8.7 \unit{kpc}$ is the radius at which the present day metallicity is solar and $\gamma_{[{\rm Fe} / {\rm H}]} = 0.3$ sets the time dependence of the chemical enrichment. We convert this to the representation of metallicity that we use in this paper by applying \citep[e.g.][]{Bertelli+1994}
\begin{equation}\label{eq:galaxy_FeH_to_Z}
    \log_{10} (Z) = 0.977 [{\rm Fe} / {\rm H}] + \log_{10}(Z_\odot).
\end{equation}

Although \citet{Frankel+2018} only fit this model for the low-\achem~disc, we also use this metallicity-radius-time relation for the high-$\alpha$ disc and the bar, but focusing on the chemical tracks more representative to the inner disc and large ages. \citet{Sharma+2020} showed that using a simple continuous model for both the low- and high-\achem~discs, the Milky Way abundance distributions could be well reproduced. Empirically, the abundance tracks in the [$\alpha$/Fe]-[Fe/H] plane (and other elements) of the stars in the bulge/bar follow the same track as those of the old stars in the Solar neighbourhood \citep[][Fig.~7,]{Griffith+2021,Bovy+2019}, which motivates our modelling choice to use the same metallicity-radius-time relation.

\subsubsection{Combining population and galaxy synthesis}\label{sec:combining_pop_gal}

For each Milky Way instance, we randomly sample the following set of parameters
\begin{equation}
    \mathbf{g}_{{j}} = \{\tau, R, Z, z, \theta\}
\end{equation}
for $j = 1, 2, \dots, N_{\rm MW}$, where we set $N_{\rm MW} = 2 \times 10^{5}$, $\tau, R, Z$ and $z$ are defined and sampled using the distribution functions specified in Section~\ref{sec:mw_model}, $\theta$ is the azimuthal angle sampled uniformly on $[0, 2\pi)$ and $Z$ is the metallicity. Fig.~\ref{fig:galaxy_schematic} shows an example of a random Milky Way instance created with these distributions. This shows how these distributions translate to positions and illustrates the gradient in metallicity over radius.

We match each set of galaxy parameters $\mathbf{g}_{{j}}$, to a random set of binary parameters $\mathbf{b}_{{Z, i}}$, by drawing a binary from the closest metallicity bin to the metallicity in $\mathbf{g}_{{j}}$. If the metallicity in $\mathbf{g}_{{j}}$ is below the minimum COMPAS metallicity bin ($Z = 10^{-4}$), we use this minimum bin. If the metallicity in $\mathbf{g}_{{j}}$ is above the maximum COMPAS metallicity bin ($Z = 0.03$), we use a randomly selected bin from the five highest metallicity bins.

Each binary is likely to move from its birth orbit. Although all stars in the Galactic disc experience radial migration \citep{Sellwood+2002, Frankel+2018}, DCOs generally experience stronger dynamical evolution as a result of the effects of both Blaauw kicks \citep{Blaauw+1961} and natal kicks \citep[e.g.][]{Hobbs+2005}.

The magnitude of the systemic kicks are typically small compared to the initial circular velocity of a binary at each Galactocentric radius. Therefore, we expect that kicks will not significantly alter the overall distribution of their positions (see however, e.g., \citealt{Brandt+1995, Abbott+2017_GW170817_progenitor}). Given this, and for the sake of computational efficiency, we do not account for the displacement due to systemic kicks in our analysis.

\subsection{Gravitational wave detection}\label{sec:gw_detection}
We use the Python package \href{https://legwork.readthedocs.io/en/latest/}{LEGWORK} \citep{Wagg+2021} to evolve binaries and calculate their LISA detectability. For a full derivation of the equations given below see \citep[][Section~3]{Wagg+2021}, or the LEGWORK documentation \href{https://legwork.readthedocs.io/en/latest/notebooks/Derivations.html}{\faBook}.

\subsubsection{Inspiral evolution}

Each binary loses orbital energy to gravitational waves throughout its lifetime. This causes the binary to shrink and circularise over time. In order to assess the detectability of a binary, we need to know its eccentricity and frequency at the time of the LISA mission. For each binary in our simulated Milky Way, we know that the time from DCO formation to today is $\tau - t_{\rm evolve}$ and that the initial eccentricity and semi-major axis are $e_{\rm DCO}$ and $a_{\rm DCO}$. We find the eccentricity of the binary at the start of the LISA mission, $e_{\rm LISA}$, by numerically integrating its time derivative \citep[][Eq. 5.13]{Peters+1964} given the initial conditions. This can be converted to the semi-major axis at the start of LISA, $a_{\rm LISA} $\citep[][Eq. 5.11]{Peters+1964}, which in turn gives the orbital frequency, $f_{\rm orb, LISA}$, by Kepler's third law since we know the component masses.

\subsubsection{Binary detectability}

We define a binary as detectable if its gravitational wave signal has a signal-to-noise ratio (SNR) of greater than 7 \citep[e.g.][]{Breivik+2020, Korol+2020}. The sky-, polarisation- and orientation-averaged signal-to-noise ratio, $\rho$, of an inspiraling binary can be calculated with the following \citep[e.g.][]{Finn+2000}
\begin{equation}\label{eq:snr}
    \rho^2 = \sum_{n=1}^{\infty} \int_{f_{n, i}}^{f_{n, f}} \frac{h_{c, n}^{2}}{f_{n}^{2} S_{\rm n}\left(f_{n}\right)} \dd{f_n},
\end{equation}
where $n$ is a harmonic of the gravitational wave signal, $f_n = n \cdot f_{\rm orb}$ is the frequency of the $n^{\rm th}$ harmonic of the gravitational wave signal, $f_{\rm orb}$ is the orbital frequency, $S_{\rm n}(f_n)$ is the LISA sensitivity curve at frequency $f_n$ \citep[e.g.][]{Robson+2019} and $h_{c,n}$ is the characteristic strain of the $n^{\rm th}$ harmonic, given by \citep[e.g.][]{Barack+2004}
\begin{equation}\label{eq:charstrain}
    h^2_{c,n} = \frac{2^{5/3}}{3 \pi^{4/3}} \frac{(G \mathcal{M}_c)^{5/3}}{c^3 D_L^2} \frac{1}{f_{\rm orb}^{1/3}} \frac{g(n,e)}{n F(e)},
\end{equation}
where $D_L$ is the luminosity distance to the source, $f_{\rm orb}$ is the orbital frequency, $g(n, e)$ and $F(e)$ are given in \citet{Peters+1963} and $\mathcal{M}_c$ is the chirp mass, defined as
\begin{equation}\label{eq:chirp_mass}
    \mathcal{M}_c = \frac{(m_1 m_2)^{3/5}}{(m_1 + m_2)^{1/5}}.
\end{equation}

Note that increasing the length of the LISA mission allows more time for a DCO to evolve over the mission. Therefore the frequency limits in Eq.~\ref{eq:snr} are dictated by the LISA mission length. The SNR generally scales as $\sqrt{T_{\rm obs}}$ (with exceptions for sources very close to merging) and thus the SNR of a typical source in a 10-year LISA mission is approximately $1.58$ (=$\sqrt{10/4}$) times stronger than in a 4-year mission.

We use \href{https://legwork.readthedocs.io/en/latest/}{LEGWORK} \citep{Wagg+2021} to calculate the signal-to-noise ratio for each binary and the package ensures that enough harmonics are computed for each binary such that the error on the gravitational-wave luminosity remains below 1\%.

\subsubsection{Detection rate calculation}
For each physics variation model and DCO type, we first convert the COMPAS simulation results into a total number of DCOs in the Milky Way, $N_{\rm DCO}$. We do this by integrating the full mass and period distributions and stars and normalising to the total Milky Way mass. For more details see Appendix~\ref{app:rate_normalisation}.

We then determine the fraction of binaries that are detectable in each Milky Way instance by summing the adaptive importance sampling weights of the binaries that have an SNR greater than 7, and dividing by the total weights in the simulation. We multiply this fraction by $N_{\rm DCO}$ to find a detection rate (which we write as a total number of detections per LISA mission)
\begin{equation}
    N_{\rm detect} = \frac{\sum_{i = 0}^{N_{\rm MW}} w_i \phi(i)}{\sum_{i = 0}^{N_{\rm MW}} w_i} N_{\rm DCO},
\end{equation}
where $\phi(i) = 1$ if a binary is detectable and $0$ otherwise. We calculate the detection rate by Monte Carlo sampling 2500 Milky Way instances (each containing 200,000 DCOs) for each DCO type and every physics variation in order to obtain values for the uncertainty on the expected detection rate.


% !TEX root = ../00_thesis.tex

\section{Appendix -- MILP Formulation}
\label{appendix:single_mode}

\TODO{read carefully (will need to be adapted to the new sched synthesis) and potential merge with the tech report version}

This appendix presents the complete description of the ILP formulation, used to synthesize the schedule \sched{\mode{}} of a given operation mode \mode{}, \ie
\begin{align*}
&\sched{\mode{}} \; = \;
	\left\lbrace
	\begin{tabular}{c@{\quad}|@{\quad}l}
	$\tau.o, \, m.o, \, m.d$
	&
	$\app \in \mode{}, \;
	(\tau,m) \in \app.\predG$
	\\
	$r_k.t, \, r_k.[B]$
	&
	$k \in [1, \, R_{\mode{}}]$
	\end{tabular}
	\right\rbrace
\end{align*}

The system model is described in \cref{sec:model}. All the variables and parameters involved in the ILP formulation used to solve the single-mode schedule synthesis problem are listed at the end in Table~\ref{tab:ILPvar} for reference.
This appendix details all the formulated constraints and how they are implemented in practice. The last subsection details the formulation of the objective function used to minimize the end-to-end application latency.

%%1. Pseudo-code that shows how we guarantee that the number of rounds is minimized
%The schedule of a mode \mode{} is computed for one hyperperiod, after which it repeat itself.
%To minimize the number of rounds used, we solve the problem sequentially, as described in Alg.~\ref{alg:outerlayer}.
%Each ILP formulation considers a fixed number of rounds $R_{\mode{}}$ to be scheduled, starting with $R_{\mode{}}=0$. The number of rounds is incremented until a feasible solution is found, or until the maximum number of rounds $R_{max}$ -- the number of rounds that ``fit'' into one hyperperiod -- is reached.
%Thus, Alg.~\ref{alg:outerlayer} guarantees by construction that if the problem is feasible, the synthesized schedule is optimal in terms of number of rounds used.
%The end-to-end latency is minimized by setting the sum of all application's latency as objective function.
%
%
%\begin{algorithm}
%\begin{algorithmic}
%\small
%\Require
%	mode \mode{},
%	applications $\app \in \mode{}$,
%	task mappings $\tau.map$ and WCETs $\tau.e$,
%	round duration $\Tround$
%	\; -- \;
%\textbf{Output:}
%	\sched{M}
%
%\State $LCM \gets$ \textit{hyperperiod}(\mode{})
%%\State $R_{min} = 1$
%\State $R_{max} = floor(LCM/\Tround)$
%
%\State $R_{\mode{}} = 0$
%
%\While{$R_{\mode{}} \leq R_{max}$}
%	\State formulate the ILP for mode \mode{} using $R_{\mode{}}$ rounds
%%	ILP = \textit{pbmFormulation}( \mode{} , $R$ )
%	\State [ \sched{M}, \textit{feasible} ] = \textit{solve}( ILP )
%	\If {\textit{feasible}}
%		\Return \sched{M}
%	\EndIf
%	\State $R_{\mode{}} \gets R_{\mode{}}+1$
%\EndWhile
%\State \Return 'Problem unfeasible'
%\end{algorithmic}
%\caption{Pseudo-code of the schedule synthesis}
%\label{alg:outerlayer}
%\end{algorithm}

The ILP formulation to be solved by Alg.~\ref{alg:outerlayer} (see \cref{sec:model}) contains the following constraints, which can be classified into four categories.

\fakepar{1. Application constraints}
		\begin{description}
			\item[(C1.1)] Precedence constraints between tasks and messages must be respected.
			\item[(C1.2)] End-to-end deadlines must be satisfied.
		\end{description}

\fakepar{2. Round constraints}
		\begin{description}
			\item[(C2.1)] The rounds must not be overlapping.
			\item[(C2.2)] The time interval between two rounds is upper-bounded.
		\end{description}

\fakepar{3. Validity of the tasks mapping}
		\begin{description}
			\item[(C3)] The same node cannot process more than one task simultaneously.
		\end{description}

\fakepar{4. Validity of the messages allocation}
		\begin{description}
			\item[(C4.1)] Every message must be served
			after its release time.
			\item[(C4.2)] Every message must be served
			before its deadline.
			\item[(C4.3)] A round cannot be allocated more messages than the number of slots available in one round.
			\item[(C4.4)] Within one hyperperiod, the same number of messages are released and served.
		\end{description}

The validity of the message allocation constraints, in particular constraints \textbf{(C4.1)} and \textbf{(C4.2)}, induce a non-linear coupling between the message and round variables. This peculiar aspect makes the scheduling problem non-trivial and prevents the use of conventional ILP-based schedule synthesis approaches reported thus far in the literature.
Our approach to solve this problem is detailed in \cref{sec:message_alloc}.

\subsection*{Application constraints}\label{sec;application}
\begin{description}
	\item[(C1.1)]Precedence constraints between tasks and messages must be respected.
\end{description}
For any application \app, let $\app.c$ be a \emph{chain} in \app.\predG. A chain is a path of \app.\predG starting and ending with a task without predecessor and successor, respectively. $\app.c(\,\first\,)$ and $\app.c(\,\last\,)$ denote the first and last task of the chain \app.c.  $\sigma_{i,j}$ is a binary variable accounting for the cases where successive task $\tau_i$ and message $m_j$ (resp. a message $m_i$ and task $\tau_j$) start during different application period ($\sigma_{i,j} = 1$) or not ($\sigma_{i,j} = 0$)
\begin{align}
\intertext{%
$	\forall\, \app, \;
	\forall\, \app.c \in \app.\predG, \;
	\forall\, \tau_j \in (\app.c \setminus \app.c(\,\last)),\;
	\forall\, m_i \in \tau_j.prec,
	$}
		m_i.o + m_i.d
		&\;\leq\; \app.p * \sigma_{i,j} + \tau_j.o\\
\intertext{%
$	\forall\, \app, \;
	\forall\, \app.c \in \app.\predG, \;
	\forall\, m_j \in \app.c,\;
	\forall\, \tau_i \in m_j.prec,
	$}
		\tau_i.o + \tau_i.e
		&\;\leq\; \app.p * \sigma_{i,j} + m_j.o
\end{align}

\begin{description}
	\item[(C1.2)] End-to-end deadlines must be satisfied.
\end{description}
\begin{align}
\intertext{%
$	\forall\, \app, \;
	\forall\, \app.c \in \app.\predG, \;
		\tau_{\first} = \app.c(\,\first\,), \;
		\tau_{\last} = \app.c(\,\last\,), \;
		C = |\app.c|, $}
& \tau_{\last}.o + \tau_{\last}.e - \tau_{\first}.o + \sum_{j=1}^{C-1} \app.p*\sigma_{i,j}  \;\leq\; \app.d
\end{align}

\subsection*{Round constraints}\label{sec:rounds}
\begin{description}
	\item[(C2.1)]The rounds must not be overlapping.
\end{description}
\begin{flalign}
&\forall j \in [1..R_{\mode{}}-1],
& & r_j.t + \Tround \; \leq \; r_{j+1}.t
&
\end{flalign}

\begin{description}
	\item[(C2.2)]The time interval between two rounds is upper-bounded.
\end{description}
%\begin{align}
%\intertext{%
%$	\forall j \in [1..R_{\mode{}}-1],$}
%&r_{j+1}.t - r_j.t  \; \leq \;  T_{max}
%\end{align}
\begin{flalign}
&\forall j \in [1..R_{\mode{}}-1],
&
&r_{j+1}.t - r_j.t  \; \leq \;  T_{max}
&
&
\end{flalign}

\subsection*{Validity of the task mappings}\label{sec:task_mapping}
\begin{description}
	\item[(C3)]The same node cannot process more than one task simultaneously.
\end{description}
\begin{align}
\intertext{%
$	\forall\, \tau_i, \tau_j, \; \tau_i.map == \tau_j.map, \;
	\forall\, k_i \in [1..LCM/\tau_i.p], \; \forall\, k_j \in [1..LCM/\tau_j.p]$}
\label{eq:t1beforet2}
&	\tau_i.o + \tau_i.e + \tau_i.p*k_i \; \leq \; \tau_j.o + \tau_j.p*k_j \\
\label{eq:t2beforet1}
\texttt{or} \quad
&	\tau_j.o + \tau_j.e + \tau_j.p*k_j \; \leq \; \tau_i.o + \tau_i.p*k_i
\end{align}
%
However, an ILP formulation cannot directly support that only one-out-of-two constraints must be satisfied. To resolve this, we use a classical trick using $(i)$ a binary variable $\lambda$ representing which of the two constraints \eqref{eq:t1beforet2} or \eqref{eq:t2beforet1} must be enforced and $(ii)$ a ``big'' time constant $M$, used to satisfied the other constraint by default, \ie regardless of the values of the variables. For example, $M = 10*LCM$.
%
\begin{align}
\label{eq:t1beforet2_impl}
\tau_i.o + \tau_i.e + \tau_i.p*k_i
	&\; \leq \; \tau_j.o + \tau_j.p*k_j + M\!M * (1 - \lambda_{i,j}^{k_i,k_j}) \\
\label{eq:t2beforet1_impl}
\tau_j.o + \tau_j.e + \tau_j.p*k_j
	&\; \leq \; \tau_i.o + \tau_i.p*k_i + M\!M * \lambda_{i,j}^{k_i,k_j}
\end{align}
%
With this implementation of the constraints, it follows that
%
\begin{align*}
&	\lambda_{i,j}^{k_i,k_j} = 1
	\quad \Leftrightarrow \quad
		\eqref{eq:t1beforet2_impl} \equiv \eqref{eq:t1beforet2}
%		\; and \;
		\;\wedge\;
		\eqref{eq:t2beforet1_impl} \text{ is always satisfied.}
		\\
&	\lambda_{i,j}^{k_i,k_j} = 0
	\quad \Leftrightarrow \quad
		\eqref{eq:t2beforet1_impl} \equiv \eqref{eq:t2beforet1}
% 		\; and \;
		\;\wedge\;
		\eqref{eq:t1beforet2_impl} \text{ is always satisfied.}
\end{align*}

\subsection*{Validity of the messages allocation}\label{sec:message_alloc}

As mentioned earlier, the validity of the message allocation constraints, in particular constraints \textbf{(C4.1)} and \textbf{(C4.2)}, induce a non-linear coupling between the message and round variables. This peculiar aspect makes the scheduling problem non-trivial and prevents the use of conventional ILP-based schedule synthesis approaches reported thus far in the literature.
The following subsection repeats and deepens the arguments from \cref{sec:single_mode}.

%-> Formulate constraints based on Network Calculus: arrival, service and demand functions
To address problem of variable coupling, we first formulate the constraints \textbf{(C4.1)} and \textbf{(C4.2)} using \emph{arrival}, \emph{demand}, and \emph{service} functions, \af \df and \sf, using network calculus%
%~\cite{leboudec2001network}
. Those functions count the number of message instances released, served, and due since the beginning of the hyperperiod, respectively.
Those three functions are illustrated in \cref{fig:afdfsf2}.
It must hold that
\begin{flalign}
\label{eq:df<sf<af2}
&\forall\, m_i \in \messageset, \;\forall\, t,
&&\df_i(t) \leq \sf_i(t) \leq \af_i(t)
&&\\
\label{eq:af_def2}
&\text{with},
&&\af_i: \; t \;
	\longmapsto \; \left \lfloor{\frac{t-m_i.o}{m_i.p}}\right \rfloor 	+ 1
	&&\\
\label{eq:df_def2}
&\text{and},
&&\df_i: \; t \;
	\longmapsto \; \left \lceil{\frac{t-m_i.o-m_i.d}{m_i.p}}\right \rceil
	&&
\end{flalign}

\noindent
%-> Adapt them to the use of rounds
%In general, one must verify that \eqref{eq:df<sf<af} holds true for all time.
However, as the service function stays constant between the rounds, we can formulate \textbf{(C4.1)} and \textbf{(C4.2)} as follows\\
$\forall\, m_i \in \messageset, \; \forall\, j \in [1 .. R_{\mode{}}], $
\begin{flalign}
\label{eq:af_const2}
&\textbf{(C4.1)}  : \quad
	&\sf_i(r_j.t + \Tround) \, &\leq \, \af_i(r_j.t)&&
\\
\label{eq:df_const2}
&\textbf{(C4.2)}  : \quad
	&\sf_i(r_j.t)  \, &\geq \, \df_i(r_j.t + \Tround)&&
\end{flalign}

\begin{figure}
\centering
\includegraphics[scale=1]{afdfsf}
\caption{Representation of arrival, demand, and service functions of message $m_i$.
The lower part shows the five round, $r_1$ to $r_5$, scheduled for the hyperperiod.
\capt{%
$m_i$ is allocated a slot in the colored rounds, \ie $r_1$, $r_2$, and $r_4$.
The allocation of $m_i$ to $r_3$ instead of $r_2$ would be invalid, as $r_3$ does not finish before the message deadline, \ie it violates \textbf{(C4.2)}.
However, the allocation of $m_i$ to $r_5$ instead of $r_1$ would be valid and result in $r_0.B_i = 0$.}
}
\label{fig:afdfsf2}
\end{figure}

%-> Introduce integer variables constrained to match the values of \af and \df at time points of interest
\noindent
The arrival and demand functions are step functions. They cannot be used directly in an ILP formulation, however
\begin{flalign}
\label{eq:af=k2}
&\forall \; k \in \mathbb{N}, \quad
&&\af_i(t) = k
	\quad \Leftrightarrow \quad
	0 \, \leq \, t - m_i.o - (k-1)m_i.p \,<\, m_i.p &&\\
&\text{and} %\hspace{30pt}
&&\df_i(t) = k
\label{eq:df=k2}
	\quad \Leftrightarrow \quad
	0 \, < \, t - m_i.o - m_i.d - (k-1)m_i.p \,\leq\, m_i.p &&
\end{flalign}
% We introduce a set of integer variable k^a_{ij} k^d such that
For each message $m_i\in \messageset$ and each round $r_j$, $j \in [1..R_{\mode{}}]$, we introduce two integer variables $k^a_{ij}$ and $k^d_{ij}$ that we constraint to take the values of \af and \df at the time points of interest, \ie $r_j.t$ and $r_j.t + \Tround$ respectively. That is,
\begin{align}
\label{eq:ka2} %\qquad
0 \, \leq \, r_j.t
	&-m_i.o - (k^a_{ij}-1)m_i.p \,<\, m_i.p\\
\label{eq:kd2} %\qquad
0 \, < \, r_j.t
	&+\Tround - m_i.o - m_i.d - (k^d_{ij}-1)m_i.p \,\leq\, m_i.p\\
\notag
\text{Thus,} \hspace{15pt} &\eqref{eq:ka2} \quad \Leftrightarrow  \quad
	 \af_i(r_j.t) = k^a_{ij} \\
\notag
	&\eqref{eq:kd2} \quad \Leftrightarrow \quad
	\df_i(r_j.t + \Tround) = k^d_{ij}
\end{align}

%
%-> Express \sf based on the rounds

\TODO{Here might be the place to say something about the round atomicity...}
Finally, we must express the service function \sf, which counts the number of message instances served \emph{at the end} of each round.
Remember that $r_k.B_s$ denotes the allocation of the $s$-{th} slot of $r_k$.
For any time $t \in \; [ \; r_{j} + \Tround \, ; \,  r_{j+1} + \Tround \; [$, the number of instances of message $m_i$ served is
\begin{align*}
	\sum_{\substack{k = 1}}^{j}
	\sum_{\substack{s = 1}}^{B}
	 \; r_k.B_s
	 \quad s.t. \; B_s = i
\end{align*}

\noindent
It may be that $m.o + m.d > m.p$, resulting in $\df(0)=-1$ (see \eqref{eq:df_def2}), like \eg in \cref{fig:afdfsf2}. This ``means'' that a message released at the each of one hyperperiod will have its deadline in the \emph{next} hyperperiod.
To consider this situation, we introduce, for each message $m_i$, a variable $r_0.B_i$ set to the number of such ``leftover'' message instances at $t=0$.
The system model makes the assumption that $\app.d \leq \app.p$. As $m.p = \app.p$, $m.o \leq m.p$ and $m.d < \app.d$, then $m.o + m.d < 2*m.p$. Thus, there can be only one or zero of such leftover message instances, \ie $r_0.B_i \in \{0\,,\,1\}$.
Finally, for each message $m_i \in \messageset$, and  $t \in \; [ \; r_{j} + \Tround \, ; \,  r_{j+1} + \Tround \; [$,
%
%However, it may be that the last message released during one hyperperiod has its relative deadline in the \emph{next} hyperperiod, thus yielding $df(0)=-1$. It is the case \eg in \cref{fig:afdfsf}. Then, to account for this previously arrived message -- possibly not yet served -- we introduce for each message $m_i$ a variable $r_0.B_i$ set to the value of the service function $sf_i$ of message $m_i$ at $t=0$, that is $0$ or $1$. Thus finally, for each message $m_i \in \messageset$, and  $t \in \; [ \; r_{j} + \Tround \, ; \,  r_{j+1} + \Tround \; [$,
\begin{flalign}
\label{eq:sf_def2}
\sf_i: \; t \;
	&\longmapsto \;
	\sum_{\substack{k = 1 \\[2pt]s.t. \; r_k + \Tround \, < \, t}}^{j}\;\;
	\sum_{\substack{s = 1 \\[2pt]s.t. \; B_s = i}}^{B}
	 r_k.B_s - r_0.B_i
\end{flalign}

\noindent
Ultimately, \textbf{(C4.1)} and \textbf{(C4.2)} can be formulated as ILP constraints using the following four equations:
\begin{flalign}
\notag
\forall\, m_i \in \messageset, \; \forall\, j\in [1..R],
&&&\eqref{eq:ka2}\quad \;	 : \;
	\quad
	0 \, \leq \, r_j.t - m_i.o - (k^a_{ij}-1)*m_i.p \,<\, m_i.p
&&\\
\notag
&&&\eqref{eq:kd2}\quad	\; : \;
	\quad
	0 \, \leq \, r_j.t + \Tround - m_i.o - m_i.d - (k^d_{ij}-1)*m_i.p \,<\, m_i.p
&&\\
&&&\eqref{eq:af_const2}\quad	 \Leftrightarrow
	\quad
	\sum_{k = 1}^j
	\sum_{\substack{s = 1 \\[2pt]s.t. \; B_s = i}}^{B}
	 \; r_k.B_s - r_0.B_i \; \leq\;  k^a_{ij}
&&\\
&&&\eqref{eq:df_const2}\quad	 \Leftrightarrow
	\quad
	\sum_{k = 1}^{j-1}
	\sum_{\substack{s = 1 \\[2pt]s.t. \; B_s = i}}^{B} \; r_k.B_s - r_0.B_i
	\; \geq\;
	k^d_{ij}
&&
\end{flalign}

To implement those constraints in practice, some slight modifications are still required. We use Gurobi to solve the ILP problem. This solver does not allow to model strict inequalities, \ie $A \cdot x  < B$. Therefore, to implement the right-hand side of the constraints \eqref{eq:ka} and \eqref{eq:kd2}, we need to use a ``small'' time constant $mm$.
%
Furthermore,
%
This leads to the following implementation.

\begin{description}
	\item[(C4.1)]Every message must be served after its release time.
\end{description}
\begin{flalign}
&\forall\, m_i\in \messageset, \; \forall\, j\in [1..R_{\mode{}}],
\label{eq:serveAfterArrival}
&	&0  \; \leq \; r_j.t - m_i.o - (k^a_{ij}-1)*m_i.p
		\; \leq \; m_i.p - mm
&		\\
&
&	&\sum_{k = 1}^{j}
	\sum_{\substack{s = 1 \\[2pt]s.t. \; B_s = i}}^{B} \; r_k.B_s - r_0.B_i
	\; \geq\;
	k^d_{ij}
&
\intertext{%
\begin{description}
	\item[(C4.2)]Every message must be served before its deadline.
\end{description}
}
&\forall\, m_i\in \messageset, \; \forall\, j\in [1..R_{\mode{}}],
&	&mm  \; \leq \; r_j.t + \Tround - m_i.o - m_i.d - (k^d_{ij}-1)*m_i.p
		\; \leq \; m_i.p
&		\\
&
&	&\sum_{k = 1}^{j-1}
	\sum_{\substack{s = 1 \\[2pt]s.t. \; B_s = i}}^{B} \; r_k.B_s - r_0.B_i
	\; \geq\;
	k^d_{ij}
&
\end{flalign}

Finally, the formulation of the last two constraints -- \textbf{(C4.3)} and \textbf{(C4.4)} -- is rather straightforward.

\begin{description}
	\item[(C4.3)]A round cannot be allocated more messages than the number of slots available in one round.
\end{description}
%
\begin{align*}
\text{Satisfied by construction.}
\end{align*}

\begin{description}
	\item[(C4.4)] Within one hyperperiod, the same number of messages are released and served.
\end{description}
\begin{flalign}
&\forall\, m_i\in \messageset,
&
	&\sum_{k = 1}^{R_{\mode{}}}
	\sum_{\substack{s = 1 \\[2pt]s.t. \; B_s = i}}^{B} \; r_k.B_s
	\; = \; LCM/m_i.p
&&
\end{flalign}

\subsection*{Objective function}

To obtain a valid schedule, the ILP solver does not \emph{need} to optimize any objective function. The primer objective is to minimize of the number of rounds $R_{\mode{}}$ used in the schedule, which is achieved by incrementally increasing the number of rounds (see Algorithm~\ref{alg:outerlayer}) until a valid schedule is found.

However, from the application perspective, it is of importance to \emph{minimize the end-to-end latency} of concurrently running applications. Therefore, we formulate as an objective function, denoted \obj, the sum of all application latency, which we want to minimize. If we denote the latency of application \app by $\app.\delta$ and the latency of the chain $\app.c$ by $\app.c.\delta$,
\begin{align}
\intertext{%
$	\forall\, \app, \;
	\forall\, \app.c \in \app.\predG, \;
		\tau_{\first} = \app.c(\,\first\,), \;
		\tau_{\last} = \app.c(\,\last\,), \;
		C = |\app.c|, $}
\app.c.\delta \; & = \;
%	\max
%		\left(
			\tau_{\last}.o + \tau_{\last}.e - \tau_{\first}.o + \sum_{j=1}^{C-1} \app.p*				\sigma_{i,j}
%		\right)
\\
 \app.\delta \; &= \;
	\max_{\app.c \,\in\, \app.\predG}
		\left(
			\;
			\app.c.\delta
			\;
		\right)
\intertext{%
And finally,}
\obj \; &= \; \sum_{\app \,\in\, \text{mode }\mode{}} \;
	\app.\delta
\end{align}

\begin{table}[h]
\centering
\small
\caption{Complete list of variables used in the ILP formulation.}
\label{tab:ILPvar}
\input{\ChapPath/Tables/table_ILPvar.txt}
\end{table}


% !TEX root=../pldi2019.tex

\appendix
\section{Appendix}

  \subsection{Rules}

    \begin{mathpar}
      \boxed{\RelationT} \\
      \userule{T-Var} \quad
      \userule{T-Loc} \\
      \userule{T-Abs} \quad
      \userule{T-App} \\
      \userule{T-If} \\
      \userule{T-Pair} \\
      \userule{T-Ref} \quad
      \userule{T-Deref} \\\
      \userule{T-Assign}
    \end{mathpar}

    \begin{mathpar}
      \boxed{\RelationE} \\
      \userule{E-Value} \\
      \userule{E-App} \\
      \userule{E-IfTrue} \\
      \userule{E-IfFalse} \\
      \userule{E-Pair} \\
      \userule{E-Ref} \quad
      \userule{E-Deref} \\
      \userule{E-Assign}
    \end{mathpar}

  \subsection{Proofs}

  \subsubsection{Theorem~\ref{thm:pres-eval}}
\begin{proof}
  We prove Theorem~\ref{thm:pres-eval} by induction on $e$:\\

  \noindent\textbf{Case} $e=\lambda x:\tau.e, e_1 e_2, x, c, l, e_1 \star e_2,
      \If{e_1}{e_2}{e_3},$\\
      $\tuple{e_1, e_2},\unit,\Ref e,!e,e_1 := e_2$ preservation has
      been proven for these cases by \todo{insert cite}\\

  \noindent\textbf{Case} $\userule{E-Edit}$
      Given that $\Gamma,\Sigma\infers\Edit e:\Task \tau$ and $\Sigma\infers s$,
      \refrule{T-Edit} gives us that $\Gamma,\Sigma\infers e:\tau$. The induction
      hypothesis gives us that $e,s\evaluate v,s'$ also preserves, and thus
      $\Gamma,\Sigma\infers v:\tau$ and $\Sigma\infers s'$. Therefore
      $\Gamma,\Sigma\infers\Edit v:\Task\tau$.\\

  \noindent\textbf{Case} $\userule{E-Enter}$
      Evaluation does not alter $e$ and $s$, therefore this case holds tivially.\\

  \noindent\textbf{Case} $\userule{E-Update}$
      Given that $\Gamma,\Sigma\infers \Edit e:\Task \tau$ and
      $\Sigma\infers s$, \refrule{T-Update} gives us that $\Gamma,\Sigma\infers e:\Ref \tau$.
      The induction hypothesis gives us that $e,s\evaluate l,s'$ also preserves,
      and thus $\Gamma,\Sigma\infers l:\Ref\tau$ and $\Sigma\infers s'$.
      Therefore $\Gamma,\Sigma\infers\Update l:\Task\tau$\\

  \noindent\textbf{Case} $\userule{E-Fail}$
      Evaluation does not alter $e$ and $s$, therefore this case holds tivially.\\

  \noindent\textbf{Case} $\userule{E-Then}$
      Given that $\Gamma,\Sigma\infers e_1\Then e_2:\Task \tau$ and
      $\Sigma\infers s$, \refrule{T-Then} gives us that
      $\Gamma,\Sigma\infers e_1:\Task\tau_1$ and
      $\Gamma,\Sigma\infers e_2:\tau_1 \to \Task \tau$. By the induction
      hypothesis, we know that $e_1,s\evaluate t_1,s'$ preserves and thus
      $\Gamma,\Sigma\infers t_1:\Task\tau_1$ and $\Sigma\infers s'$. Therefore
      $\Gamma,\Sigma\infers t_1\Then e_2:\Task\tau$.\\

  \noindent\textbf{Case} $\userule{E-Next}$
      Given that $\Gamma,\Sigma\infers e_1\Next e_2:\Task \tau$ and
      $\Sigma\infers s$, \refrule{T-Next} gives us that
      $\Gamma,\Sigma\infers e_1:\Task\tau_1$ and
      $\Gamma,\Sigma\infers e_2:\tau_1 \to \Task \tau$. By the induction
      hypothesis, we know that $e_1,s\evaluate t_1,s'$ preserves and thus
      $\Gamma,\Sigma\infers t_1:\Task\tau_1$ and $\Sigma\infers s'$. Therefore
      $\Gamma,\Sigma\infers t_1\Next e_2:\Task\tau$.\\

  \noindent\textbf{Case} $\userule{E-And}$
      Given that $\Gamma,\Sigma\infers e_1\And e_2:\Task(\tau_1\times\tau_2)$
      and $\Sigma\infers s$, \refrule{T-And} gives us that
      $\Gamma,\Sigma\infers e_1:\Task\tau_1$ and
      $\Gamma,\Sigma\infers e_2:\Task\tau_2$. By the induction hypothesis, we
      know that both $e_1,s\evaluate t_1,s'$ and $e_2,s'\evaluate t_2,s''$
      preserve and thus $\Gamma,\Sigma\infers t_1:\Task\tau_1$,
      $\Sigma\infers s'$, $\Gamma,\Sigma\infers t_2:\Task\tau_2$ and
      $\Sigma\infers s''$. Therfore
      $\Gamma,\Sigma\infers t_1\And t_2:\Task(\tau_1\times\tau_2)$\\

  \noindent\textbf{Case} $\userule{E-Or}$
      Given that $\Gamma,\Sigma\infers e_1\Or e_2:\Task\tau$ and $\Sigma\infers s$, \refrule{T-Or} gives us that $\Gamma,\Sigma\infers e_1:\Task\tau$ and
      $\Gamma,\Sigma\infers e_2:\Task\tau$. By the induction hypothesis, we have that both
      $e_1,s\evaluate t_1,s'$ and $e_2,s'\evaluate t_2,s''$ preserve and thus $\Gamma,\Sigma\infers t_1:\Task\tau$, $\Sigma\infers s'$,
      $\Gamma,\Sigma\infers t_2:\Task\tau$ and $\Sigma\infers s''$. Therefore $\Gamma,\Sigma\infers t_1\Or t_2:\Task\tau$.\\

  \noindent\textbf{Case} $\userule{E-Xor}$
      Evaluation does not alter $e$ and $s$, therefore this case holds tivially.\\

  \noindent\textbf{Case} $\userule{E-Appoint}$
      Given that $\Gamma,\Sigma\infers u \At e:\Task\tau$ and $\Sigma\infers s$, the induction hypothesis gives us that $e,s\evaluate t,s'$ also preserves, and therefore by \refrule{T-Appoint} $\Gamma,\Sigma\infers u \At t:\Task\tau$.
\end{proof}

\subsubsection{Lemma~\ref{lem:presvalue}}
\begin{proof}
  We prove Lemma~\ref{lem:presvalue} by induction over $e$.\\

  \noindent\textbf{Case} $\Value{(\Edit v,s)}=v$ By T-Edit, if
  $\Gamma,\Sigma\infers \Edit v:\Task\tau$, then $\Gamma,\Sigma\infers v:\tau$.\\

  \noindent\textbf{Case} $\Value{(\Enter \tau,s)}=\bot$ Since this case does not
  lead to a value, the lemma holds trivially.\\

  \noindent\textbf{Case} $\Value{(\Update l,s)}=s(l)$ Given that
  $\Gamma,\Sigma\infers\Update l:\Task \tau$ and $\Sigma\infers s$, we know that
  $\Gamma,\Sigma\infers s(l):\tau$ by definiton.\\

  \noindent\textbf{Case} $\Value{(\Fail,s)}=\bot$ Since this case does not lead
  to a value, the lemma holds trivially.\\

  \noindent\textbf{Case} $\Value{(t_1\Then e_2,s)}=\bot$ Since this case does
  not lead to a value, the lemma holds trivially.\\

  \noindent\textbf{Case} $\Value{(t_2\Next e_2,s)}=\bot$ Since this case does
  not lead to a value, the lemma holds trivially.\\

  \noindent\textbf{Case} $\Value{(t_1\And t_2,s)}=\tuple{v_1, v_2}$ given that
  $\Value{(t_1,s)}=v_1\wedge\Value{(t_2,s)}=v_2$\\ By \refrule{T-And} we have that
  $\Gamma,\Sigma\infers t_1\And t_2:\Task(\tau_1\times\tau_2)$ and
  $\Gamma,\Sigma\infers t_1:\tau_1$ and $\Gamma,\Sigma\infers t_2:\tau_2$. By the
  induction hypothesis, $ \Value{(t_1,s)}=v_1$ and $\Value{(t_2,s)}=v_2$ preserve,
  and thus $\Gamma,\Sigma\infers v_1:\tau_1$ and $\Gamma,\Sigma\infers v_2:\tau_2$.
  This gives us that $\Gamma,\Sigma\infers \tuple{v_1, v_2}:\Task(\tau_1\times\tau_2)$ \\

  \noindent\textbf{Case} $\Value{(t_1\And t_2,s)}=\bot$ given that
  $\neg(\Value{(t_1,s)}=v_1\wedge\Value{(t_2,s)}=v_2)$\\ Since this case does
  not lead to a value, the lemma holds trivially.\\

  \noindent\textbf{Case} $\Value{(t_1\Or t_2,s)}=v_1$ given that
  $\Value{(t_1,s)}=v_1$\\
  By \refrule{T-Or} we have that $\Gamma,\Sigma\infers t_1\Or t_2:\Task\tau$,
  and $\Gamma,\Sigma\infers t_1:\Task\tau$ and
  $\Gamma,\Sigma\infers t_2:\Task\tau$. By the induction hypothesis, we have
  that $\Gamma,\Sigma\infers v_1:\tau$.\\

  \noindent\textbf{Case} $\Value{(t_1\Or t_2,s)}=v_2$ given that
  $\Value{(t_1,s)}=\bot\wedge\Value{(t_2,s)}=v_2$\\
  By \refrule{T-Or} we have that $\Gamma,\Sigma\infers t_1\Or t_2:\Task\tau$,
  and $\Gamma,\Sigma\infers t_1:\Task\tau$ and
  $\Gamma,\Sigma\infers t_2:\Task\tau$. By the induction hypothesis, we have
  that $\Gamma,\Sigma\infers v_2:\tau$.\\

  \noindent\textbf{Case} $\Value{(t_1\Or t_2,s)}=\bot$ given that
  $\Value{(t_1,s)}=\bot\wedge\Value{(t_2,s)}=\bot$\\ Since this case does not
  lead to a value, the lemma holds trivially.\\

  \noindent\textbf{Case} $\Value{(t_1\Xor t_2,s)}=\bot$ Since this case does not
  lead to a value, the lemma holds trivially.\\

  \noindent\textbf{Case} $\Value{(u\At t,s)}=\Value(t,s)$ This case follows
  directly from the induction hypothesis.\\
\end{proof}

\subsubsection{Theorem~\ref{thm:pres-stride}}
\begin{proof}
  We prove Theorem~\ref{thm:pres-stride} by induction on $e$:\\

  \noindent\textbf{Case} $\userule{S-Fail}$ Since this case does not alter the
  expression, the theorem holds trivially.\\

  \noindent\textbf{Case} $\userule{S-Xor}$ Since this case does not alter the
  expression, the theorem holds trivially.\\

  \noindent\textbf{Case} $\userule{S-Update}$ Since this case does not alter
  the expression, the theorem holds trivially.\\

  \noindent\textbf{Case} $\userule{S-Fill}$ Since this case does not alter the
  expression, the theorem holds trivially.\\

  \noindent\textbf{Case} $\userule{S-Edit}$ Since this case does not alter the
  expression, the theorem holds trivially.\\

  \noindent\textbf{Case} $\userule{S-And}$ Given that
  $\Gamma,\Sigma\infers t_1\And t_2:\Task(\tau_1\times\tau_2)$, by
  \refrule{T-And we} have $\Gamma,\Sigma\infers t_1:\tau_1$ and
  $\Gamma,\Sigma\infers t_2:\tau_2$. By the induction hypothesis, we also have $\Gamma,\Sigma\infers t_1':\tau_1$ and $\Gamma,\Sigma\infers t_2':\tau_2$.
  This gives us that
  $\Gamma,\Sigma\infers t_1'\And t_2':\Task(\tau_1\times\tau_2)$.\\

  \noindent\textbf{Case} $\userule{S-Next}$ Given that
  $\Gamma,\Sigma\infers e_1\Next e_2:\Task \tau$, \refrule{T-Then} gives us that $\Gamma,\Sigma\infers t_1:\Task\tau_1$ and
  $\Gamma,\Sigma\infers e_2:\tau_1 \to \Task \tau$. By the induction hypothesis,
  we know that $t_1\stride t_1'$ preserves and thus
  $\Gamma,\Sigma\infers t_1':\Task\tau_1$. Therefore
  $\Gamma,\Sigma\infers t_1'\Next e_2:\Task\tau$.\\\\

  \noindent\textbf{Case} $\userule{S-OrLeft}$ Given that
  $\Gamma,\Sigma\infers t_1\Or t_2:\Task\tau$, by \refrule{T-Or} we have
  $\Gamma,\Sigma\infers t_1:\Task\tau$. By the induction hypothesis, we know that
  $t_1\stride t_1'$ preserves and thus $\Gamma,\Sigma\infers t_1':\Task\tau$.\\

  \noindent\textbf{Case} $\userule{S-OrRight}$ Given that
  $\Gamma,\Sigma\infers t_1\Or t_2:\Task\tau$, by \refrule{T-Or} we have $\Gamma,\Sigma\infers t_2:\Task\tau$. By the induction hypothesis, we know that
  $t_2\stride t_2'$ preserves and thus $\Gamma,\Sigma\infers t_2':\Task\tau$.\\

  \noindent\textbf{Case} $\userule{S-OrNone}$ Given that
  $\Gamma,\Sigma\infers t_1\Or t_2:\Task\tau$, by \refrule{T-Or} we have
  $\Gamma,\Sigma\infers t_1:\Task\tau$ and $\Gamma,\Sigma\infers t_2:\Task\tau$.
  By the induction hypothesis, we know that $t_1\stride t_1'$ and
  $t_2\stride t_2'$ preserve, and thus
  $\Gamma,\Sigma\infers t_1'\Or t_2':\Task\tau$.\\

  \noindent\textbf{Case} $\userule{S-ThenStay}$ Given that
  $\Gamma,\Sigma\infers t_1\Then e_2:\Task\tau$,
  by \refrule{T-Then} we have $\Gamma,\Sigma\infers t_1:\Task\tau_1$ and
  $\Gamma,\Sigma\infers e_2:\tau_1\to\Task\tau$. By the induction
  hypothesis, we know that $t_1\stride t_1'$ preserves, and thus
  $\Gamma,\Sigma\infers t_1'\Then e_2:\Task\tau$.\\

  \noindent\textbf{Case} $\userule{S-ThenFail}$ Given that
  $\Gamma,\Sigma\infers t_1\Then e_2:\Task\tau$,
  by \refrule{T-Then} we have $\Gamma,\Sigma\infers t_1:\Task\tau_1$ and
  $e_2:\tau_1\to\Task\tau$. By the induction
  hypothesis, we know that $t_1\stride t_1'$ preserves, and thus
  $\Gamma,\Sigma\infers t_1'\Then e_2:\Task\tau$.\\

  \noindent\textbf{Case} $\userule{S-ThenCont}$Given that
  $\Gamma,\Sigma\infers t_1\Then e_2:\Task\tau$, by \refrule{T-Then} we have
  $\Gamma,\Sigma\infers t_1:\Task\tau_1$ and
  $\Gamma,\Sigma\infers e_2:\tau_1\to\Task\tau$. By the induction hypothesis, we
  know that $t_1\stride t_1'$ preserves. By Lemma~\ref{lem:presvalue}, we know
  that $\Value{(t_1')}=v_1$ preserves. By Theorem~\ref{thm:pres-eval} we know
  that $e_2 v_1\evaluate t_2$ preserves. And finally by the induction hypothesis,
  we know that $t_2\stride t_2'$ preserves. Therefore
  $\Gamma,\Sigma\infers t_2':\Task\tau$.\\

  \noindent\textbf{Case} $\userule{S-Appoint}$ Given that
  $\Gamma,\Sigma\infers u\At t:\Task\tau$, by \refrule{T-Appoint} we have
  $t:\Task\tau$. By the induction hypothesis, we know that $t,s\stride t',s'$
  preserves, and thus $\Gamma,\Sigma\infers u\At t':\Task\tau$.\\

\end{proof}

\subsubsection{Theorem~\ref{thm:pres-norm}}

\begin{proof}
  We prove Theorem~\ref{thm:pres-norm} by induction on $e$:\\

  \noindent\textbf{Case} $\userule{N-Done}$ Given that
  $\Gamma,\Sigma\infers e:\Task\tau$ and $\Sigma\infers s$, we know that
  $\Gamma,\Sigma\infers t:\Task\tau$ and $\Sigma\infers s'$ by
  Theorem~\ref{thm:pres-eval}. Then by Theorem~\ref{thm:pres-stride}, we have
  $\Gamma,\Sigma\infers t':\Task\tau$ and $\Sigma\infers s''$.\\

  \noindent\textbf{Case} $\userule{N-Repeat}$ Given that
  $\Gamma,\Sigma\infers e:\Task\tau$ and $\Sigma\infers s$, we know that
  $\Gamma,\Sigma\infers t:\Task\tau$ and $\Sigma\infers s'$ by
  Theorem~\ref{thm:pres-eval}. Then by Theorem~\ref{thm:pres-stride}, we have
  $\Gamma,\Sigma\infers t':\Task\tau$ and $\Sigma\infers s''$. Then by the
  induction hypothesis, we finally obtain that
  $\Gamma,\Sigma\infers t'':\Task\tau$ and $\Sigma\infers s'''$.\\

\end{proof}

\subsubsection{Theorem~\ref{thm:pres-handle}}

We require the following Lemma for this proof.

\begin{lemma}
  Given that $\Sigma\infers s$, $\Sigma(l)=\tau$ and $\Gamma,\Sigma\infers v:\tau$, it holds that $\Sigma\infers s[l\mapsto v]$
  \label{lemmasigmaconsistent}
\end{lemma}
This lemma follows immediately from definition.

\begin{proof}
  We prove Theorem~\ref{thm:pres-handle} by induction on $e$:

  \noindent\textbf{Case} $\userule{H-Change}$ Given that
  $\Gamma,\Sigma\infers\Edit v:\Task\tau$ and $\Sigma\infers s$, the
  \refrule{H-Change} rule additionally gives us that $v,v':\tau$. Therefore by
  \refrule{T-Edit} we have that $\Gamma,\Sigma\infers\Edit v':\Task\tau$\\

  \noindent\textbf{Case} $\userule{H-Empty}$ Given that
  $\Gamma,\Sigma\infers\Edit v:\Task\beta$ and $\Sigma\infers s$, the
  \refrule{H-Empty} rule additionally gives us that $v:\tau$. Then by
  \refrule{T-Enter} we have $\Gamma,\Sigma\infers\Enter \tau:\Task\tau$ \\

  \noindent\textbf{Case} $\userule{H-Fill}$ Given that
  $\Gamma,\Sigma\infers\Enter\tau$ and $\Sigma\infers s$, the \refrule{H-Fill}
  rule additionally gives us that $v':\tau$. Then by \refrule{T-Enter} we have
  $\Gamma,\Sigma\infers \Edit v':\Task\tau$.\\

  \noindent\textbf{Case} $\userule{H-Update}$ Given that
  $\Gamma,\Sigma\infers\Update l:\Task\tau$ and $\Sigma\infers s$. This gives us
  that $\Sigma(l)=\tau$, and we additionally obtain $s(l),v':\tau$ by
  \refrule{H-Update}. By application of Lemma~\ref{lemmasigmaconsistent} this
  case holds.\\

  \noindent\textbf{Case} $\userule{H-PickLeft}$ Given that
  $\Gamma,\Sigma\infers t_1\Xor t_2:\Task\tau$ and $\Sigma\infers s$, then by
  \refrule{T-Xor} we have $\Gamma,\Sigma\infers t_1:\Task \tau$.\\

  \noindent\textbf{Case} $\userule{H-PickRight}$ Given that
  $\Gamma,\Sigma\infers t_1\Xor t_2:\Task\tau$ and $\Sigma\infers s$, then by
  \refrule{T-Xor} we have $\Gamma,\Sigma\infers t_2:\Task \tau$. \\

  \noindent\textbf{Case} $\userule{H-Next}$ Given that
  $\Gamma,\Sigma\infers t_1\Next e_2 :\Task\tau$ and $\Sigma\infers s$. Then by
  \refrule{T-Next}, we have $\Gamma,\Sigma\infers t_1:\Task\tau_1$ and
  $\Gamma,\Sigma\infers e_2:\tau_1\to\Task\tau$. Then by \refrule{T-Then} we
  obtain $\Gamma,\Sigma\infers t_1\Then e_2:\Task\tau$.\\

  \noindent\textbf{Case} $\userule{H-PassThen}$ Given that
  $\Gamma,\Sigma\infers t_1\Then e_2:\Task\tau$ and $\Sigma\infers s$,
  \refrule{T-Then} gives us that $\Gamma,\Sigma\infers t_1:\Task\tau_1$ and
  $\Gamma,\Sigma\infers e_2:\tau_1\to\Task\tau$. By the induction hypothesis, we
  know that $t_1,s\handle{i}t_1',s'$ also preserves and thus
  $\Gamma,\Sigma\infers t_1':\Task\tau_1$ and $\Gamma,Sigma\infers s'$. By
  \refrule{T-Then} we now obtain that
  $\Gamma,\Sigma\infers t_1'\Then e_2:\Task\tau$. \\

  \noindent\textbf{Case} $\userule{H-PassNext}$ Given that
  $\Gamma,\Sigma\infers t_1\Next e_2:\Task\tau$ and $\Sigma\infers s$,
  \refrule{T-Next} gives us that $\Gamma,\Sigma\infers t_1:\Task\tau_1$ and
  $\Gamma,\Sigma\infers e_2:\tau_1\to\Task\tau$. By the induction hypothesis, we
  know that $t_1,s\handle{i}t_1',s'$ also preserves and thus
  $\Gamma,\Sigma\infers t_1':\Task\tau_1$ and $\Gamma,Sigma\infers s'$. By
  \refrule{T-Next} we now obtain that
  $\Gamma,\Sigma\infers t_1'\Next e_2:\Task\tau$. \\

  \noindent\textbf{Case} $\userule{H-FirstAnd}$ Given that
  $\Gamma,\Sigma\infers t_1\And t_2:\Task(\tau_1\times\tau_2)$ and
  $\Sigma\infers s$, \refrule{T-And} gives us that
  $\Gamma,\Sigma\infers t_1:\Task\tau_1$ and
  $\Gamma,\Sigma\infers t_2:\Task\tau_2$. By the induction hypothesis, we know
  that $t_1,s\handle{i}t_1',s'$ also preserves and thus
  $\Gamma,\Sigma\infers t_1':\Task\tau_1$ and $\Sigma\infers s'$. Therefore by
  \refrule{T-Next} we obtain
  $\Gamma,\Sigma\infers t_1'\And t_2:\Task(\tau_1\times\tau_2)$.\\

  \noindent\textbf{Case} $\userule{H-SecondAnd}$ Given that
  $\Gamma,\Sigma\infers t_1\And t_2:\Task(\tau_1\times\tau_2)$ and
  $\Sigma\infers s$, \refrule{T-And} gives us that
  $\Gamma,\Sigma\infers t_1:\Task\tau_1$ and
  $\Gamma,\Sigma\infers t_2:\Task\tau_2$. By the induction hypothesis, we know
  that $t_2,s\handle{i}t_2',s'$ also preserves and thus
  $\Gamma,\Sigma\infers t_2':\Task\tau_2$ and $\Sigma\infers s'$. Therefore by
  \refrule{T-Next} we obtain
  $\Gamma,\Sigma\infers t_1\And t_2':\Task(\tau_1\times\tau_2)$.\\

  \noindent\textbf{Case} $\userule{H-FirstOr}$ Given that
  $\Gamma,\Sigma\infers t_1\Or t_2:\Task\tau$ and $\Sigma\infers s$,
  \refrule{T-Or} gives us that $\Gamma,\Sigma\infers t_1:\Task\tau$ and
  $\Gamma,\Sigma\infers t_2:\Task\tau$. By the induction hypothesis we know that
  $t_1,s\handle{i}t_1',s'$ also preserves, and therefore
  $\Gamma,\Sigma\infers t_1':\Task\tau$ and $\Sigma\infers s'$. By
  \refrule{T-Or} we now obtain $\Gamma,\Sigma\infers t_1'\Or t_2:\Task\tau$.\\

  \noindent\textbf{Case} $\userule{H-SecondOr}$ Given that
  $\Gamma,\Sigma\infers t_1\Or t_2:\Task\tau$ and $\Sigma\infers s$,
  \refrule{T-Or} gives us that $\Gamma,\Sigma\infers t_1:\Task\tau$ and
  $\Gamma,\Sigma\infers t_2:\Task\tau$. By the induction hypothesis we know that
  $t_2,s\handle{i}t_2',s'$ also preserves, and therefore
  $\Gamma,\Sigma\infers t_2':\Task\tau$ and $\Sigma\infers s'$. By T-Or we now
  obtain $\Gamma,\Sigma\infers t_1\Or t_2':\Task\tau$.\\

  \noindent\textbf{Case} $\userule{H-Appoint}$ Given that
  $\Gamma,\Sigma\infers u\At t:\Task\tau$, \refrule{T-Assign} gives us that
  $\Gamma,\Sigma\infers t:\Task\tau$. By the induction hypothesis, we know that
  $t,s\handle{i}t',s'$ also preserves, and therefore
  $\Gamma,\Sigma\infers u\At t'$ and $\Sigma\infers s'$.
\end{proof}

% \subsubsection{Theorem~\ref{thmprogressnorm}}
%
% \begin{proof} We prove this Theorem by induction on $e$.\\
%
%   \noindent\textbf{Case} $\userule{S-Edit}$ Given that $\Gamma,\Sigma\infers \Edit v : \Task \tau$, let $e''=\Edit v'$, $s''=s$ and $i=v':\tau$. Then H-Edit gives $\Edit v,s\handle{v'}\Edit v',s$. \\
%
%
%   \noindent\textbf{Case} $\userule{S-Fill}$ Given that $\Gamma,\Sigma\infers \Enter \tau : \Task \tau$, let $e''=\Edit v$, $s''=s$ and $i=v:\tau$. Then H-Fill gives $\Enter \tau,s\handle{v}\Edit v,s$. \\
%
%   \noindent\textbf{Case} $\userule{S-Update}$ Given that $\Gamma,\Sigma\infers \Update l : \Task \tau$, let $e''=\Update l$, $s''=s[l\mapsto v]$ and $i=v:\tau$. Then H-Update gives $\Update l ,s\handle{v}\Update l,s[l\mapsto v]$. \\
%
%   \noindent\textbf{Case} $\userule{S-Fail}$ Since $\Failing(\Fail)=\True$, the theorem holds in this case. \\
%
%   \noindent\textbf{Case} $\userule{S-Xor}$ \todo{Here we have an issue with the defintion of $\Failing$ and the sideconditions of external choice. These definitions should concur, so we can finish the proof, but $\Failing$ is a static property}\\
%
%   \noindent\textbf{Case} $\userule{S-Eval}$ By induction hypothesis we have that there exists an $e'''$, $s'''$ and $i$ such that $e'',s''\handle{i}e''',s'''$.\\
%
%   \noindent\textbf{Case} $\userule{S-ThenStay}$ By the induction hyposthesis we have that there exists an $e''$, $s''$ and $i$ such that $t_1',s'\handle{i}e'',s''$. Then by H-Pass, we know that we can apply the same $i$ to obtain $t_1\Then e_2,s'\handle{i} e''\Then e,s''$.\\
%
%   \noindent\textbf{Case} $\userule{S-ThenFail}$ By the induction hyposthesis we have that there exists an $e''$, $s''$ and $i$ such that $t_1',s'\handle{i}e'',s''$. Then by H-Pass, we know that we can apply the same $i$ to obtain $t_1\Then e_2,s'\handle{i} e''\Then e,s''$.\\
%
%   \noindent\textbf{Case} $\userule{S-ThenCont}$ By the induction hypothesis, we have that there exists an $e''$, $s''''$ and $i$ such that $t_2',s''\handle{i}e'',s''''$.\\
%
%   \noindent\textbf{Case} $\userule{S-OrLeft}$ By the induction hypothesis, we have that there exists an $e''$, $s'$ and $i$ such that $t_1',s\handle{i}e'',s''$.\\
%
%   \noindent\textbf{Case} $\userule{S-OrRight}$ By the induction hypothesis, we have that there exists an $e''$, $s'$ and $i$ such that $t_2',s\handle{i}e'',s''$.\\
%
%   \noindent\textbf{Case} $\userule{S-OrNone}$ \todo{   }\\
%
%   \noindent\textbf{Case} $\userule{S-Next}$ By the induction hypothesis, we have that there exists an $e''$, $s'$ and $i$ such that $t_1',s'\handle{i}e'',s''$. Then by the H-PassNext rule, we know that we can apply the same $i$ to obtain $t_1'\Next e_2,s'\handle{i}e'',s''$.\\
%
%   \noindent\textbf{Case} $\userule{S-And}$ By the induction hypothesis, we have that there exists an $e''$, $s'$ and $i$ such that $t_1',s'\handle{i}e'',s''$. Then by the H-FirstOr rule, we know that we can apply $\First i$ to obtain $t_1'\And t_2',s'\handle{\First i} t_1''\And t_2',s''$
%
% \end{proof}

\subsubsection{Lemma~\ref{lem:stride-does-not-eval}}

\begin{proof}
  We prove Lemma~\ref{lem:stride-does-not-eval} by induction on $e$. First we
  apply evaluation, and we then find ourselves in one of the cases below.\\

  \noindent\textbf{Case} $\userule{S-ThenStay}$\\
  and $\userule{S-ThenFail}$ The \refrule{E-Then} rule gives us that evaluation
  has been applied to $t_1$. We therefore can apply the induction hypothesis,
  from which we obtain that $t_1',s'\evaluate t_1'',s''$ then $t_1'=t_1''$ and
  $s'=s''$. This, together with the \refrule{E-Then} rule, proves this case.\\

  \noindent\textbf{Case} $\userule{S-ThenCont}$ By application of the induction
  hypothesis, we obtain that $t_2',s'''\evaluate t_2'',s''''$ then $t_2'=t_2''$
  and $s'''=s''''$, which immediately proves this case.\\

  \noindent\textbf{Case} $\userule{S-OrLeft}$ The \refrule{E-Or} rule gives us
  that evaluation has been applied to $t_1$. We therefore can apply the
  induction hypothesis, from which we obtain that $t_1',s'\evaluate t_1'',s''$
  then $t_1'=t_1''$ and $s'=s''$, which immediately proves this case.\\

  \noindent\textbf{Case} $\userule{S-OrRight}$The \refrule{E-Or} rule gives us
  that evaluation has been applied to $t_2$. We therefore can apply the
  induction hypothesis, from which we obtain that $t_2',s'\evaluate t_2'',s''$
  then $t_2'=t_2''$ and $s'=s''$, which immediately proves this case.\\

  \noindent\textbf{Case} $\userule{S-OrNone}$ The \refrule{E-Or} rule gives us
  that evaluation has been applied to both $t_1$ and $t_1$. We assumed that the
  states do not change, so we know that $s=s'=s''$. We can therefore safely
  apply the induction hypothesis twice, to obtain that
  $t_1',s''\evaluate t_1'',s'''$ then $t_1'=t_1''$ and $s''=s'''$, and
  $t_2',s'''\evaluate t_2'',s''''$ then $t_2'=t_2''$ and $s'''=s''''$. This,
  together with the \refrule{E-Or} rule proves this case.\\

  \noindent\textbf{Case} $\userule{S-Edit}$ by definiton, $\Edit v$ is a value
  with respect to evaluation.\\

  \noindent\textbf{Case} $\userule{S-Fill}$ by definition, $\Enter \tau$ is a
  value with respect to evaluation.\\

  \noindent\textbf{Case} $\userule{S-Update}$ by definiton, $\Update l$ is a
  value with respect to evaluation.\\

  \noindent\textbf{Case} $\userule{S-Fail}$ by definiton, $\Fail$ is a value
  with respect to evaluation.\\

  \noindent\textbf{Case} $\userule{S-Xor}$ by definition, $e_1\Xor e_2$ is a
  value with respect to evaluation.\\

  \noindent\textbf{Case} $\userule{S-Next}$ The \refrule{E-Next} rule gives us
  that evaluation has been applied to $t_1$. We therefore can apply the
  induction hypothesis, from which we obtain that $t_1',s'\evaluate t_1'',s''$
  then $t_1'=t_1''$ and $s'=s''$. This, together with the \refrule{E-Next} rule,
  proves this case.\\

  \noindent\textbf{Case} $\userule{S-And}$ The \refrule{E-And} rule gives us
  that evaluation has been applied to both $t_1$ and $t_1$. We assumed that the
  states do not change, so we know that $s=s'=s''$. We can therefore safely
  apply the induction hypothesis twice, to obtain that
  $t_1',s''\evaluate t_1'',s'''$ then $t_1'=t_1''$ and $s''=s'''$, and
  $t_2',s'''\evaluate t_2'',s''''$ then $t_2'=t_2''$ and $s'''=s''''$. This,
  together with the \refrule{E-And} rule proves this case.\\

  \noindent\textbf{Case} $\userule{S-Appoint}$ The \refrule{E-Appoint} rule
  gives us that evaluation has been applied to $t$. We therefore can apply the
  induction hypothesis, from which we obtain that $t',s'\evaluate t'',s''$ then
  $t'=t''$ and $s'=s''$. This, together with the \refrule{E-Appoint} rule,
  proves this case.

\end{proof}

\subsubsection{Theorem~\ref{thm:failing}}

\begin{proof}

  We prove Theorem~\ref{thm:failing} by induction on $e'$.\\

  \noindent\textbf{Case} $e = \Fail$\\
  $\Failing(\Fail)=\True$, and there is no handling rule that applies to fail.\\

  \noindent\textbf{Case} $e = \Edit v$\\
   Given that $\Gamma,\Sigma\infers\Edit v:\Task\tau$, $\Failing(\Edit v)=\False$, and there exists an input $i$, namely $v':\tau$.\\

  \noindent\textbf{Case} $e = \Enter \tau$\\
  $\Failing(\Enter \tau)=\False$, and there exists an in put i, namely $v:\tau$.\\

  \noindent\textbf{Case} $e = \Update l$\\
  Given that $\Gamma,\Sigma\infers\Update l:\Task\tau$, $\Failing(\Update l)=\False$, and there exists an input $i$, namely $v:\tau$.\\

  \noindent\textbf{Case} $e = t_1\Then e_2$\\
   $\Failing(t_1\Then e_2)=\Failing(t_1)$. If there exitsts an $i$ for $t_1$, then this $i$ also applies to $t_1\Then e_2$. This case therefore holds by the induction hypothesis.\\

  \noindent\textbf{Case} $e = t_1\Next e_2$\\
   $\Failing(t_1\Next e_2)=\Failing(t_1)$. If there exitsts an $i$ for $t_1$, then this $i$ also applies to $t_1\Next e_2$. This case therefore holds by the induction hypothesis.\\

  \noindent\textbf{Case} $e = e_1\Xor e_2$\\
   We normalise the two expressions first, $e_1,s\stride t_1,s'$, $e_2,s\stride t_2,s'$ and we can then be in two situations. One, we can have that $\Failing(t_1,s')$ and $\Failing(t_2,s')$ are both true. If that is so, then by definiton, we have both $\Failing(e_1\Xor e_2,s)$ and no rule of the hanlding semantics applies, and therefore there exists no input for this case.\\
                                           Or we are in the situation where one or both of the two sub expressions does not fail. In that case, we know that $\Failing(e_1\Xor e_2,s)$ does not hold, and that at least one of the handling rules applies. Therefore, there must be an input $i$, namely $\Left$, $\Right$ or both.

  \noindent\textbf{Case} $e = t_1\And t_2$\\
   We can again find ourselfs in one of two situations. In the first case, both sub expressions fail, $\Failing(t_1,s)$ and $\Failing(t_2,s)$. In that case, we know that $\Failing(t_1\And t_2,s)$ also fails by definition. By the induction hypothesis, we know that for both $t_1$ and $t_2$ there is no input that can be handled. Since the only two rules for $\And$ that handle input just pass this input on to one of the two expressions, we know that indeed no $i$ applies.\\
                                           In the case that one or both sub expressions do not fail, then by definition $t_1\And t_2$ not failing under $s$. Again by induction hypothesis, we know that for one or both of the expressions, there exits an $i$ that can be handled. Then by H-FirstAnd and H-SecondAnd, we know that we can pass this $i$, by prefixing it with either $\First$ or $\Second$.\\

  \noindent\textbf{Case} $e = t_1\Or t_2$\\
  We can again find ourselfs in one of two situations. In the first case, both sub expressions fail, $\Failing(t_1,s)$ and $\Failing(t_2,s)$. In that case, we know that $\Failing(t_1\Or t_2,s)$ also fails by definition. By the induction hypothesis, we know that for both $t_1$ and $t_2$ there is no input that can be handled. Since the only two rules for $\Or$ that handle input just pass this input on to one of the two expressions, we know that indeed no $i$ applies.\\
                                           In the case that one or both sub expressions do not fail, then by definition $t_1\Or t_2$ not failing under $s$. Again by induction hypothesis, we know that for one or both of the expressions, there exits an $i$ that can be handled. Then by H-FirstOr and H-SecondOr, we know that we can pass this $i$, by prefixing it with either $\First$ or $\Second$.\\

  \noindent\textbf{Case} $e = u \At t$\\
   This case follows directly from applying the induction hypothesis, since $\Failing(u \At t,s)=\Failing(t,s)$ and any input that applies to $t$ also applies to $u \At t$.\\
\end{proof}

\subsubsection{Theorem~\ref{thm:safety-i}}
\begin{proof}

  \noindent\textbf{Case} $e=\Edit v:\Task\tau, i= v':\tau$\\
   Given that $\userule{H-Change}$, we have by definition that $\Inputs(\Edit v:\Task\tau) = \set{v':\tau,\Empty}$, which includes $v':\tau$.

  \noindent\textbf{Case} $e=\Edit v:\Task\tau, i= \Empty$\\
   Given that $\userule{H-Empty}$, we have by definition that $\Inputs(\Edit v:\Task\tau) = \set{v':\tau,\Empty}$, which includes $\Empty$.\\

  \noindent\textbf{Case} $e=\Enter \tau, i= v':\tau$\\
   Given that $\userule{H-Fill}$, we have by definiton that $\Inputs(\Enter \tau) = \set{v':\tau }$, which includes $v':\tau$.\\

  \noindent\textbf{Case} $e=\Update l:\Task\tau, i= v':\tau$\\
   Given that $\userule{H-Update}$, we have by definiton that $\Inputs(\Update l:\Task\tau)= \set{v':\tau }$, which includes $v':\tau$.\\

  \noindent\textbf{Case} $e=t_1\Xor t_2 , i= \Left$\\
   Given that $\userule{H-PickLeft}$, we have by definition that $\Inputs(t_1\Xor t_2) = \set{ \Left,\Right}$, which includes $\Left$.\\

  \noindent\textbf{Case} $e=t_1\Xor t_2 , i= \Right$\\
   Given that $\userule{H-PickRight}$, we have by definition that $\Inputs(t_1\Xor t_2) = \set{ \Left,\Right}$, which includes $\Right$.\\

  \noindent\textbf{Case} $e=t_1\Next e_2 , i= \Continue $\\
   Given that $\userule{H-Next}$, we have by definition that $\Inputs(t_1\Next e_2) = \Inputs(t_1) \cup \set{\Continue\mid \Value{(t_1)} = v_1 \wedge \neg\Failing{(e_2 v_1\stride)}}$. If the H-Next rule applies, this means that the conditions $\Value{(t_1)} = v_1 \wedge \neg\Failing{(e_2 v_1\stride)}$ are fulfilled, and therefore $\Continue$ is contained. \\

  \noindent\textbf{Case} $e=t_1\Next e_2 , i\neq\Continue$\\
   Given that $\userule{H-PassNext}$, we have by definition that $\Inputs(t_1\Next e_2) = \Inputs(t_1) \cup \set{\Continue\mid \Value{(t_1)} = v_1 \wedge \neg\Failing{(e_2 v_1\stride)}}$. By the induction hypthesis, we have that $i\in \Inputs(t_1)$, and by definiton of $\Inputs$, $i$ is therefore also included in this case.\\

  \noindent\textbf{Case} $e=t_1\Then e_2 , i$\\
   Given that $\userule{H-PassThen}$, we have by definition that $\Inputs(t_1\Then e_2)= \Inputs(t_1)$. By the induction hypthesis, we have that $i\in \Inputs(t_1)$, and by definiton of $\Inputs$, $i$ is therefore also included in this case.\\

  \noindent\textbf{Case} $e=t_1\And t_2 , i=\First i$\\
   Given that $\userule{H-FirstAnd}$ we have by definition that $\Inputs(t_1\And t_2) = \set{\First\ i \mid i \in \Inputs(t_1)} \cup \set{\Second\ i \mid i \in \Inputs(t_2)}$. By the induction hypothesis, we have that $i\in\Inputs(t_1)$, and by definition of $\Inputs$, $\First i$ is therefore als included in this case.\\

  \noindent\textbf{Case} $e=t_1\And t_2 , i=\Second i$\\
   Given that $\userule{H-SecondAnd}$ we have by definition that $\Inputs(t_1\And t_2) = \set{\First\ i \mid i \in \Inputs(t_1)} \cup \set{\Second\ i \mid i \in \Inputs(t_2)}$. By the induction hypothesis, we have that $i\in\Inputs(t_2)$, and by definition of $\Inputs$, $\Second i$ is therefore als included in this case.\\

  \noindent\textbf{Case} $e=t_1\Or t_2 , i=\First i$\\
   Given that $\userule{H-FirstOr}$ we have by definition that $\Inputs(t_1\Or t_2) = \set{\First\ i \mid i \in \Inputs(t_1)} \cup \set{\Second\ i \mid i \in \Inputs(t_2)}$. By the induction hypothesis, we have that $i\in\Inputs(t_1)$, and by definition of $\Inputs$, $\First i$ is therefore als included in this case.\\

  \noindent\textbf{Case} $e=t_1\Or t_2 , i=\Second i$\\
   Given that $\userule{H-FirstOr}$ we have by definition that $\Inputs(t_1\Or t_2) = \set{\First\ i \mid i \in \Inputs(t_1)} \cup \set{\Second\ i \mid i \in \Inputs(t_2)}$. By the induction hypothesis, we have that $i\in\Inputs(t_2)$, and by definition of $\Inputs$, $\Second i$ is therefore als included in this case.\\

  \noindent\textbf{Case} $e=u\At t, i$\\
   Given that $\userule{H-Appoint}$, we can directly apply the induction hypothesis to prove this case.\\
\end{proof}


%************************************************
\chapter{Discussion}\label{ch:discussion} % $\mathbb{ZNR}$
%************************************************
\glsresetall % Resets all acronyms to not used
A wide variety of results were gathered in multiple different setups in \autoref{ch:evaluation} and are discusses in this section. At first, we discuss how to comprehend these results and derive use cases for NEAT-TCP. Then NEAT-TCP in general is discussed in relation to applicability and convergence. In the last part of this chapter we discuss future work for NEAT-TCP.

\section{Discussion of results}\label{sec:resultsDiscussion}
In \autoref{sec:resConclusion} it can be seen that NEAT-TCP1 reaches its target of providing high fairness and respectable throughput. NEAT-TCP2 achieved about the same throughput and fairness as New Reno with less end-to-end delay, but higher packet loss. This could indicate that more throughput is not possible in this setup. However, there is some room for variety in end-to-end delay and packet loss, while achieving the "maximum" total throughput. \\
For the evolution, only experiments 1, 4, 7 and 10 achieved a sufficient fitness. These experiments share the activation function \autoref{eq:sigmoid}. This either indicates that decision based neural networks are superior, or that for the given parameters for NEAT it was the only setup that could evolve fast enough. In \autoref{subsec:diffNEATpar} this is discussed further.
However, NEAT-TCP1 is the only congestion control algorithm tested, that enables the potential of wireless multi-hop networks. All flows have respectable throughput with very short end-to-end delay and very small packet loss.

\subsection{NEAT-TCP in Different Topologies}\label{subsec:neatDiffTop}
While NEAT-TCP1 and 2 were evolved in the 5x5 topology, they still have a good performance in 3x3 and a respectable performance in 6x6. NEAT-TCP1 in particular has similar behaviour in 3x3 in relation to New Reno. \\\\
This could indicate that NEAT-TCP could evolve for a variety of network topologies. So maybe the provided network model does not have to be precise. Yet, for 6x6 it can be seen, for packet loss in particular, that some measures can vary a lot. So the number of network setups that the evolved congestion control algorithm can satisfy is restricted. To state this with confidence, it has to be tested in more topologies and also in a non grid topology.

\subsection{Different NEAT Parameters}\label{subsec:diffNEATpar}
We priorly discussed that the evolutions with $\phi_2$ could have worse performance because of the \textit{Weight Mutation Power}.
The guess was that the weights were not mutated satisfying enough.
So we conducted the evolutions 2, 3, 5 and 6 again with the same parameters as \texttt{p2nv.ne} but with a \textit{Weight Mutation Power} of 5 instead of 1.8.
The results of these follow up evolutions can be found in \autoref{tab:followup}. It can be seen that there has been only a slight improvement in fitness. This was to be expected, because a stronger weight mutation can be achieved with some intermediate nodes that multiply the values multiple times with lower power, instead of one strong multiplication. The next guess is that a better result can be achieved with a larger population and a higher number of epochs.
\begin{table}[htbp]
  \centering
  \caption{Follow up evolution of experiments 2-3 and 5-6 with a different \textit{Weight Mutation Power}}
    \begin{tabular}{|l|l|r|}\hline
          & Highest Fitness Achieved & \multicolumn{1}{l|}{Epoch of Best Performing NN} \\ \hline
    Experiment 2 & 0.676702 & 87 \\ \hline
    Experiment 3 & 0.722285 & 49 \\ \hline
    Experiment 5 & 0.726794 & 53 \\ \hline
    Experiment 6 & 0.739769 & 34 \\ \hline
    \end{tabular}%
  \label{tab:followup}%
\end{table}%

\section{Congestion Control vs. Balancing Tasks}\label{sec:congVSbalancing}
It is interesting to see that the best performing neural networks were evolved with a setup that can also solve the double pole balancing on one cart problem. Congestion control is in a way a balancing task. But rather than the double pole balancing it is a distributed one. This could be an indication that NEAT is able to solve distributed balancing problems, which has not been discovered yet. In congestion control the congestion window is controlled which affects the throughput. So NEAT-TCP balances the throughput of all flows at about the same level, which is similar to balancing two poles on a cart, but distributed.

\section{NEAT-TCP Convergence}\label{sec:neatConvergence}
With limited time it is not easy to build statements on convergence. NEAT has three stop criteria: (i) target fitness is achieved, (ii) the number of epochs is reached or (iii) abortion by the user. Convergence is only considered by (i). Because NEAT is based on randomness in its mutations, each NEAT evolution converges differently. It can be stated that the earlier NEAT reaches the target fitness, the smaller the neural networks are, simply because then there have been less mutations. So to get neural networks with minimal structure, one should take more tries with less epochs instead of less tries with a high number of epochs. The higher the epoch number, the more complex are the resulting neural networks, given there is a chance for the \textit{Add Node Mutation}.

\section{NEAT-TCP Applicability}\label{sec:neatApplicability}
In this work NEAT-TCP was only tested in wireless multi-hop networks in grid structures. This is a rather complex environment for congestion control. NEAT-TCP should work as well in other kinds of networks. Then maybe other parameters for the neural network should be used. The parameters should represent the current congestion state. E.g. number of consecutive timeouts should not be used in a wired network since here timeouts would occur not because of congestion.\\\\
In an industrial context NEAT-TCP could be evolved before installation of the wireless multi-hop network and then shipped with it. With more computing power several scenarios can be tested within the evolution evaluation, thus covering a wider range of possible ways the network could behave.

\section{Future Work}\label{sec:futureWork}
In this section multiple ideas are mentioned for future work on NEAT-TCP.
\begin{itemize}
	\item{\textbf{Parallelise ns-3:} For a faster evolution, the next step would be to provide parallelisation. Right now, in an evolution the population has to be evaluated one by one, because ns-3 is not thread-safe. By providing parallel evaluation of the population the evolution would speed up by a factor of n, where n is the number of threads. This is because the simulation is the only part of NEAT-TCP that takes time. With doing this, an evolution would not take days or weeks, but rather hours.}
	\item{\textbf{Provide a larger population size:} Because of time constraints, we only considered a population size of 500. In future evolutions with more time, or a parallelised setup, a higher population size should be considered. With a larger population size the number of diversity in mutations is also higher, hence providing a higher chance of evolving neural networks of minimal structure. This could be mandatory for energy restricted nodes, because there should be a huge difference in energy consumption between a small neural network and a big one.}
	\item{\textbf{Provide more scenarios within the evaluation of the evolution:} Because of time constraints, we only considered one network scenario of all flows starting at the same time in a 5x5 grid and simulated it for only 40 seconds. In future evolutions of NEAT-TCP more scenarios should be considered, covering a wide range of possible network configurations. For example, if the nodes can move randomly, some movement pattern should be provided and the neural network has to satisfy in all of these scenarios. Also, the networks could be simulated longer. In our tests, NEAT-TCP1 and 2, even though they were simulated with 40s simulation time, held up their performance for 300 seconds. In general, it should be tested how far network specifications can be generalised in regards to wireless multi-hop networks.}
	\item{\textbf{Give NEAT-TCP more possibilities:} At the moment, NEAT-TCP only changes the congestion window and only reacts whenever a packet is acknowledged, or the socket says it wants to increase the congestion window. NEAT-TCP could also change the segment size. Or one could think of integrating the congestion states as inputs. The variety of changing NEAT-TCP is sheer endless. Also, to get away from TCP, NEAT could also evolve neural networks for routing, NEAT-Routing. The approach would be the same like NEAT-TCP, but the resulting NNs would be injected to route.}
	\item{\textbf{Extend NEAT to support multiple activation functions:} Right now, NEAT is restricted to only one activation function for the whole neural network. By extending NEAT to support multiple activation functions and an activation function mutation or randomly set activation functions a higher variety of neural networks could be evolved.}
	\item{\textbf{Evaluate NEAT-TCP on a real testbed:} In order to be sure NEAT-TCP does not only work in simulations it should be tested on a real testbed. For that purpose the testbed needs to be modelled in ns-3. Also, the interferences should be taken into account. After the evolution is over, the NEAT-TCP NN is coded into the testbed nodes and then evaluated. If the results are comparable to the ones from the simulation, NEAT-TCP can be adopted. A study should also be conducted on how close to reality the network model needs to be.}
\end{itemize}

%************************************************
\chapter{Conclusion}\label{ch:conclusion} % $\mathbb{ZNR}$
%************************************************
\glsresetall % Resets all acronyms to not used
Evolving neural networks to perform congestion control in wireless multi-hop networks has hereby been done, to the best of our knowledge, for the first time.
Congestion control in wireless multi-hop networks with conventional congestion control like TCP New Reno suffers bad performances \cite{wcp}, as channel disturbances and interferences leading to frame loss may mistakenly trigger congestion mechanisms and hence reduce the network`s performance.\\
In this work, we present NEAT-TCP, a novel approach to congestion control that automatically generates congestion control algorithms in a data-driven fashion while optimising towards a specific global system utility. It is highly variable and can be extended in sheer endless ways.\\
We also port iTCP from ns-2 to ns-3 to test the neural networks evolved by NEAT-TCP in relation to another neural network based congestion control algorithm. \\
We conduct twelve experiments, each with a different configuration and evaluate the best two neural networks evolved in these experiments. Our evaluation consists of testing in three different sized wireless multi-hop grid topologies for 100 runs each, measuring total network throughput, fairness, mean end-to-end delay and packet loss.\\
NEAT-TCP1, a neural network that is optimised towards a combination of total throughput and fairness between flows, outperforms TCP New Reno and iTCP in several respects. NEAT-TCP1  achieves 69\% more fairness, 66\% less mean end-to-end delay and 71\% less packet loss in relation to TCP New Reno at the cost of 19\% less overall throughput.