%!TEX root = report.tex

\chapter{The C3AE Model}
\label{chp:theorystuff}

\section{Model details}

The C3AE plain model takes as input a source image and tries to output a plausible estimation for the
age of the portrayed person.

Since the objective is to obtain a lightweight model the total number of parameters needs to be as low
as possible, as long as it doesn't affect the overall performance.
For this reason the input image size is limited (64×64×3) and the other channels sizes are also small.\\
Standard convolutional layers are adequate for the trade-off between accuracy and compactness (as
opposed to the separable convolution block used in the bigger models like MobileNets and ShuffleNets),
followed by batch normalization, Relu and average pooling (BRA).\\
The model is composed of five of these standard convolutions and two fully connected layers as shown
in \autoref{tab:architecture}.

\begin{center}
    \begin{tabular}{||c | c c c c||}
    \hline
    Layer & Kernel & Stride & Output size & Parameters \\
    \hline\hline
    Image & - & 1 & 64×64×3 & - \\
    \hline
    Conv. 1 & 3×3×32 & 1 & 62×62×32 & 896 \\
    \hline
    BRA & - & 1 & 31×31×32 & 128 \\
    \hline
    Conv. 2 & 3×3×32 & 1 & 29×29×32 & 9248 \\
    \hline
    BRA & - & 1 & 14×14×32 & 128 \\
    \hline
    Conv. 3 & 3×3×32 & 1 & 12×12×32 & 9248 \\
    \hline
    BRA & - & 1 & 6×6×32 & 128 \\
    \hline
    Conv. 4 & 3×3×32 & 1 & 4×4×32 & 9248 \\
    \hline
    BN + ReLu & - & 1 & 4×4×32 & 128 \\
    \hline
    Conv5 & 1×1×32 & 1 & 4×4×32 & 1056 \\
    \hline
    Feat. & 1×1×32 & 1 & 12 & 6156 \\
    \hline
    Predict. & 1×1×1 & 1 & 1 & 13 \\
    \hline
    \end{tabular}
    \captionof{table}{Architecture of the model}
    \label{tab:architecture}
\end{center}

To estimate people's age C3AE considers two objectives simultaneously: the first one minimizes the
Kullback-Leibler loss between distributions, and the second one optimizes the squared loss between
discrete ages.

In the following sections are mentioned this and other techniques used in C3AE.

\begin{figure}[!ht]
    \centering
    \includegraphics[width=400pt]{images/model.jpg}
    \caption{Overview of the model age estimation process}
    \label{fig:overview}
\end{figure}

\subsection*{Context-based Regression}
The resolution and the size of small-scale image is limited, so the idea is to exploit facial information
at different granularity levels.
After the face recognition task we identify three different crops of different sizes of the subject's face,
like in Figure 3.1. Each cropped image has a special view on the face.
The smaller image contains rich local information; in return the bigger one may contain global and scene
information.
The three crops are then fed into the shared CNN network, and finally the bottlenecks of the
three-scale facial images are aggregated by concatenation.

\subsection*{Two-point Age Representation}
With C3AE we don't predict directly the age as a number. Instead, this model uses a two-point age
representation through a distribution over two discrete adjacent bins.\\
For example let's consider the corresponding representation of an age of 22 with 10 bins. In this
case the set of bins is [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] and the corresponding vector
representation of the age is [0, 0.8, 0.2, 0, 0, 0, 0, 0, 0, 0].

\subsection*{Cascade Training}
From the above section, the age value can be represented as a distribution vector. The mapping from this
vector to age value is decomposed into two steps, where we define two different losses for the two cascade
tasks.\\
The first one ($L_{kl}$) measures the discrepancy between ground-truth label and predicted age distribution.
We adopt KL-Divergence as the measurement.\\
The second loss ($L_{reg}$) controls the prediction of the final age and is implemented as an L1 distance
or mean absolute error (MAE loss).\\
In the training process the two loss functions are considered in the cascade style as shown in Figure 3.1
but they are still trained jointly, and the total loss is given as
$L_{total} = \alpha L_{kl} + L_{reg}$, where $\alpha$ is the hyperparameter to balance the two losses.

\section{Implementation}
Our implementation of the C3AE model can be found on
GitHub.\footnote{\url{https://github.com/torchipeppo/C3AE-tf2}}
The code for this part of the project is based on the Tensorflow library for Python and was written in
Visual Studio Code text editor, collaborating remotely using the Live Share extension feature, which let
us write the code together.
\subsection*{The model}
The code of the model implementation can be found in the directory \texttt{master/model.py}. We followed
as strictly as possible the structure indicated in the reference paper, both in the number, composition
and ordering of the layers and also in the choice of parameters such as kernel dimensions, bottleneck
dimension and squeeze factors.
The Keras package integrated in Tensorflow provided all the basic functions needed to implement the
building blocks of the C3AE plain model, shared by all three of the image cuts.

In the last part of the file we organized the code so that we could be able to replicate the ablation
studies conducted in the original C3AE paper. Ablation studies are procedure where certain parts of the
network are removed, in order to gain a better understanding of the network’s behaviour. In our case,
the two ablations affect the presence or the absence of the cascade module and the context module.
The \texttt{model.py} file therefore gives us the possibility to analyze not only the full context
model, but also compare it with three slightly simpler ones: the model without cascade, without context
and without both.

The presence of these alternative versions required some changes in the code:

\begin{itemize}
    \item \textit{Context ablation}: produces only one simple input, instead of three concatenated ones,
    before computing the losses in the training phase. This means we will train using only one cut of the
    photos, the outer one.
    \item \textit{Cascade ablation}: in this case we lose the concept of two-point age representation.
    We replace the last dense layer W1 with a hidden layer with no particular meaning and then only
    considered one output, the age prediction, and ignore the second output, the age distribution.
    It follows that in the training phase we will only evaluate the MAE loss in this case, since the KL
    divergence loss will no longer be present.
    \item \textit{Full ablation}: both of the above modifications apply.
\end{itemize}

The results of these ablation studies are discussed later in \fullref{sec:ablation_study}.

\subsection*{The training}
The code relevant to the training phase can be found in \texttt{master/training.py}. Again, the choice of
the parameters such as learning rate, batch sizes and optimizers follows the values indicated in the source
paper when possible, with a couple of exceptions.

The dataset split ratio into training and validation was not specified for the datasets we used, so we
chose a value of 88\% - 12\%.

In the original paper for a comparison with the state-of-the-art methods, each model has been trained for
600 epochs. In our implementation this number had to be cut down to 100, the reason being time constraints
and hardware availability. All training was conducted locally on a machine with a Nvidia GTX 1660 SUPER GPU,
and even with 100 epochs each training phase lasted for 10 hours on average. A discussion on how this
cutback may not have affected the final results is present in the next chapter.

In this section of the code we also implemented the possibility to take an already trained model and continue
its training on another dataset, instead of starting over from zero. An experiment taking advantage of this
feature is described in \fullref{subsec:wikiutk}.


\section{Separation}


\documentclass[12pt]{amsart}   % LaTeX with AMS style; 12 point for old eyes

\usepackage{paper}

\begin{document}

\graphicspath{ {figures/} }

\title[Shape of Stones]{Continuous and Discrete Models for Simulating Stone Erosion}

\author{Jonathan Allen, John Wang}
\date{\today}

\maketitle

\subsection*{Abstract}

In this paper we explore various techniques for modeling erosion processes on a stone. We develop and analyze an algorithm for modeling chipping by representing a stone as a polygon. We also develop a method for modeling gradual stone erosion through a Fast Fourier Transform (FFT) representation of a stone.

\section{Introduction}
\input{introduction.tex}

\section{Discrete Model}
\input{discrete_model.tex}

\section{Continuous Model}
\input{continuous_surface.tex}

\section{Conclusion}
\input{conclusion.tex}

\begin{appendix}

\section{The DFT}\label{sec:dft}
\input{dft.tex}

\end{appendix}

\input{bibliography.tex}

\end{document}


% Chapter Template

\chapter{Related Work} % Main chapter title

\label{ch:02} % Change X to a consecutive number; for referencing this chapter elsewhere, use \ref{ChapterX}

%----------------------------------------------------------------------------------------
%	SECTION 1
%----------------------------------------------------------------------------------------

From PCA for estimation to recently deep learning based methods, the task of surface normal inference is also been well studied in last several decades.

\section{Sparse Input processing}

%% methods deal with sparse input, like nconv, gconv ...
The depth map is supposed to be dense. Therefore, how to accept sparse depth map as input in CNNs is one of the most important problem. Some trivial solutions like median filters are good enough, if the missing pixels are sparse enough, however, for the case of huge missing holes in the depth map, it produces just a paltry result. Thus a reasonable guess is required for missing areas. Generally, it can be solved as image inpainting problems,\cite{inpainting1},\cite{inpainting2}.

%% Deep learning based approaches
Some deep learning based method for image inpainting also achieved quite good performance for the hole mending task.
%% talk about gconv
Notably, in 2016, Oord et al. \cite{gated_activation} proposed a gated activation unit for a CNN model,
\[\textbf{y} = \tanh (W_{k,f} * \textbf{x}) \odot \sigma (W_{k,g} * \textbf{x})\]
to substitute the standard activation layer, where $ \sigma $ is the sigmoid function, which constricts the output value of second part between $ [0,1] $.  The function is inspired by Long Short-Term Memory (LSTM) \cite{lstm} and Rated Recurrent Unit (GRU).\cite{gru} It is originally used for learning complex interactions as LSTM gates does. In 2018, Yu et al. \cite{gconv} employed same function for free-form image inpainting, which can be used to learn mask automatically from image it self.

%% talk about nconv
Different to aforementioned approaches, Knutsson et al. in 2005 introduced normalized convolution \cite{nconv} dealing with missing sample case for convolution operation, which aims to reconstruct the missing pixels from the sparse output sensed by cameras, which particularly considered the confidence of each interpolated pixels, since it provides the trustworthiness of the predicted value. The higher the reliability of the value inference, the better the model shape reconstruction.

In 2018, Eldesokey et al. \cite{ncnn} applied normalized convolution in CNN as normalized convolution layer that takes both sparse depth map and a binary confidence map as input to perform scene depth completion.
In 2020, Eldesokey et al. \cite{pncnn} focus on modeling the uncertainty of depth data instead of assuming binary input confidence.

Guided method \cite{guided} requires addition information like RGB image or the certainty map of depth map, and fuse them together to predict the dense depth map.

\section{Normal Inference}

%% normal estimation method introduction
Usually, we based on point cloud, depth map or RGB/Grayscale image of the objects or scenes to inference the normals.

Traditional methods evaluate normals based on neighbor information of point cloud or depth map.
In 2012, Holzer et al. \cite{Holzer.S} proposed method to calculate normal from covariance matrices.
This method use integral image as input, which is able to run algorithm in a high frame speed. They smooth the depth data in order to handle the noise of depth image. The drawbacks are, as mentioned in the paper, the normals error go up when point depths change severely. In 2013, Fouhey et al. \cite{geometry_based_solution} proposed a method constructing a over-determined function systems to predict normals and solving it
by algebra methods. Similarly, this approach gives a quick but coarse normal inference.

%% CNN based methods
Recently, CNN based methods improve the performance of image processing to a brand new stage. In 2014, Eigen et al.\cite{Eigen} proposed a method predicting depth map directly from RGB image using CNN. In this case, no depth map is required. In 2016, Laina et al. \cite{img2depth} proposed a deeper network based on ResNet \cite{resnet} with a well designed upsamling part.
%% guided scene completion
In 2018, Qi et al. proposed GeoNet\cite{GeoNet}, it integrates both algebra method and also CNN method to inference depthmap based on \cite{img2depth} \cite{geometry_based_solution}.

%% upsampling
It is worth to noticed that, the output of normal inference CNN model is not one or severl labels but an entire image or normal map with same size.
%% talk about image upsampling, unet
Recently, Ronneberger et al proposed an architecture called UNet \cite{unet} for biomedical image segmentations. The architecture is shown in Figure \ref{fig:u-net}.The first half network is a usual classification convolutional network, the second half replace the pooling layers and traditional fc layers in the traditional CNNs to upsampling layers, thus in the end of the second half, the output is able to back to the input size. The proposed network can successfully assigned each pixel a class for segmentation tasks. Under this symmetric network, an input image is downsampled 3 times and upsampled 3 times. Output image has exactly the same size as input image. The downsampling and upsampling both have large number of feature channels, which guarantee the network propagates the information to higher resolution layers.

%%\begin{figure}[!h]
%%	\centering
%%	\includegraphics[width=\textwidth]{./ref/u-net-illustration-correct-scale2}
%%	\caption{U-net architecture (example for 32x32 pixels in the lowest resolution). Each blue box corresponds to a multi-channel feature map. The number of channels is denoted on top of the box. The x-y-size is provided at the lower left edge of the box. White boxes represent copied feature maps. The arrows denote the different operations.
	%%	}
%%	\label{fig:u-net}
%% \end{figure}

%% unstructured point cloud
In some case, the input is unstructured point cloud which can not be fed into a CNN entirely. Thus, a challenge task connect to the deep learning is the input format. Since different point clouds have different sizes.
In 2018, Ben-Shabat et al. \cite{Ben-Shabat_2019_CVPR} presented Nesti-Net. It predicts the normal point by point with the help of neighbor points. It fixed the distance of considering neighbors to provide an unified input for CNN. In 2021, Zhou et al. \cite{zhou2021fast} presents a method considering overlapping of different patches (a group of neighboring points) as input to evaluate normals.


\documentclass[12pt,english]{article}
\usepackage[utf8]{inputenc}

% url package
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,
    urlcolor=cyan,
}

% Bibliography package
\usepackage[authordate, backend=biber]{biblatex-chicago}
\bibliography{fansample}

% Titling and Author
\title{Latex Example, Pandoc Conversion}
\author{Fan Wang (University of Houston)}
\date{\today}

\begin{document}

\maketitle

\section{Equation Test}

Inline: $\sigma_y = \sqrt{ \sum_{y} P(Y=y) \cdot \left( y - \mu_y \right)^2}$

$$\Omega^{\max} = \exp(z^{\max}) \cdot \left(\Lambda^{\max}\right)^{\alpha}$$

\begin{equation}
\label{eq:1}
\sum_{i=0}^{\infty} a_i x^i
\end{equation}

\section{Citation Testing}

\textcite{becker_human_1986} is a paper on Human Capital. Early childhood health and economic circumstances could have lasting effects on adult socioeconomic outcomes \autocite{case_lasting_2005}.\footnote{"In this article, we develop a framework for analyzing the causal effects of interventions in the presence of latent factors that could affect outcomes, even in the absence of interventions" \autocite{conti_understanding_2010}.}

\section{URL Test}

\begin{itemize}
	\item \href{http://fanwangecon.github.io}{Fan Wang Site}
	\item \href{https://fanwangecon.github.io/CodeDynaAsset/}{Fan Wang Dynamic Asset Code Repository}
\end{itemize}

\pagebreak

\section{Pandoc}

\subsection{Install and convert Tex to Word}

For editing latex files in word to benefit from tracked changes.

\begin{enumerate}
	\item install pandoc: \href{https://pandoc.org/installing.html}{Pandoc Site Installation Link}
	\item open up command line
	\item \textit{cd into where tex file is}: cd \path{C:/Users/fan/Tex4Econ/_other/pandoc}
	\item \textit{run this for tex to word}: pandoc -s fansample.tex -o fansample.docx
\end{enumerate}

\subsection{Convert from Tex to Word with bibliography}

\begin{enumerate}
	\item \textit{run this for tex to word with bib}: pandoc --bibliography=fansample.bib -o fansample.docx fansample.tex
\end{enumerate}

\subsection{Convert from Word from Tex}

\begin{enumerate}
	\item \textit{run this for word to tex}: pandoc -s fansample.docx -o fansampleBACKDOCX.tex
\end{enumerate}

\printbibliography

\end{document}


\section{Metric spaces}\label{sec:metric_spaces}

Metric spaces are \hyperref[def:uniform_space]{uniform} \hyperref[def:topological_space]{topological spaces} with a lot of desirable properties. Most of real analysis that does not rely on certain algebraic structures generalizes well to metric spaces.


\chapter{scattering theory solutions}
\begin{abox}
	Practice set 1 solutions
	\end{abox}
\begin{enumerate}
	\begin{minipage}{\textwidth}
		\item A free particle described by a plane wave and moving in the positive $z$-direction undergoes scattering by a potential
		$$
		V(r)= \begin{cases}V_{0}, & \text { if } r \leq R \\ 0, & \text { if } r>R\end{cases}
		$$
		If $V_{0}$ is changed to $2 V_{0}$, keeping $R$ fixed, then the differential scattering cross-section, in the Born approximation.
		\exyear{NET JUNE 2012}
	\end{minipage}
	\begin{tasks}(2)
		\task[\textbf{A.}]increases to four times the original value
		\task[\textbf{B.}]increases to twice the original value
		\task[\textbf{C.}]decreases to half the original value
		\task[\textbf{D.}]decreases to one fourth the original value
	\end{tasks}
\begin{answer}
	$V(r)= \begin{cases}V_{0}, & r \leq R \\ 0, & r>R\end{cases}$\\
	$$\text { Low energy scattering amplitude } f(\theta, \phi)=-\frac{m}{2 \pi \hbar^{2}} V_{0} \frac{4}{3} \pi R^{3}$$
	$$\text { And differential scattering is given by } \frac{d \sigma_{1}}{d \Omega}=|f|^{2}=\left(\frac{2 m V_{0} R^{3}}{3 \hbar^{2}}\right)^{2}$$
	$$\text { Now } V(r)=2 V_{0} \text { for } r<R \Rightarrow \frac{d \sigma_{2}}{d \Omega}=\left(\frac{2 m\left(2 V_{0}\right) R^{3}}{3 \hbar^{2}}\right)^{2}=4\left(\frac{2 m V_{0} R^{3}}{3 \hbar^{2}}\right)^{2}=4 \frac{d \sigma_{1}}{d \Omega}$$
	The correct optopn is \textbf{(a)}
\end{answer}
\begin{minipage}{\textwidth}
	\item The differential cross-section for scattering by a target is given by
	$$
	\frac{d \sigma}{d \Omega}(\theta, \phi)=a^{2}+b^{2} \cos ^{2} \theta
	$$
	If $N$ is the flux of the incoming particles, the number of particles scattered per unit time is
	\exyear{NET JUNE 2015}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\frac{4 \pi}{3} N\left(a^{2}+b^{2}\right)$
	\task[\textbf{B.}]$4 \pi N\left(a^{2}+\frac{1}{6} b^{2}\right)$
	\task[\textbf{C.}]$4 \pi N\left(\frac{1}{2} a^{2}+\frac{1}{3} b^{2}\right)$
	\task[\textbf{D.}]$4 \pi N\left(a^{2}+\frac{1}{3} b^{2}\right)$
\end{tasks}
\begin{answer}
	$$\frac{d \sigma}{d \Omega}=a^{2}+b^{2} \cos ^{2} \theta$$
	$$\sigma=a^{2} \int_{0}^{\pi} \int_{0}^{2 \pi} \sin \theta d \theta d \phi+b^{2} \int_{0}^{\pi} \cos ^{2} \theta \sin \theta d \theta \int_{0}^{2 \pi} d \phi=a^{2} .4 \pi+b^{2} .2 \pi \times \frac{2}{3}=4 \pi\left[a^{2}+\frac{b^{2}}{3}\right]$$
	$$\text { Number of particle scattered per unit time, } \sigma \cdot N=4 \pi N\left(a^{2}+\frac{b^{2}}{3}\right)$$
	The correct option is \textbf{(d)}
\end{answer}
\begin{minipage}{\textwidth}
	\item A particle of energy $E$ scatters off a repulsive spherical potential
	$$
	V(r)=\left\{\begin{array}{ccc}
	V_{0} & \text { for } & r<a \\
	0 & \text { for } & r \leq a
	\end{array}\right.
	$$
	where $V_{0}$ and $a$ are positive constants. In the low energy limit, the total scattering crosssection is $\sigma=4 \pi a^{2}\left(\frac{1}{k a} \tanh k a-1\right)^{2}$, where $k^{2}=\frac{2 m}{h^{2}}\left(V_{0}-E\right)>0$. In the limit $V_{0} \rightarrow \infty$ the ratio of $\sigma$ to the classical scattering cross-section off a sphere of radius $a$ is
	\exyear{NET JUNE 2015}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] 4
	\task[\textbf{B.}]3
	\task[\textbf{C.}]1
	\task[\textbf{D.}]$\frac{1}{2}$
\end{tasks}
\begin{answer}
	 $\sigma=4 \pi a^{2}\left[\frac{1}{k a} \tanh k a-1\right]^{2}$\\\\
	$k a \rightarrow \infty, \tanh k a \rightarrow 1 \Rightarrow \sigma=4 \pi a^{2}\left(\frac{1}{k a}-1\right)^{2}$\\\\
	 and $k a \rightarrow \infty, \lim _{k a \rightarrow \infty} \sigma_{H}=4 \pi a^{2}$\\\\
	classically $\sigma_{c}=\pi a^{2} \quad \therefore \frac{\sigma_{H}}{\sigma_{c}}=4$\\
	The correct option is \textbf{(a)}
\end{answer}
\begin{minipage}{\textwidth}
	\item A particle is scattered by a central potential $V(r)=V_{0} r e^{-\mu r}$, where $V_{0}$ and $\mu$ are positive constants. If the momentum transfer $\vec{q}$ is such that $q=|\vec{q}| \gg \mu$, the scattering crosssection in the Born approximation, as $q \rightarrow \infty$, depends on $q$ as
	[You may use $\left.\int x^{n} e^{a x} d x=\frac{d^{n}}{d a^{n}} \int e^{a x} d x\right]$
	\exyear{NET DEC 2016}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}]$q^{-8}$
	\task[\textbf{B.}]$q^{-2}$
	\task[\textbf{C.}]$q^{2}$
	\task[\textbf{D.}]$q^{6}$
\end{tasks}
\begin{answer}
 The form factor is given for high energy as $q \rightarrow \infty$ \\
 \begin{align*}
 &f(\theta, \phi)=\frac{-2 m}{\hbar^{2} q} \int_{0}^{\infty} r V(r) \sin q r d r=\frac{-2 m}{\hbar^{2} q} \int_{0}^{\infty} r^{2} V_{0} e^{-\mu v} \sin q r d r\\
 	&=\frac{-2 m}{\hbar^{2} q} V_{0} \int_{0}^{\infty} r^{2} e^{-\mu r} \frac{e^{i q r}-e^{-i q r}}{2 i} d r=\frac{m V_{0}}{\hbar^{2} q} i\left[\int_{0}^{\infty} r^{2} e^{-r(\mu-i q)} d r-\int_{0}^{\infty} r^{2} e^{-r(\mu+i q)} d r\right] \\
 	&=\frac{m V_{0} i}{\hbar^{2} q}\left[\frac{\lfloor 2}{(\mu-i q)^{3}}-\frac{\lfloor 2}{(\mu+i q)^{3}}\right]=\frac{2 m V_{0} i}{\hbar^{2} q}\left[\frac{\left((\mu+i q)^{3}-(\mu-i q)^{3}\right)}{(\mu+i q)^{3}(\mu-i q)^{3}}\right] \\
 	&=\frac{2 m V_{0}}{\hbar^{2} q} \frac{i\left[\left(\mu^{3}-i q^{3}+3 \mu^{2} i q-3 \mu q^{2}\right)-\left(\mu^{3}+i q^{3}-3 \mu^{2} i q-3 \mu q^{2}\right)\right]}{\left(\mu^{2}+q^{2}\right)^{3}}\\
 	&=\frac{2 m V_{0} i}{\hbar^{2} q}\left[\frac{6 \mu^{2} i q-2 i q^{3}}{\left(\mu^{2}+q^{2}\right)^{3}}\right]=\frac{2 m V_{0}}{\hbar^{2} q}\left[\frac{2 q^{3}-6 \mu^{2} q}{\left(\mu^{2}+q^{2}\right)^{3}}\right] \\
 	&\propto \frac{q^{3}}{q}\left(2-\frac{6 \mu^{2}}{q^{2}}\right) \times \frac{1}{q^{6}\left(\frac{\mu^{2}}{q^{2}}+1\right)^{3}} \propto q^{2} \times \frac{1}{q^{6}} \propto \frac{1}{q^{4}} \quad\left(\because \frac{\mu^{2}}{q^{2}}<<1\right) \\
 	&\sigma(\theta) \propto|f(\theta)|^{2} \propto\left(q^{-4}\right)^{2}=q^{-8}
 \end{align*}
 The correct option is \textbf{(a)}
\end{answer}
\begin{minipage}{\textwidth}
	\item Consider the potential
	$$
	V(\vec{r})=\sum_{i} V_{0} a^{3} \delta^{(3)}\left(\vec{r}-\vec{r}_{i}\right)
	$$
	where $\vec{r}_{i}$ are the position vectors of the vertices of a cube of length $a$ centered at the origin and $V_{0}$ is a constant. If $V_{0} a^{2}<<\frac{\hbar^{2}}{m}$, the total scattering cross-section, in the lowenergy limit, is
	\exyear{NET JUNE 2017}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $16 a^{2}\left(\frac{m V_{0} a^{2}}{\hbar^{2}}\right)$
	\task[\textbf{B.}]$\frac{16 a^{2}}{\pi^{2}}\left(\frac{m V_{0} a^{2}}{\hbar^{2}}\right)^{2}$
	\task[\textbf{C.}]$\frac{64 a^{2}}{\pi}\left(\frac{m V_{0} a^{2}}{\hbar^{2}}\right)^{2}$
	\task[\textbf{D.}]$\frac{64 a^{2}}{\pi^{2}}\left(\frac{m V_{0} a^{2}}{\hbar^{2}}\right)$
\end{tasks}
\begin{answer}
	\begin{align*}
		V(r) &=\sum_{i} V_{0} a^{3} \delta^{3}\left(\vec{r}-\vec{r}_{i}\right) \\
		&=\sum_{i} V_{0} a^{3} \delta\left(x-x_{i}\right) \delta\left(y-y_{i}\right) \delta\left(z-z_{i}\right)
	\end{align*}
	where $x_{i}, y_{i}, z_{i}$ are co-ordinate at 8 corner cube whose center is at origin.\\\\
	$
	f(\theta)=-\frac{m}{2 \pi \hbar^{2}} \int V(r) d^{3} r
	$
	\begin{align*}
		&=\frac{-m}{2 \pi \hbar^{2}} V_{0} a^{3} \int_{-\infty}^{\infty} \int \sum_{i=1}^{8} \delta\left(x-x_{i}\right) \delta\left(y-y_{i}\right) \delta\left(z-z_{i}\right) d x d y d z \\
		&=\frac{-m}{2 \pi \hbar^{2}} V_{0} a^{3}[1+1+1+1+1+1+1+1] \\
		&=\frac{-8 m V_{0} a^{3}}{2 \pi \hbar^{2}}=\frac{-4 m V_{0} a^{3}}{\pi \hbar^{2}}
	\end{align*}
	$\text { total scattering cross section } \sigma=\int|f(\theta)|^{2} \sin \theta d \theta d \phi$\\
	$\text { Differential scattering cross section } D(\theta)=|f(\theta)|^{2}=\frac{16 m^{2} V_{0}^{2} a^{6}}{\pi^{2} \hbar^{4}}$\\
	\begin{align*}
		&=\frac{16 m^{2} V_{0}^{2} a^{6}}{\pi^{2} \hbar^{4}} 4 \pi=\frac{64 a^{2}}{\pi}\left(\frac{m^{2} V_{0}^{2} a^{4}}{h^{4}}\right) \\
		&\sigma=\frac{64 a^{2}}{\pi}\left(\frac{m V_{0} a^{2}}{\hbar^{2}}\right)^{2}
	\end{align*}
	The correct option is \textbf{(c)}
\end{answer}
\begin{minipage}{\textwidth}
	\item A phase shift of $30^{\circ}$ is observed when a beam of particles of energy $0.1 \mathrm{MeV}$ is scattered by a target. When the beam energy is changed, the observed phase shift is $60^{\circ}$. Assuming that only $s$-wave scattering is relevant and that the cross-section does not change with energy, the beam energy is
	\exyear{NET DEC 2017}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $0.4 \mathrm{MeV}$
	\task[\textbf{B.}]$0.3 \mathrm{MeV}$
	\task[\textbf{C.}]$0.2 \mathrm{MeV}$
	\task[\textbf{D.}]$0.15 \mathrm{MeV}$
\end{tasks}
\begin{answer}
	$\sigma=\frac{4 \pi}{k^{2}} \sum_{l=0}^{\infty}(2 l+1) \sin ^{2}\left(\delta_{l}\right)$\\
	only $s$-wave scattering is relevant $l=0$
	$$
	k=\sqrt{\frac{2 m E}{\hbar^{2}}}
	$$
	$$\sigma=\frac{4 \pi}{k^{2}} \sin ^{2} \delta_{0}=\frac{4 \pi \hbar^{2}}{2 m E} \sin ^{2} \delta_{0}$$
	$\text { According to problem } \frac{\sin ^{2} 30}{0.1 \mathrm{MeV}}=\frac{\sin ^{2} 60}{E} \Rightarrow E=\frac{\sin ^{2} 60}{\sin ^{2} 30} \times 0.1 \mathrm{MeV}=0.3 \mathrm{MeV}$\\
	The correct option is \textbf{(b)}
\end{answer}
\begin{minipage}{\textwidth}
	\item The differential scattering cross-section $\frac{d \sigma}{d \Omega}$ for the central potential $V(r)=\frac{\beta}{r} e^{-\mu r}$, where $\beta$ and $\mu$ are positive constants, is calculated in thee first Born approximation. Its dependence on the scattering angle $\theta$ is proportional to ( $A$ is a constant below)
	\exyear{NET JUNE 2018}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\left(A^{2}+\sin ^{2} \frac{\theta}{2}\right)$
	\task[\textbf{B.}]$\left(A^{2}+\sin ^{2} \frac{\theta}{2}\right)^{-1}$
	\task[\textbf{C.}]$\left(A^{2}+\sin ^{2} \frac{\theta}{2}\right)^{-2}$
	\task[\textbf{D.}]$\left(A^{2}+\sin ^{2} \frac{\theta}{2}\right)^{2}$
\end{tasks}
\begin{answer}
	$f(\theta) \propto \int_{0}^{\infty} V(r) \sin k r d r \Rightarrow D(\theta) \propto|f(\theta)|^{2}$
	\begin{align*}
		&f(\theta) \propto \frac{1}{k} \int_{0}^{\infty} \beta \frac{e^{-\mu r}}{r} r \sin k r d r \\
		&f(\theta) \propto \frac{1}{k} \int_{0}^{\infty} \frac{e^{-\mu r}}{r} r\left(\frac{e^{i k r}-e^{-i k r}}{2 i}\right) d r \Rightarrow \frac{1}{2 i k} \int_{0}^{\infty} e^{-\mu r} e^{i k r} d r-\int_{0}^{\infty} e^{-\mu r} e^{-i k r} d r \\
		&\Rightarrow \frac{1}{2 i k}\left(\int_{0}^{\infty} e^{-r(\mu-i k)} d r-\int e^{-r(\mu+i k r)} d r\right) \Rightarrow \frac{1}{2 i k}\left[\frac{\mu+i k-\mu+i k}{\mu^{2}+k^{2}}\right]=\frac{2 i k}{2 i k}\left(\mu^{2}+k^{2}\right)^{-1} \\
		&f(\theta) \propto \frac{1}{\left(\mu^{2}+k^{2}\right)}, \quad D(\theta)=\left(\frac{1}{\mu^{2}+k^{2}}\right)^{2}
	\end{align*}
	$D(\theta)=\left(\mu^{2}+k^{2}\right)^{-2}$, where $k \propto \sin \frac{\theta}{2}$\\
	$D(\theta) \propto\left(\mu^{2}+\sin ^{2} \frac{\theta}{2}\right)^{-2}$ or $D(\theta)=\left(A^{2}+\sin ^{2} \frac{\theta}{2}\right)^{-2}$\\
	The correct option is \textbf{(c)}
\end{answer}
\end{enumerate}

QM -CSIR/chapter/scattering theory solutions.tex


\chapter{Conclusion}
\label{chapter:conclusion}

In this dissertation, we have considered the problem of how the dynamics of biological macromolecules can be studied using discrete-state master equation or Markov models.
The construction of these models requires two elements: a way of decomposing configuration space into states, and a method for computing transition rates or probabilities among these states.
Chapter \ref{chapter:mastereqn-alanine-long-times} contained a proof of concept, demonstrating that a model constructed from short trajectories for a model system, terminally-blocked alanine peptide in explicit solvent, was capable of accurately describing the statistical dynamics over long times.
In Chapter \ref{chapter:validation-of-master-equation}, we considered a number of tests to establish the timescale at which the stochastic model would be an appropriate description of dynamics, an important prerequisite for evaluating various state decompositions.
Finally, Chapter \ref{chapter:automatic-state-decomposition} presented a first attempt at an \emph{automatic} algorithm for finding an optimal set of states given the number of states desired.
These last two chapters describe the minimal essential ingredients for the construction of these models for problems of biological interest.

There are obviously many remaining challenges before the use of these models becomes widespread, and before it is possible to tackle the most interesting questions in biology.
Currently, the quantity of data needed to construct these models requires the resources of massive computing projects, such as Blue Gene or Folding@Home, though it is becoming apparent that equilibrium datasets from these projects are also insufficient to construct well-determined Markov models.
Future work will concentrate on multistage sampling techniques.
There, an initial set of simulations is used to construct a crude state space, from which sets of trajectories are initiated.
By use of well-defined starting distributions that completely cover configuration space (\emph{e.g.}\ \cite{swope:2004a,weber-thesis:2006a,kube:2006a}), equilibrium transition probabilities can be reliably computed even if global equilibrium has never been achieved, as we saw in Chapter \ref{chapter:validation-of-master-equation}.
Alternatively, automatic algorithms to construct Markov models may start a number of simulations from any known structural information (\emph{e.g.}\ crystal structures, NMR ensembles, or homology models) and iteratively construct and update the model, continually discovering new metastable states and reapportioning computational effort to always explore the most poorly characterized regions, perhaps using a method like the one described by Singhal \emph{et al.}\ \cite{singhal:2005a}.
Transition path sampling \cite{dellago:1998b,bolhuis:2002a} could be employed to more efficiently compute transition rates or probabilities between states if at least one trajectory connecting the two has been found.

Further progress in the efficient construction of these models from biomolecular simulation data will lend insight into the biophysical processes of protein folding and dynamics.
More efficient algorithms will not only allow more complex problems to be addressed, but also will allow these models to be constructed with modest computer clusters instead of distributed computing projects.
There may come a time when the majority of molecular simulations are performed to construct these models.
After all, what good is a single trajectory when the entire statistical dynamics can be characterized instead?


\documentclass[fleqn]{scrartcl}

%{{{ Packages and such
\usepackage{goodies}
\usepackage{xspace}
\usepackage{named}
\usepackage{mathti}
\usepackage{theorems}

\newcommand{\prospec}{\textsf{ProSpec}\xspace}
\newcommand{\eqtrafo}{\textsf{EQTrafo}\xspace}
\newcommand{\sort}{\textsc{Sort}\xspace}
%}}}

\begin{document}
%{{{ Title
\bibliographystyle{named}

\title{The \prospec and \eqtrafo User's Manual}
\author{Peter Baumgartner and Bernd Thomas\\
Universit{\"a}t Koblenz-Landau\\
Rheinau 1\\
56075 Koblenz\\[2ex]
\texttt{\normalsize \{peter,bthomas\}@informatik.uni-koblenz.de}}
\date{Draft of \today}

\maketitle
%}}}

\section{Introduction}
\label{sec:Introduction}
%{{{ Introduction text
This document describes two tools developed at the AI Group at the
University of Koblenz. Both are intended  as frontends to be used in
conjunction with classical, first order clause logic theorem provers
(such as PROTEIN \cite{Baumgartner:Furbach:PROTEIN:CADE12:94}).
\begin{description}
\item[\prospec:] \prospec takes as input a file consisting of a {\em sort
  declaration\/} and some {\em well-sorted formulas\/} (not neccessarily
  clauses), possibly containing the equality predicate. The output is
  a set of unsorted clauses with equality. In brief, \prospec
  transforms sorted logic with equality into unsorted logic with
  equality in a semantics preserving way.

\item[\eqtrafo:] \eqtrafo takes as input a file consisting of clauses,
  possibly containing the equality predicate. The output is a set of
  clauses not containing the equality predicate. In brief \eqtrafo
  transforms clause logic with equality into clause logic without
  equality in a semantics preserving way.
\end{description}
Hence, typically a sorted specification with equality is proved using the
command sequence \prospec --- \eqtrafo --- Protein.
%}}}

\section{\protect{\prospec}}
\label{sec:Prospec}
%{{{ Introductory text
We will first describe the semantics of the transformation; the
subsequent \prospec user's guide will describe the concrete syntax and
how to run the program.
%}}}

\subsection{Syntax and Semantics of the Transformation}
\label{sec:ProspecSemantics}
%{{{ Text
By  a {\em sorted
  specification\/} we mean a pair consisting of a {\em sort declaration\/}
  and a set of {\em well-sorted sorted formulas\/}.

Following standard terminology, a {\em sort declaration\/} for a signature
$\Sigma$ consists of
\begin{itemize}
\item a set $\sort$ of symbols, called {\em sorts\/},
\item a mapping $s:Var \mapsto \sort$ which maps each variable of
  $\Sigma$ to a sort,
\item a set of {\em term declarations\/} of the form $t \in S$, where $S \in
\sort$,
\item a set of {\em predicate declarations\/} of the form
$P : S_1 \times \cdots \times S_n$, where $P$ is an
$n$-ary predicate symbol and $S_i \in \sort$,
\item and a set of {\em subsort declarations\/} of the form $S_1
  \sqsubseteq S_2$ where $S_1,S_2 \in \sort$.
\end{itemize}
For instance, using the convention that a variable $x$ with sort
$s$ (i.e. $s(x) = S$) is displayed as $x_S$, a valid term
declaration is $succ(succ(x_{Even})) \in Even$ (provided $Even \in
\sort$). An example for a subsort declaration would be $Nat
\sqsubseteq Integer$.

Although these notions all are standard, we gave them here in order to
formulate  restrictions apply in our case:
\begin{itemize}
\item The sort hierarchie must be a tree: whenever $S \sqsubseteq
   S_1$ and $S \sqsubseteq S_2$ then $S_1 = S_2$.
\item For every $n-ary$ predicate symbol $P$ there is exactly one
  predicate declaration
  \begin{displaymath}
    P : S_1 \times \cdots \times S_n\quad \text{where $S_i
      \in \sort$, for $1 \leq i \leq n$.}
  \end{displaymath}
\item For every $n-ary$ function symbol $f$ there is exactly one
  term declaration
  \begin{displaymath}
    f(x^1_{S_1},\ldots,x^n_{S_n}) \in S \quad\text{where  $S,\,S_i
      \in \sort$, $x_i \neq x_j$, for $1
      \leq i,j \leq n$ and $i \neq j$.}
  \end{displaymath}
This is also noted as
\begin{displaymath}
  f: S_1 \times \cdots \times S_n \mapsto S
\end{displaymath}
This restriction is also called the {\em elementary\/} restriction of sorted
signatures, and the term declarations are also called {\em function
declarations\/}.
\end{itemize}
By a {\em declaration\/} we mean either a predicate declaration or a
function declaration. The tree-restriction and the restrictions posed
in the declarations are quite severe. Nethertheless they turned out to
be useful in practice.

The restrictions stated so far are precisely the same as in
\cite{Schmitt:Wernecke:TableauSortedLogics:89}. The reasons is that
our \prospec transformation coincides with the predicative encoding of
sorts of Schmitt and Wernecke, and hence has to make the same
assumptions about the sort declarations.

However, we want to be more general and allow
{\em polymorphism\/} in our declarations (again, this is standard,
see~\cite{Beierle}).
The idea is to  allow a {\em variable\/}
in place where a {\em sort\/} is required. These {\em sort variables\/} are
taken from a set disjoint to the object variables. Further, we would
like to have declarations of the form $cons: U \times list(U) \mapsto
list(U)$. This motivates the following definition of a {\em sort\/}
\begin{definition}[Polymorphic Sorts]
Let $\cal B \neq \emptyset$  be a set of symbols, called {\em basic sorts\/}, let $\cal U$
be a set of variables, called {\em sort variables\/}, and let $\cal F$
be a set of function symbols
of given arity, called {\em sort functions\/}.
The set \sort is the smallest set consisting of sorts, where a sort
is defined inductively as follows:
\begin{itemize}
\item Every basic sort $B \in {\cal B}$ is a sort.
\item Every variable $U \in {\cal U}$ is a sort.
\item If $S_1,\ldots,S_n$ are sorts, then $F(S_1,\ldots,S_n)$ is a sort,
  where $F \in {\cal F}$.
\end{itemize}
\end{definition}

When taking this modified definition of \sort, the restrictions on
sort declarations posed above can remain unchanged, except
that the following  restricion on subsort declarations has to be made:
\begin{description}
\item Every  {\em subsort declaration\/} is of the form $S_1
  \sqsubseteq S_2$ where $S_1,S_2 \in {\cal B}$.
\end{description}
With this restriction, the transitive closure of ``$\sqsubseteq$''
can be extended to a partial order on \sort (see~\cite{Beierle}).

Now, equality is declared as follows: ${} = {} : U \times U$, where
$U \in {\cal U}$. Notice that this is an ``unusual'' declaration of
equality, since it permits equations only on terms of the {\em same\/}
sort (the ``usual'' declaration would be ${} = {} : t \times t$
where $t$ is a basic sort and is the least upper bound of all basic
sorts). This restriction is motivated by the equality transformation
\eqtrafo, which is complete for this declaration only.

A further consequence of this declaration concerns semantics: for
interpretations it has
to be required that different sorts are mapped to domains which do not
have any elements in common.

{\large\bf STOP 2.6.97}

%
% Let $D[U_1,\ldots,U_n]$ denote
% a declarion containing exactly the different sort variables
% $U_1,\ldots,U_n$. By $D[U_1,\ldots,U_{i-1},S_i,U_{i+1},\ldots,U_n]$ we mean
% the declaration which is obtained from  $D[U_1,\ldots,U_n]$ by replacing
% all occurrences of $U_i$ by $S_i \in \sort$.

It has to be clarified what a {\em well-sorted formula\/} is. In brief,
one has to take care when building formulas that all terms and atoms
obey the sort declarations: whenever according to the declaration part
a term of sort $S$ is expected, then only a term of sort $S$ or
subsort of $S$ may be used.
Since this is completely standard we
will not repeat the definition here (See
e.g.~\cite{Oberschelp:OrderSortedPredicateLogic:TableauSortedLogics:89}).
The only thing to note is that our restrictions imply that each term
gets a {\em unique\/} sort\footnote{Our sorted signatures are
  {\em subterm-closed\/}: every subterm of a well-sorted term is
  well-sorted as well.}

With respect to  semantics, one has to use {\em sorted
interpretations\/}. Again, this is standard. The only thing to mention
here is that a sorted interpretation $\cal I$ maps each sort $S \in \sort$ to a
{\em non-empty\/} domain ${\cal I}(S)$.

\prospec transforms a well-sorted specification $\Phi_S$ into an unsorted
clause set $\Phi$ in such a way that the semantics of the sorts is
preserved. Such transformations are well-known in the literature and
are referred to as {\em sort relativations\/}. Relativations are expected to
satisfy the following property:
\begin{description}
\item[Sort theorem:] $\Phi_S$ is satisfiable with some sort
  interpretation if and only if $\Phi$ is satisfiable in some unsorted
  interpretation.
\end{description}
Since the relativation carried out by \prospec satisfies the sort
theorem, we thus have a semantics for sorted specifications, by simply
taking the semantics of the relativised version.

Designing a sort relativation is a tradeoff between {\em expressibility\/}
and {\em efficiency\/}. In \prospec we decided to have rather severe
restrictions on sort declarations, which, on the other hand, allow for
a very simple transformation. Further, and more important, the
relativised clause set can
be treated very efficiently, because all the reasoning stemming from
the sort information is carried out by {\em ordinary\/} unification.
For instance, we do not allow the declaration that different sorts
have a {\em common\/} subsort, because this would either need a
non-standard unification algorithm or a much more complex
transformation.
%}}}

\subsection{\prospec User's Guide}
\label{sec:ProspecUsersGuide}
%{{{ Text
%}}}

\bibliography{/home/peter/TEX/peter,/home/peter/TEX/logic}
\end{document}

%%% Local Variables:
%%% folded-file: t
%%% mode: latex
%%% TeX-master: t
%%% TeX-parse-self: t
%%% TeX-auto-save: t
%%% End:


\chapter{Mathematical Representation}
\label{chap:mathsdefn}

\begin{quote}
{\small
All models are wrong but some are useful\\
\textit{George E.P. Box} }
\end{quote}

\section{Introduction}
This chapter deals with the mathematical description of models which can be encoded in PharmML. The figure
\ref{fig:indivModel} visualises the task every modeller is faced with -- find a model (solid line) which explains the experimental data (diamonds). A perfect mathematical model, given error free experimental measurements, would explain the underlying mechanism and therefore fit every measurement. The complexity of the human body makes detailed mechanistic representation impossible, so the models we use are only approximations of a physiological system under consideration with multiple sources of uncertainty we have to account for, see Figure \ref{fig:basicEquation}.\\
%
%{\Large
%\begin{eqnarray}
%&& Experimental \;data = Model \;Prediction + Error \nonumber
%\end{eqnarray}
%}
\begin{figure}[htbp]
\centering
 \includegraphics[height=10mm]{ModelEquation}
\caption{A basic equation visualising the relationship between experimental data and model prediction.}
%\caption{Basic mathematical model for frequently sampled individual data. The black diamonds stand for experimental data, the solid line for the time course of concentration as predicted by a mathematical model.}
\label{fig:basicEquation}
\end{figure}
Additional aspect is the difference between individual and population approach. In the former case, usually when dealing with animal or preclinical studies, frequently sampled data is available and one can estimate individual's PK and PD parameters, see Figure \ref{fig:indivModel}. In clinical practise however, the situation is quite different, Figure \ref{fig:popModel}. More data records in total are available but it's often impossible to estimate subject specific parameters. Instead, the data provides valuable information on the inter-individual variability.
\begin{figure}[htbp]
\centering
 \includegraphics[height=45mm]{Model_individual}
\caption{Frequently sampled individual PK data. The black diamonds stand for experimental data, the solid line for the time course of concentration as predicted by a mathematical model. }
%\caption{Basic mathematical model for frequently sampled individual data. The black diamonds stand for experimental data, the solid line for the time course of concentration as predicted by a mathematical model.}
\label{fig:indivModel}
\end{figure}

\begin{figure}[htbp]
\centering
 \includegraphics[height=45mm]{Model_population}
\caption{Population PK data --  for three subjects with different observation times and varying characteristics, such as area under the curve, maximum values, time of the maximum etc. The grey line of the population average is to be estimated along with individual estimates.}
%\caption{Basic mathematical model for frequently sampled individual data. The black diamonds stand for experimental data, the solid line for the time course of concentration as predicted by a mathematical model.}
\label{fig:popModel}
\end{figure}

\section{Non-linear mixed effect models}

The approach which proved to be very effective for the analysis of population data is that of \textbf{nonlinear mixed effect models}, NLME. The nonlinearity means that it can handle virtually any type of structural model, usually highly non-linear. Additionally one can consider population or subject related factors, known \emph{a priori} or collected during the study, which can be divided into two groups:
\begin{itemize}
\item
\textbf{fixed effects} -- population averages, e.g. typical/population value for volume, and other group or even subject specific explanatory variables, such as treatment groups, gender or weight, see covariate model in section \ref{maths:covariate_model}.
\item
\textbf{random effects} -- subject/occasion specific, e.g. \textit{inter-individual} or \textit{inter-individual within subject within centre variability}, see section \ref{sec:variabilityModel} on variability.
\end{itemize}
The notation of fixed versus random effects might be at first confusing as the former account for population, group but also subject characteristics. As explained in the parameter model section, the values of individual characteristics are subject specific features but the parameters assigned to them are identical for a group or population. \\
The structure of this chapter is the following, in section \ref{sec:continuousDataModel} we formulate a general nonlinear mixed effects model for continuous data, section \ref{sec:structuralModel} introduces the structural model, section \ref{sec:variabilityModel} discusses the variability as nested hierarchy, section \ref{sec:parameterModel} is about the parameter model, with discussion on correlation of random effects, covariate model and a comparison of equivalent representations of the parameter model and section \ref{sec:residualErrorModel} is about the residual error model.
% and last section \ref{sec:CTS} about the trial design model.

\input{input/continuousDataModel_specSection}

\input{input/structuralModel_specSection}

\input{input/variabilityLevels_specSection}

\input{input/parameterRepresentation_specSection}

\input{input/observationModel_specSection}

%\paragraph{Covariate model}
%Covariate model is barely covered so far. See also \cite{Keizer:2011aa}. Missing are following features:\\
%For categorical covariates:\\
%-- categorical distribution of categorical covariates \\
%---- estimating categorical distribution from external data file \\
%---- sampling from known categorical distribution \\
%---- clusters of categorical covariates \\
%For continuous covariates:\\
%-- power-normal distribution for continuous covariates \\
%---- estimating parameters $\lambda$,$\mu$,$\sigma$ from external data file \\
%---- sampling from known power-normal distribution \\
%---- conditional distribution of continuous covariates \\
%------ none \\
%------ defined \\
%------ to be estimated \\
%---- selecting criteria for continuous covariates \\
%---- dependent distribution of continuous covariates \\
%---- correlated continuous covariates \\
%For both types: \\
%-- selection/exclusion criteria missing \\
%
%\subsection{Observation model}
%- Name\\
%- Units\\
%- Observation types - continuous/discrete\\
%- Symbol of predicted output\\
%
%\subsection{Task model}
%-- Combination of tasks, e.g.\\
%1. estimate distribution of covariate from experimental data\\
%2. Simulation task using the estimated PDF
%
%
%\subsection{Not covered so far}
%- correlation of residual errors \\
%---- number models of relevant models identified and described in Use Case document\\
%


\section{Vickrey auctions}


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{listings}

\title{EDA132 Project2 - Probabilistic Reasoning}
\author{Axel Larsson (920515-0395), Lewis Belcher (900429-3552)}
\date{}

\usepackage{natbib}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage[thinlines]{easytable}
\usepackage{placeins}

\begin{document}

\maketitle

\section{Introduction}
In this project we employ a Hidden Markov Model to do filtering for localisation in an environment with no landmarks.

\subsection{The Environment}
The environment is modelled as an empty room; a rectangular grid of size $n \times{m}$ where $n$ is the number of rows and $m$ the number of columns. The time is seen as integers, we start at time $t = 0$. Each time step corresponds to the robot moving one field in any direction and the sensor giving an approximation of the location of the robot. The true location of the robot is a triple of $(x, y, heading)$ called a pose, e.g. the pose $(0, 1, EAST)$ corresponds to Figure \ref{fig:grid}.

\begin{figure}[ht]
\centering
    \begin{TAB}(e,2cm,2cm){|c:c:c:c|}{|c:c:c|}
    &  $\to$    &   &     \\
    &           &   &     \\
    &           &   &
    \end{TAB}
\caption{An example grid of size $3 \times{4}$ with the robot's pose $(0,1, EAST).$}
\label{fig:grid}
\end{figure}

\subsection{Robot and Sensors}\label{sec:robots}
The robot moves autonomously in one of the four cardinal directions, denoted $NORTH$, $EAST$, $SOUTH$ and $WEST$ depending on whether or not it encounters a wall. The moving strategy is given in Table \ref{tab:robot}. If the robot encounters a wall it always changes heading and the new heading is chosen from a uniform distribution over the available headings that does not entail wall encounters. Thus, if the robot is in the north west corner there is a $50\%$ probability of the new heading being east and a $50\%$ probability of it being south.
\begin{table}[ht]
\centering
  \begin{tabular}{ | l | l | }
    \hline
    \textbf{Heading}                            & \textbf{Probability}  \\ \hline
    $P(Maintain\ heading \mid no\ wall)$      & $0.7$                 \\ \hline
    $P(Change\ heading \mid no\ wall)$        & $0.3$                 \\ \hline
    $P(Maintain\ heading \mid wall)$          & $0.0$                 \\ \hline
    $P(Change\ heading \mid wall)$            & $1.0$                 \\ \hline
  \end{tabular}
  \caption{The robot's moving strategy, depending on wall encounter.}
  \label{tab:robot}
\end{table}

The objective is to localise and track a robot whose location is hidden. The only data available comes from a noisy sensor that approximates the location of the robot. The sensor reports the location of the robot as a pair of coordinates, $(x, y)$ on the grid. The sensor can report four different types of readings; $L$, $L_s$, $L_{s2}$ and "Nothing". $L$ denotes the correct location, $L_s$ any of the $8$ surrounding fields of the true location $L$ on the grid and $L_{s2}$ the next 16 surrounding fields. Note that this can include locations that are actually outside the grid, e.g. if the robot's true location is a corner field, the sensor might report the location as being $(-1, -1)$. The probability for each type of reading is shown in Table \ref{tab:sensor}.

\begin{table}[ht]
\centering
  \begin{tabular}{ | l | l | }
    \hline
    \textbf{Sensor Reading}             & \textbf{Probability}  \\ \hline
    True location $L$                   & $0.1$                 \\ \hline
    Surrounding fields $L_s$            & $0.05$                \\ \hline
    Next surrounding fields $L_{s2}$    & $0.025$               \\ \hline
    "Nothing"                           & $0.1$                 \\ \hline
  \end{tabular}
  \caption{Probabilities for the different possible sensor readings.}
  \label{tab:sensor}
\end{table}

\subsection{Probabilistic Reasoning}
We construct an agent operating in a partially observable environment. This agent maintains a belief state of which states of the world are currently probable. The agent predicts from the belief state and a transition model how the world might evolve in the next time step. The agent receives percepts from a noisy sensor and updates its belief state with the help of a sensor model.

A transition model specifies the probability distribution over the latest state variables given the previous values. In general we denote this variable $X_t$ where $t$ is the time step. So, $X_0$ would denote the state of the world at $t = 0$. In our world the state variable is the pose of the robot. If we assume a first-order Markov process, i.e. that the current state depends on only the previous state, we can write:
\begin{displaymath}
\textbf{P}(\textbf{X}_t \mid \textbf{X}_{0:t-1}) = \textbf{P}(\textbf{X}_t \mid \textbf{X}_{t-1})
\end{displaymath} Where $\textbf{X}_t$ are the state variables. Hence, the transition model says that the next state is only dependent on the previous state.
Furthermore we denote the evidence variable as $E_t$ which corresponds to the sensor output of a pair of coordinates $(x, y)$. For the sensor model, we make the \emph{sensor Markov assumption}:
\begin{displaymath}
\textbf{P}(\textbf{E}_t \mid \textbf{X}_{0:t}, \textbf{E}_{0:t-1} = \textbf{P}(\textbf{E}_t \mid \textbf{X}_t)
\end{displaymath} Thus, the state of the world causes the sensors to take on particular values.

Filtering is the process of computing the belief state, the posterior distribution over the most recent state given all evidence to date. To do filtering we compute:
\begin{displaymath}
\textbf{f}_{1:t} = \textbf{P}(\textbf{X}_t \mid \textbf{e}_{1:t})
\end{displaymath}

A \textbf{hidden Markov model}, or \textbf{HMM} is a temporal probabilistic model in which the state of the world is described by a \textbf{single discrete} random variable and whose possible values are the possible states of the world. If we enumerate the different possible states, i.e. the values of $X_t$, with $1,..,S$ the transition model $\textbf{P}(X_t \mid X_{t-1})$ becomes an $S \times S$ matrix $\textbf{T}$. $\textbf{T}_{i,j}$ is the probability of a transition from state $i$ to state $j$ which can be written as
\begin{displaymath}
\textbf{T}_{i,j} = P(X_t = j \mid X_{t-1} = i)
\end{displaymath}

We also introduce an $S \times S$ diagonal matrix $\textbf{O}_t$ whose $i$:th diagonal entry is $P(e_t \mid X_t = i)$, i.e. we specify how likely it is that the state causes $e_t$ to appear, for each state $i$. The $t$ specifies the time step and thus the current evidence is known at that time.

With a hidden Markov model we can do filtering with the following equation:
\begin{displaymath}
\textbf{f}_{1:t+1} = \alpha \textbf{O}_{t+1} \textbf{T}^t\textbf{f}_{1:t}
\end{displaymath}
where \textbf{f} is a column vector over the belief state; the probability distribution over the most recent state given all evidence to date. The equation is recursive, and we set the initial $\textbf{f}_{1:0}= \textbf{P}(\textbf{X}_0)$ to reflect the fact that at the the start of the process, $t=0$, all states are equally likely since we have not been given any evidence at this time.

\section{Method}
The possible different states are given as poses, i.e. $(x,y,heading)$. They need to be encoded in the transition matrix $\textbf{T}$ so that $\textbf{T}_{i,j}$ gives the probability of the robot transitioning to pose $j$ from pose $i$. We translate a pose to an index $i$ or $j$ by enumerating the headings clockwise from $0$ to $4$ starting with $NORTH$. This is described in Table \ref{tab:headings}.

\begin{table}[ht]
\centering
  \begin{tabular}{ | l | c | }
    \hline
    \textbf{Heading}    & \textbf{Code}   \\ \hline
    $NORTH$             & $0$             \\ \hline
    $EAST$              & $1$             \\ \hline
    $SOUTH$             & $2$             \\ \hline
    $WEST$              & $3$             \\ \hline
  \end{tabular}
  \caption{Encoding the headings.}
  \label{tab:headings}
\end{table}
We then multiply the heading code with $4$ and add the encoding of the location $(x,y)$ as a simply enumeration of the fields as row-major order. Thus we have:
\begin{lstlisting}
pose_to_index(x,y,h) = sq_nbr(x,y) * 4 + heading_code(h)
\end{lstlisting} to compute the index of a certain pose. For instance the pose $(0,1,EAST)$ would be translated to $1*4 + 1 = 5$, which corresponds to the robot pose shown in Figure \ref{fig:grid} and the pose $(0,0,EAST)$ would be equal to $1$. So to find the probability of going from pose (i.e. state) $(0,0,EAST)$ to $(0,1,EAST)$ we look up the transition matrix cell $\textbf{T}_{1, 5}$ which should be equal to $0.7$ according to Table \ref{tab:headings}.

The observation matrix is constructed as a diagonal matrix with the probabilities of the robot location on each diagonal element. In this project we receive only the robot location from the sensor, so where we have four states for each position in our transition matrix (as described above) we have four consecutive (along the diagonal) and equal probabilities for each position in the observation matrix.

\section{Implementation}
The program is written in Python3 and the functionality is divided into different modules, located in the \texttt{robot\_localisation} package:
\begin{itemize}
    \item \texttt{grid.py}
    \item \texttt{hmm\_filter.py}
    \item \texttt{main.py}
    \item \texttt{robot.py}
\end{itemize}
The \texttt{main} module is where the CLI is set up and where the robot simulation and tracking is initialised. This module also computes the error between the belief state and the actual state in the form of the so called Manhattan distance.

The \texttt{robot} module contains the logic for the simulation of the robot movement as well as the \texttt{Sensor} class. The \texttt{Sensor} generates readings with the help of numpy according to the distribution explained in Section \ref{sec:robots}. The \texttt{Sensor} class is also responsible for generating the observation matrices depending on the current sensor reading.

The \texttt{hmm\_filter} module contains a class, \texttt{FilterState}, that does the filtering.
In the \texttt{grid} module, the transition matrix is computed and the representation of the environment (i.e. the grid) is stored.

\subsection{Usage}
The program root is to be found at \texttt{/h/d5/f/dat11al1/robot-localisation}, while standing in that directory, execute \texttt{python3 robot\_localisation -h} to get a useful help message as such:
\begin{lstlisting}
usage: robot_localisation [-h] [-r ROWS] [-c COLUMNS]

Robot localisation with HMM

optional arguments:
  -h, --help                     show this help message
                                 and exit
  -r ROWS, --rows ROWS           the number of rows on
                                 the grid, default is 4
  -c COLUMNS, --columns COLUMNS  the number of columns on
                                 the grid, default is 4
\end{lstlisting}
As can be seen above, the \texttt{--rows} and \texttt{--cols} command line arguments are used to specify the desired grid size.

\subsection{Requirements}
The minimum requirements to execute the program is:

\begin{itemize}
    \item Python3
    \item numpy
\end{itemize}
If \texttt{virtualenv}, \texttt{setuptools} and \texttt{pip} is available on the system (which, unfortunately, they are not on the student computer system), these can be used to install the program in a virtual environment, but this is entirely optional.

\subsection{Running the Program}
While standing in the project root (\texttt{/h/d5/f/dat11al1/robot-localisation}) with a terminal, execute the command \texttt{python3 robot\_localisation}.

The program is developed as a CLI - Command Line Interface. Upon execution, the program outputs a friendly help text of how to run it, this message can at any time be displayed by typing \texttt{help}. The simulation starts at $t = 0$ and to step forward, one simply presses enter on the keyboard.

The transition and observation matrices can at any time be displayed by invoking \texttt{show T} and \texttt{show O}, respectively. Similarly the column vector representing the belief state of the agent can be shown by \texttt{show f}.

To quit, enter \texttt{q}.

\subsection{Testing}

There are three test modules; \texttt{grid\_test}, \texttt{manhattan\_text} and \texttt{robot\_test}, all located in the \texttt{tests} directory. To execute any of them, go to the project root (\texttt{/h/d5/f/dat11al1/robot-localisation}) and type the command: \texttt{python3 tests/<test-module>.py}.

\section{Results}

Figures \ref{fig:manhattan-errors} and \ref{fig:manhattan-errors-single} show the errors (Manhattan distance from the true location to the inferred location) compared to the number of steps taken in the simulation, over an average of 20 simulations and for a single simulation respectively.

\begin{figure}[h!]
    \centering
    \textbf{Manhattan distance between true position and \\ inferred position}
    \includegraphics[scale=0.45]{manhattan-errors-notitle.png}
    \caption{The average Manhattan distance between the true robot location and the assumed location using hidden Markov model filtering. The distances were taken over an average of 20 simulations.}
    \label{fig:manhattan-errors}
\end{figure}

\begin{figure}[h!]
    \centering
    \textbf{Manhattan distance between true position and \\ inferred position for a single simulation}
    \includegraphics[scale=0.45]{manhattan-errors-single.png}
    \caption{Manhattan distance between the true robot location and the assumed location using hidden Markov model filtering. This plot is for a single simulation and points at which the sensor returned no reading were recorded and plotted as dots in the figure.}
    \label{fig:manhattan-errors-single}
\end{figure}

\FloatBarrier
\section{Discussion}

We find that during the execution of our code the FilterState class finds the location of the robot at an error of 1-2 Manhattan distance within 1-2 steps. For continued execution of the code the belief state is rarely greater than 2 Manhattan distance away. Figure \ref{fig:manhattan-errors} exemplifies this, we see that over an average of 20 simulations for different grid sizes the error converges to a Manhattan distance of between 1-2 at greater than 2 steps.

We also note that one of the primary causes of an incerasing error is when the sensor returns no value (shown in figure \ref{fig:manhattan-errors-single}). In our implementation we do not update our position for these cases, so this result is in line with intuition (only the robot position is changed, and unless it moves directly towards our estimated position the error will increase).

When the sensor gives positions that are outside the grid, we still include them in the calculation. This is something we believe is better than treating off-grid positions as "None". If we treated them as "None", the sensor reading at that time would not give the model any useful information at all. While in our implementation, off-grid positions are not treated any differently than ordinary sensor readings. In the cases where the sensor reports the location as being two steps outside the grid, there could in fact sometimes only be one possible true location that could have caused that sensor reading.
So even if the sensor reports a location that is guaranteed to be incorrect, it still gives the model useful information.

\bibliographystyle{plain}
\bibliography{references}
\end{document}


% declare document class and geometry
\documentclass[12pt]{article} % use larger type; default would be 10pt
\usepackage[margin=1in]{geometry} % handle page geometry

% import packages and commands
\input{../header.tex}

\title{Phys 221A -- Quantum Mechanics -- Lec03}
\author{UCLA, Fall 2014}
\date{\formatdate{13}{10}{2014}} % Activate to display a given date or no date (if empty),
         % otherwise the current date is printed

\begin{document}
\maketitle

\section{Introduction}

Any theory we consider will have a complete set of compatible observables which we call an operator basis. That is, given operators $\set{A, B, C, \dots}$, we will have
\begin{equation}
0 = [A,B] = [A,C] = [B,C] = \dots.
\end{equation}
These operators will have associated quantum numbers $\set{\alpha, \beta, \gamma, \dots}$ such that a subset of them is in one-to-one correspondence with a basis vectors in the associated orthonormal basis. Typically these operators will be the Hamiltonian $H$ along with symmetry generators.

\subsection{Examples}

\subsubsection{Particle in a centro-symmetric potential}

In this system the Hamiltonian is given by
\begin{equation}
H = \frac{\v{p}^2}{2m} + V(\abs{\v{r}}) + H_\text{so}
\end{equation}
where $H_\text{so} \propto \v{L} \cdot \v{S}$. Here the Hilbert space is $L_2$. If we neglect spin-orbit coupling the operator basis is given by $\set{H_0, L^2, L_z, S_z}$. Otherwise we will need to use the total angular momentum $\v{J}$, which gives us operators $\set{H, J^2, J_z, L^2}$.

\subsubsection{Free particle}

Here the Hamiltonian is given by $H = \v{p}^2 / 2m$. This is the minimal Hamiltonian, and its operator basis is given by $\set{p_x, p_y, p_z, S_z}$. Notice that $H \propto p_x^2 + p_y^2 + p_z^2$.

\subsubsection{Harmonic oscillator in 3D}

Here the Hamiltonian is given by
\begin{equation}
H = \frac{\v{p}^2}{2m} + \frac{1}{2} k \v{x}^2
\end{equation}
and the operator basis is given by $\set{H, S_z}$.

\subsection{More on operators and shit}

Consider a Hermitian operator $O = O^\dagger$ and normal vector $\ket{\psi} \in G$, so $\braket{\psi}{\psi} = 1$. Then the expectation value of $O$ in the state $\psi$ is
\begin{equation}
\avg{O}_\psi = \bra{\psi} O \ket{\psi}.
\end{equation}
Define the corresponding \textit{deviation operator} $\Delta_O$ as
\begin{equation}
\Delta_O = O - \avg{O}_\psi.
\end{equation}
Then the quantity $\avg{ (\Delta_O)^2 }_\psi$ characterizes quantum fluctuations of $O$ in the state $\psi$. Note of course that the operator $(\Delta_O)^2$ is Hermitian.

\subsection{Generalized uncertainty principle}

The generalized uncertainty principle states that, given any $\psi \in G$ and two self-adjoint operators $A,B$, we have
\begin{equation}
\avg{ (\Delta_A)^2 }_\psi \avg{ (\Delta_B)^2 }_\psi \geq \frac{1}{4} \abs{ \avg{ [A,B] }_\psi }^2.
\end{equation}
Let's prove this. Consider the states $\ket{\alpha} = \Delta_A \ket{\psi}$, $\ket{\beta} = \Delta_B \ket{\psi}$. Then the Cauchy inequality tells us that
\begin{equation}
\braket{\alpha}{\alpha} \braket{\beta}{\beta} \geq \abs{\braket{\alpha}{\beta}}^2
\end{equation}
so that we have
\begin{equation}
\avg{(\Delta_A)^2}_\psi \avg{(\Delta_B)^2}_\psi \geq \abs{\avg{\Delta_A \Delta_B}_\psi }^2.
\end{equation}
We can decompose
\begin{equation}
\Delta_A \Delta_B = \underbrace{\frac{1}{2} \{ \Delta_A, \Delta_B \}}_\text{Hermitian} + \underbrace{\frac{1}{2} [\Delta_A, \Delta_B]}_\text{anti-Hermitian}
\end{equation}
and find that
\begin{equation}
\avg{\Delta_A \Delta_B} = \underbrace{\frac{1}{2} \avg{ \{ \Delta_A, \Delta_B \} }}_\text{real} + \underbrace{\frac{1}{2} \avg{ [\Delta_A, \Delta_B] } }_\text{imaginary}.
\end{equation}
Thus from the inequality before we have
\begin{align}
\avg{(\Delta_A)^2} \avg{(\Delta_B)^2} &\geq \abs{\avg{\Delta_A \Delta_B} }^2 \\
	&\geq \frac{1}{4} \abs{ \avg{ \{ \Delta_A, \Delta_B \} }}^2 + \frac{1}{4} \abs{ \avg{ [\Delta_A, \Delta_B] } }^2 \\
	&\geq \frac{1}{4} \abs{ \avg{ [\Delta_A, \Delta_B] } }^2.
\end{align}
We drop the anti-commutator term because it turns out to not be very important.

\subsection{Copenhagen interpretation}

Given a (pure) quantum state $\ket{\psi} \in G$ normalized $\braket{\psi}{\psi} = 1$, we can measure a dynamical variable $A = A^\dagger$ with eigenstates $\ket{\alpha_i}$ and eigenvalues $a_i$. If $\ket{\psi} = \sum_i c_i \ket{\alpha_i}$ then the measurement apparatus yields a measurement $a_i$ with probability $P_i = \abs{c_i}^2$ and the physical state ``collapses'' to the state $\ket{\alpha_i}$.

After measurement we are left with a mixed state. After ``infinitely'' many measurements we find the density matrix
\begin{equation}
\rho = \sum_i P_i \ket{\alpha_i} \bra{\alpha_i}
\end{equation}
where $\sum_i P_i = 1$ since $\braket{\psi}{\psi} = 1$. More generally the density matrix is given by
\begin{equation}
\rho = \sum_i P_i \ket{\psi_i} \bra{\psi_i}.
\end{equation}
For any operator $O$ that is evaluated over all possible outcomes we have
\begin{equation}
\avg{O} = \sum_i P_i \avg{O}_{\alpha_i} = \opname{tr} (O\rho).
\end{equation}

For an operator $A$ define the trace
\begin{equation}
\opname{tr} A = \sum_i \bra{\alpha_i} A \ket{\alpha_i}
\end{equation}
where $\set{\ket{\alpha_i}}$ is an orthonormal basis. It's independent of basis: given another orthonormal basis $\set{\beta_i}$ we have
\begin{align}
\opname{tr} A &= \sum_i \bra{\alpha_i} A \ket{\alpha_i} \\
	&= \sum_{ij} \braket{\beta_j}{\alpha_i} \bra{\alpha_i} A \ket{\beta_j} \\
	&= \sum_j \bra{\beta_j} A \ket{\beta_j}.
\end{align}

The trace blah blah blah [blah blah]

Averaging over outcomes we have
\begin{align}
\sum_i P_i a_i &= \avg{A}_\psi = \opname{tr} (A\rho) \\
\sum_i P_i (a_i - \avg{A})^2 &= \avg{(\Delta_A)^2}_\psi = \opname{tr} (\Delta_A^2 \rho).
\end{align}

The density matrix is just represents the projection operator combined with the statistical outcomes of measurements.

If we measure $A$ in state $\ket{\psi}$, we get the density matrix
\begin{equation}
\rho = \sum_i P_i \ket{\alpha_i} \bra{\alpha_i}.
\end{equation}
If we measure $B$ relative to the outcomes of $A$ we get
\begin{equation}
\avg{B} = \opname{tr} (B\rho), \qquad \avg{(\Delta_B)^2} = \opname{tr} (\Delta_B^2 \rho).
\end{equation}

[He rambled a bit more here about some stuff but I stopped paying attention.]

\end{document}


\chapter{Concluding Remarks}
\label{chapter: Future Directions}

%conclusion lambanontas upopsi oti o reader kserei ti exei ginei sto thesis
The goal of this final chapter is to conclude this report by reiterating the main contributions of this dissertation, and state a collection of promising ideas for future exploration that stem from the work enclosed in this report.

\section{Conclusion}

In this dissertation, we provide an initial exploration of the opportunity for optimisation of schedules based on the dataset supplied by Royal Mail, as well as an initial step towards the development of an efficient but also robust schedule against uncertainty. Our focus with respect to locating the room for improvement that exists in the historical schedule has been focused on the solution of various \textit{Mixed-Integer Optimisation Problems}, motivated in part by the fact that such formulations enable us to optimised various aspects of the historical schedules. Our goal in optimising those aspects of the historical schedules is to provide solutions for improvements inside a sphere of different factors ranging from employee quality of life, to cost-savings for the company.

\vspace{\baselineskip}
\noindent
In Section \ref{section:Makespan Scheduling-content} of Chapter \ref{chapter: 2-Evaluating Royal Mail Historical Data}, the solution of the Makespan Scheduling formulation provides us with a schedule that featured a minimised makespan. This translates to a more balanced schedule that will prevent employees working overtimes hence improving their general quality of life at work. The following model involved a formulation that attempted to minimise the number of duties required to execute the workload at hand. As seen in Sections \ref{section:minimise duties}-\ref{section: maximise blocks} the solutions provided, outlined a series of schedules that improved on the current schedule both on the employee quality of life and company cost-savings fronts. Namely, the schedules generated by formulation (\ref{equation: Minimise Duties}) minimised the number of duties required. Consequently, the majority of employees could afford to work marginally less, since there were less duties to be completed, and concurrently, Royal Mail could have cost-savings from the reduction in duties since it might possible to place some willing employees to a part-time work schedule. Similarly, formulation (\ref{equation: M3}) maximised the number of blocks that can be processed as we decrease the maximum duty length of the schedule. Our findings indicated that we can generally afford a reduction in the maximum duty length without impacting our processing capacity significantly. Hence, provided Royal Mail is able to implement such schedules with a reduction in the maximum duty length we will have generated an improvement in the quality of life of employees as well as possibility for cost-saving by placing employees on part-time duties.

\vspace{\baselineskip}
\noindent
Finally in Chapter \ref{chapter:Benchmark Instances} we make the first steps towards the formulation of a schedule that is concurrently efficient with respect to the makespan criterion but also remains robust against uncertainty. We start by applying uncertainty components of various sizes to the schedule generated through formulation (\ref{equation: Makespan Scheduling}) of Section \ref{section:Makespan Scheduling-content}. We then optimise those schedules with the Makespan Scheduling formulation. We then compare the optimised disturbed schedules with the recovered version of the nominal. We repeat the same process for schedules generated from two new formulations, the lexicographic and completion time squared models. In the end, we compare all three schedules and determine that the schedule that stems from the lexicographic optimisation is the most robust, and makes the smallest compromise in its makespan efficiency.

\section{Future Directions}
We conclude this final chapter by enclosing directions for future exploration that were deemed to be worthwhile for further research, upon conversation with our \textit{industrial liaison}, Royal Mail. These ideas are largely an extrapolation of the work presented in this dissertation in the direction of a more practical application of the ideas developed in this report. The fulfilling of the directions outlined below would render our solutions more realistically applicable from the perspective of Royal Mail, since they involve the addition of practical constraints faced by Royal Mail. In contrast the work of this dissertation is largely theoretical and is hopes to discover the theoretical boundaries for optimisation that exist in the context of the problem that we have studied.

\subsection*{Scheduling Meal-Reliefs}
\label{section: Addition of the Meal Relief Constraint}
The first direction for future investigation concerns the provision of schedules that comply with the Meal-Relief constraint enforced by EU regulations around \textbf{driving} and \textbf{working time directives}, as seen in Appendix \ref{section: EU rules}. Meal-Reliefs are one of the activities observed in the data, as seen in Chapter \ref{chapter: Problem Definition}. However, for the purposes of the Meal-Relief constraint, they are considered a special kind of activity since their location inside a schedule dictates whether the overall schedule is compliant with the EU regulations. Consequently, the decision regarding the time that these activities are scheduled involves the addition of a new type of scheduling constraint.

\vspace{\baselineskip}
\noindent
In practice, this involves the addition of two new scheduling constraints to our models, one for the driving time and one for the working time directives. These two constraints will render certain schedules infeasible if they do not satisfy both directives.

\vspace{\baselineskip}
\noindent
Even though it is extremely interesting to explore from an algorithmic point of view, after consulting with our industrial liaison, we determined that it was out of scope for the purposes of this dissertation. Our goal through this project is to provide schedules that explore the boundaries of what is possible in the context of this problem. In contrast, choosing to implement the Meal-Relief constraint would allow us to search for efficient schedules from within a rather narrow subset of the overall feasible set, hence preventing us from approaching the boundaries of global optimally. Moreover, as we were informed by the Royal Mail Scheduling staff, enforcing the Meal-Relief constraint, is largely an \textit{ad-hoc} operation that they tend to perform at the last stage of the schedules' design, which also takes into account the various peculiarities related to each MC's fleet of drivers. For instance, drivers at each MC may be accustomed to taking their Meal-Relief breaks only at specific locations and at specific times within their duty. Hence, enforcing a high-level version of the Meal-Relief constraint that does not take into account those minor but important details would not prove effective in reality. As a result, focusing on further exploring this aspect of the problem without considering such human factors that are not captured by the dataset, and can only be examined within Royal Mail's infrastructure was determined to be not worthwhile pursuing at this stage of the project.

\vspace{\baselineskip}
\noindent
Provided, that we can gain access to this information and consult with each MC's stakeholders to take into account their requests, and implement them in the form of various optimisation constraints, the enforcement of the Meal-Relief constraint can be reduced down to a mere addition of a constraint to our model. The \textbf{working time directive} is to be respected by making sure that the \textbf{duration} of a \textit{duty} is compliant with the regulation. On the contrary the \textbf{driving time directive} is examined at the \textbf{block} level, and has to be respected between adjacent blocks.  The collection of travel legs featured within each block are those that determine the feasibility component, regarding the \textbf{driving time} regulation.

\subsubsection*{Driving Time Directive}

\vspace{\baselineskip}
\noindent
Ideally, it should take place at the end of a shift, at which point the \textit{driving time} limit has been exhausted. However, in the case that prior blocks have consumed a large part of the 4.5 hour driving buffer such that the following block would violate the regulation, the meal relief has to be brought forward, and scheduled between the blocks.

\subsubsection*{Working Time Directive}

 Technically, \texttt{Meal-Relief} activities, are at the moment actually scheduled inside the blocks featured in our proposed schedules since as explained in the Data Cleaning section (\ref{section: Data Cleaning}) the \texttt{Meal Relief} activity was one of the \textbf{useful} activities that we preserved insider our blocks during the Data Cleaning procedures we followed. Hence, as far the implementation of the Meal Relief Constraint is concerned, rendering our \textit{proposed schedules} legal with respect to this constraint is simply a matter of moving the \texttt{Meal Relief} activities in the right place within the space of a duty.

 \vspace{\baselineskip}
\noindent
 Moreover, we anticipate that the addition of these constrains to our models, will make the process of finding an optimal solution less complicated, as opposed to without them since we will be essentially \textit{tightening our feasible space}, hence it will relatively more straightforward to obtain an optimal solution.

\vspace{\baselineskip}
\noindent
Upon conversation with our industrial liaison (Royal Mail), we decided to forego the desire to explore the \textbf{Meal Relief} constraint, as it was deemed merely a practical contribution that would not particularly expand the theoretical frontier for what is possible.

\subsection*{Vehicle Routing Considerations}
As was discussed in the introductory chapters we do not particularly focus on the \textit{Vehicle Routing} component of the problem. By additionally implementing the \textit{routing} component, we wish to extend the aspects of the problem captured in our model, a critical sub-problem in the majority of distribution network problems.

\vspace{\baselineskip}
\noindent
We briefly investigated a glimpse of the routing aspect of the problem in section \ref{section: Pre-emptive}, where the implementation of the pre-emptive philosophy did in fact result into a \textit{re-routing} of the routes followed by drivers. However, numerous experiments that are specifically focused on the solution of the \textit{routing} problem are required to acquire an accurate and insightful understanding of the problem through this point of view.

\vspace{\baselineskip}
\noindent
 As explained, in the Data Cleaning section (\ref{section: Data Cleaning}), we eliminated certain attributes from each data entry of the dataset that were not helpful when looking at the problem from the \textit{scheduling perspective.} As seen in Appendix \ref{subsection: Eliminated Attributes} one out of those eliminated attributes, consisted of information regarding the distance between locations visited by the HGVs. In solving this problem, one could use this information and form the problem through the concept of a \textbf{graph}. \textit{Edges}, of this graph would represent the \textit{time} and \textit{distance} between locations and \textbf{nodes} would represent the various external locations themselves. Plotting these graphs, one could then rearrange the \textbf{routing} aspect of the problem to make efficiency gains.

\subsection*{Incorporating Deadline Constraints}
During the initial data cleaning stages of the project we observed the existence of certain blocks that contained trips that were bound with a deadline with respect to the time of their completion. Namely, such trips involve the delivery of time-sensitive packages. As explained in Section \ref{section: Data Cleaning} of Chapter \ref{chapter: Problem Definition} this packages often refer to trips to the airport, which are by nature time-constrained.

\vspace{\baselineskip}
\noindent
However, as explained in Section \ref{section: Data Cleaning} we decided to ignore such data that is related to \textbf{time-constrained packages} and determine it us out of scope for the purposes of our project. The rationale behind this decision is founded in the fact that to satisfy our objective of finding the available room for optimisation we demand total freedom as far as our ability to move the blocks from duty to duty.

\vspace{\baselineskip}
\noindent
Nevertheless, the exploration of such time-constrained trips would be of significant interest both for researchers but also for Royal Mail. For researchers such a task poses great methodological potential. Namely, these time-sensitive round-trips would place certain blocks rigidly inside the spectrum of a duty such that the solver cannot relocate them. In practice, it would be implemented as an additional optimisation constraint. As our result, this would further shrink the feasible set allowing the scheduler less room for the exploration of the optimisation bounds. From the perspective of Royal Mail, the incorporation such constraints would be highly valuable since it would make our proposed schedules more realistic. Moreover, those schedules would be easier to implement since Royal Mail's operators would not have to heuristically add those constraints and re-order the duties' sequences so that those blocks are placed rigidly in the right place.

\subsection*{Incorporating Ellipsoid Uncertainty Sets}
As mentioned in the evaluation chapter (\ref{chapter: Evaluation}) due to the fact the study of uncertainty was a late addition to the topics explored we decided not to proceed with the addition of ellipsoid uncertainty set-based components. However, we believe that the study of the effects the application of an ellipsoid-based uncertainty components is a direction for future research that should definitely be tapped.

\vspace{\baselineskip}
\noindent
In greater detail, we believe that the ellipsoidal nature of such uncertainty components would introduce an additional methodological interest to our problem. In greater detail, the addition of ellipsoidal uncertainty sets will transform the study of the robustness of the target model\footnote{The model to which the uncertainty component is applied} to the process of solving conic quadratic problems \cite{Ben-Tal2000}. Moreover, the analysis of the effects of ellipsoidal uncertainty sets can be used as a further stepping stone for the approximation of the effects of more complex uncertainty sets\cite{vertsimas}.

Report/.tex files/[end] - Future Work/Future Work.tex


\section{Genetic Operators}\label{sec:genetic_operators}
As has been mentioned, genetic operators are applied to members of an existing population to generate a new population. For this assignment the operators used included reproduction, crossover and mutation. As detailed by Koza and Poli \cite{koza2005genetic}, these operators can be briefly summarized as follows:

\begin{itemize}
    \item Reproduction: Copy the selected individual program to the new population as is.
    \item Crossover: Create offspring for the new population by combining randomly chosen parts from two selected programs.
    \item Mutation: Create one new offspring for the new population by randomly mutating a randomly chosen part of a selected individual.
\end{itemize}

Of course, these operators will not be used uniformly to generate new populations. Rather, every operator is associated with a probability which determines the likelihood that it will be used to select the next individual for the new population. Specifically, the probability for crossover was 0.9, the probability for mutation was 0.05 and the probability for mutation was also 0.05.

In addition, when applying operators decisions must be made regarding whether to select terminal (leaf) or non-terminal (internal) nodes. The probability for selecting a terminal node was chosen as 0.1 whereas the probability for selecting a terminal node was chosen as 0.9.

Finally, a maximum tree depth of 16 was applied as a constraint to the individuals of a new population. In the case of crossover and mutation, the operators would not try to produce a valid individual more than once before failing.

With the selection methods and genetic operators having been identified, figure \ref{fig:breeding_pipeline} depicts the entire breeding pipeline for generating a new population from an existing population.

\begin{figure}[H]
\centering
\includegraphics[width=\textwidth]{report/6_genetic_operators/breeding_pipeline.png}
\caption{Breeding Pipeling}
\label{fig:breeding_pipeline}
\end{figure}


\section{Fission model algorithm.}

\hspace{1.0em}The Monte Carlo procedure of calculation of characteristics of
fission fragments can be outlined as following:
\begin{itemize}
\item Select fission mode (symmetric or asymmetric).
Sample atomic number $A_f$ of a fission
fragment according to experimentaly defined distribution, which consists
from the "symmetrical" and "asymmetrical" parts;
\item For choosen $A_f$ randomly in accordance with
Gaussian distribution and the experimentaly defined
dispersion and average
 select the fragment charge $Z_f$;
\item For
choosen $A_f, Z_f$ sample
the kinetic energy of fragments
 according to the Gaussian
distribution
 with experimentaly defined average values
and dispersions;
\item Applying energy conservation and using fragment ground state masses
calculate excitation energy of fragments and share it between fragments
assuming that fragments have equal temperatures;
\item Calculate absolute value of the c.m.
fragment momentumeach(non-relativistic kinematics
is used) and sample fragment flay off angles assuming isotropical
angular distribution of fragments;
\item Perform evaporation for the excited fragments.
\end{itemize}


\subsection{Second pre-image attacks}

Given \(m_1\), can we find \(m_2\) with same hash?

\subsubsection{Defence from second pre-image attacks}


\documentclass[11pt, oneside]{article}   	% use "amsart" instead of "article" for AMSLaTeX format
\usepackage{geometry}                		% See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                   		% ... or a4paper or a5paper or ...
\usepackage{graphicx}				% Use pdf, png, jpg, or eps§ with pdflatex; use eps in DVI
\usepackage{caption}
\usepackage{amssymb, amsmath}
\usepackage{algorithmic}
\usepackage{filecontents}

\begin{filecontents}{bibliography.bib}
@inproceedings{goodrich2010randomized,
  title={Randomized shellsort: A simple oblivious sorting algorithm},
  author={Goodrich, Michael T},
  booktitle={Proceedings of the twenty-first annual ACM-SIAM symposium on Discrete Algorithms},
  pages={1262--1277},
  year={2010},
  organization={Society for Industrial and Applied Mathematics}
}
\end{filecontents}

\title{Secure MPC Protocol for Randomized Shell Sort}
\begin{document}

\maketitle

Randomized shell sort is an oblivious sorting algorithm, developed by Michael Goodrich \cite{goodrich2010randomized}. While the paper should be referred to for a full description of the algorithm and its analysis, the following is designed to be a general introduction to the algorithm, based on its more thorough description in Goodrich\cite{goodrich2010randomized}. It additionally describes how it is implemented in JIFF in a secure manner.

\section{Randomized Shellsort}

Recall that insertion sort is an $O(n^2)$ sorting algorithm with the following (simplified) pseudocode:

\begin{center}
\begin{algorithmic}
\STATE{Given input array $A$, let $n$ be the length of $A$ and let $B = A[0].$}
\FOR{$i$=1 to $n-1$}
	\STATE{Check each element of $B$ against $A[i]$ and insert $A[j]$ into $B$ so that the $B$ preserves its order.}
\ENDFOR
\end{algorithmic}
\end{center}

The traditional Shellsort sorting algorithm relies on the idea that insertion sort performs better on partially sorted lists. (Note, for example, that shell sort on a fully sorted list will have $O(n)$ runtime since each element only needs to be compared to the adjacent element). A traditional Shellsort algorithm uses this idea, and does a series of insertion sort algorithms on subsets of the array, where each subset is chosen by taking every ``$o^{\text{th}}$" element of the array ($o$ stands for ``offset"). In pseudocode, given array $A$ indexed from $0$ to $n-1$ and offset values $o_1,\ldots,o_p$ such that $o_i < n$,

\begin{center}
\begin{algorithmic}
\FOR{$i=1$ to $p$}
	\FOR{$j=0$ to $o_i - 1$}
	\STATE{Sort the subarray of $A$ with indices $j, j+o_i, j+2o_i,...$ with insertion sort}
	\ENDFOR
\ENDFOR
\end{algorithmic}
\end{center}

Whether or not this is efficient depends on what series of offsets $o_1,\ldots, o_p$ is chosen. The idea behind \textit{randomized} Shellsort is to fix the offset sequence as $O = {n/2, n/4, n/8,\ldots,1}$, then compare pairs of regions $A_1$ and $A_2$ by randomly permuting the order and then doing comparisons and exchanges based on this random permutation, as shown in Fig.~\ref{fig:compare-exchange}.

\begin{figure}
	\begin{center}
	\includegraphics{compare-exchange}
	\caption{Compare-exchange operation. The dotted lines indicate the items that will be compared to one another, under (a) the identity permutation and (b) a random permutation for each pair of adjacent regions. Image from Goodrich \cite{goodrich2010randomized}.}
	\label{fig:compare-exchange}
	\end{center}
\end{figure}

Which pairs of regions are to be compared are chosen based on a schedule as follows:

\begin{figure}[!h]
	\begin{center}
	\includegraphics[scale=0.7]{shellsort}
	\caption{Randomized Shellsort pseudocode from Goodrich \cite{goodrich2010randomized}.}
	\end{center}
\end{figure}

As shown by Goodrich, this randomized Shellsort has, with high probability, a runtime of $O(n \log n)$ \cite{goodrich2010randomized}.

\section{Our Secure Implementation}

We securely implement randomized Shellsort on an array which is the element-wise sum of some number of input arrays. Since the algorithm is oblivious in the sense that everything other than the compare-exchange operation do not require knowledge of the underlying data, the majority of the algorithm may be performed without any special tools. Thus, the only portion of our implementation that requires use of the MPC library is the initial element-wise summation of the arrays and the compare-exchange operation.

The only other nuance to this implementation is in the randomization. Since the secret-sharing that underlies the compare-exchange operations occurs in parallel for all parties, all parties must do compare-exchanges on the same elements. In other words, the random permutations that the parties do must be fixed before the computations begin. In this demo, this is handled by having the first party send out a random string to all parties, who listen for that message. All parties then use this shared random string to determine the comparisons.

\bibliographystyle{acm}
\bibliography{bibliography}
\end{document}