% !TEX root =  main.tex

%\section{Benchmark Games}

%The \pgsolver library contains a few programs that create benchmarks for the parity game
%solvers. They are built using the command
%\begin{verbatim}
%    ~/pgsolver> make generators
%\end{verbatim}
%and reside afterwards in the subdirectory \texttt{bin}.
%
%Additionally, it is possible to compile all generators directly into \pgsolver by setting
%the variable \texttt{LINKGENERATORS} to \texttt{YES} in the \texttt{./Config}-file. This
%has the advantage that the process of generating and solving a game is not slowed down by
%formatting the game first and parsing it afterwards again into the same data structure.

\section{Random Games}

\subsection{A Na\"{\i}ve Model}
Randomly generated parity games are the simplest form of benchmarking utility to assess the
performance of game solvers. The ones used here are parametrized by four parameters: the number
$n$ of nodes in the game, the highest priority $p$, a lower and an upper bound $l$ and $u$ on the
out-degree of each node. The call
\begin{verbatim}
    ~/pgsolver> bin/randomgame 1000 200 2 5
\end{verbatim}
creates a random game with 1000 nodes as follows: for each node $v$,
\begin{itemize}
\item the priority $\Omega(v)$ is uniformly chosen among $\{0,\ldots,200\}$;
\item node $v$ belongs to player $0$ with probability $0.5$ and therefore to player $1$ with
      probability $0.5$ as well;
\item a number $d$ is uniformly chosen in the range $\{2,\ldots,5\}$, and $d$ pairwise different
      nodes are uniformly chosen as $v$'s successors.
\end{itemize}
Beware that \texttt{bin/randomgame} may crash or not terminate if the lower bound on the outdegree
is greater than the upper bound or that one is greater than the number of nodes.

\subsection{Clustered Random Games}

Almost every game created by the random generator above consists of a single big SCC and many adhesive
chains.

Therefore this generator uses an other random model that accomplishes to bring a bit more structure into its instances. It depends on nine parameters: The number of nodes $n$, the highest possibly occurring priority $p$, an out-degree range $(l;h)$, a recursion depth $r$, a recursion breadth range $(a;b)$ and an interconnection range $(x;y)$. An instance of $\mathcal{G}^c_{(n,r)}$ with $c = (p,l,h,a,b,x,y)$ can be generated as follows. If $r = 0$ or $a > n$ simply return a randomly generated game with $n$ nodes, highest priority $p$ and out-degree bounds $l$ and $h$ as above. If $r > 0$ and $a \leq n$,
\begin{itemize}
\item a number $d$ is uniformly chosen in the range $\{a,\ldots,\min(b,n)\}$;
\item $d$ numbers $k_0,\ldots,k_{d-1}$ are uniformly chosen in the range $\{0,\ldots,n-1\}$ s.t.\ $\sum_{i=0}^{d-1} k_i = n$;
\item $d$ instances $G_0,\ldots,G_{d-1}$ are chosen, where $G_i$ is chosen from $\mathcal{G}^c_{(k_i,r-1)}$ (we assume the nodes of all $G_i$ to be pairwise different);
\item a game $G$ is created by the union of all $G_i$;
\item a number $e$ is uniformly chosen in the range $\{x,\ldots,y\}$;
\item $e$ additional uniformly chosen edges in $G$ are added to $G$;
\item the game $G$ is returned.
\end{itemize}

Basically, this recursive approach creates a topological tree structure that is partially intercepted by adding the additional interconnection edges.

A clustered random game with 1000 nodes, highest priority 2, out-degree bounds 2 and 5, recursion depth 3, recursion breadth between 4 and 6 and interconnection degree between 11 and 22 is created using the call
\begin{verbatim}
    ~/pgsolver> bin/clusteredrandomgame 1000 200 2 5 3 4 6 11 22
\end{verbatim}

\subsection{Steady Random Games}

The Steady Random Generator tries to circumvent many universal optimisations in order to particularly
benchmark the backend solvers. The Steady Random Generator is parametrized by five parameters: the number
$n$ of nodes (and different priorities) in the game, a lower and an upper bound and on the
out-degree of each node and a lower and an upper bound and on the in-degree of each node. The call
\begin{verbatim}
    ~/pgsolver> bin/steadygame 1000 2 4 3 5
\end{verbatim}
creates a random game with 1000 nodes as follows: for each node $v$,
\begin{itemize}
\item the priority $\Omega(v)$ is simply $v$;
\item node $v$ belongs to player $0$ with probability $0.5$ and therefore to player $1$ with
      probability $0.5$ as well;
\item a number $d$ is uniformly chosen in the range $\{2,\ldots,4\}$, and $d$ pairwise different
      nodes are uniformly chosen in $v$'s subgame as $v$'s successors;
\item a number $d$ is uniformly chosen in the range $\{3,\ldots,5\}$, and an attempt is made to ensure
      that $v$ has $d$ pairwise different predecessors.
\end{itemize}
All edges are iteratively determined as long as there are at least two different nodes with one of them violating
a lower bound and the other one being below the opposite upper bound uniformly between two such nodes.

\section{Special Graph Structures}

\subsection{Clique Games}

The clique game of order $n$ is $G_n = (\{0,\ldots,n-1\},\{0,2,4,\ldots\},\{1,3,5,\ldots\},E,\Omega)$
with $E = \{ (v,w) \mid v \ne w \}$ and $\Omega(v) = v$. It forms a clique in a directed graph without
self-cycles. Clique games exhibit a large amount of cycles in the game which may pose difficulties
for certain solvers. Note that adding self-cycles to the nodes will result in easy solving because
self-cycles are partial winning strategies in this case, and then all other nodes would lie in the attractor
of these winning regions.

The clique game of order $50$ for instance is generated as follows.
\begin{verbatim}
    ~/pgsolver> bin/cliquegame 50
\end{verbatim}
The clique game of order 50 with self-cycles can also be generated.
\begin{verbatim}
    ~/pgsolver> bin/cliquegame 50 self
\end{verbatim}

\subsection{Ladder Games}
\label{sec:laddergame}

The name of these games is derived from their structure which is reminiscent of a ladder. The
\emph{ladder game} of index $n$ is $G_n = (V,V_0,V_1,E,\Omega)$, defined as follows.
\begin{itemize}
\item $V = \{0,\ldots,2n-1\}$,
\item $V_0 = \{0,2,4,\ldots,2n-2\}$, $V_1 = \{1,3,5,\ldots,2n-1\}$,
\item $E = \{ (v,w) \mid w \equiv_{2n} v+i $ for some $i \in \{1,2\}$ $\}$,
\item $\Omega(v) = v \mod 2$.
\end{itemize}
where $\equiv_{2n}$ means equality modulo $2n$.

It is not hard to see that player $0$ wins on $V_0$ and player $1$ wins on $V_1$ since both can
stay within these regions and only see the priorities $0$, resp.\ $1$.

Ladder games are chosen as benchmarks because in $G_n$ there are $2^n$ many positional strategies for each
player but only one of them is a winning strategy. Not surprisingly, ladder games are very difficult
to solve for the strategy guessing heuristic for example.

The ladder game of index 19 is created using the call
\begin{verbatim}
    ~/pgsolver> bin/laddergame 19
\end{verbatim}

\section{Hard Games for Particular  Algorithms}

\subsection{Jurdzi{\'n}ski Games}
\label{sec:jurdgame}

Jurdzi{\'n}ski has defined a family of games on which the small progress measures algorithm
exhibits an exponential running time \cite{Jurdzinski/00}. The Jurdzi{\'n}ski game $J_{d,w}$ of depth
$d$ and width $w$ forms a rectangle of dimension $(2d+1) \times (2w)$. For instance, $J_{50,100}$
is generated by calling
\begin{verbatim}
    ~/pgsolver> bin/jurdzinskigame 50 100
\end{verbatim}

% \begin{figure}[t]
% \begin{center}
% \scalebox{0.6}{\input{graphics/marcingame.eepic}}
% \end{center}

% \caption{The Jurdzi{\'n}ski games.}
% \label{fig:marcingame}
% \end{figure}

\subsection{Recursive Ladder Games}

%\include{pgfgraphics}

% \begin{figure}[t]
% \begin{center}
% \pictrecursiveladder
% \end{center}
% \caption{The recursive ladder game of index 4.}
% \label{fig:recursiveladder}
% \end{figure}

The recursive ladder games form a family on which the recursive algorithm exhibits an exponential
running time.  The recursive ladder game of index $n$ has size $5 \cdot n$.
% We omit a formal
% definition here. The construction can easily be inferred from Fig.~\ref{fig:recursiveladder}. Inside
% the nodes it shows the node's identifier (left of the colon) and its priority.
The recursive ladder game of index 4 results in 20 nodes and is generated by calling
\begin{verbatim}
    ~/pgsolver> bin/recursiveladder 4
\end{verbatim}

\subsection{Exponential Strategy Improvement Games}

The exponential strategy improvement games form a family on which both strategy improvement algorithms
exhibit an exponential running time (in the index of the game) \cite{FriedmannSI09}.
The exponential strategy improvement game of index $n$ has size $14 \cdot n + 11$.
% We omit a formal definition here. The game of index 2 is depicted in Fig.~\ref{fig:expstratimpr}.
% Inside the nodes it
%shows the node's identifier (left of the colon) and its priority.
A game of index 4 results in 67 nodes and is generated by calling
\begin{verbatim}
    ~/pgsolver> bin/expstratimpr 4
\end{verbatim}

In order to verify that the strategy iteration indeed requires exponential runtime on these games, you
need to either disable all generic optimisations or transform the game using the \texttt{transformer}
tool with the parameters \texttt{-ss -ap -bn}.

% \begin{landscape}
% % \pagenumbering{none}
% \begin{figure}[t]
% \begin{center}
% \pictexpstratimpr
% \end{center}
% \caption{The exponential strategy improvement game of index 2.}
% \label{fig:expstratimpr}
% \end{figure}
% \end{landscape}

\subsection{Model Checker Ladder Games}

The model checker ladder games form a family on which the model checker algorithm exhibits an
exponential running time.  The model checker ladder game of index $n$ has size $4 \cdot n$.
% We omit a formal definition here. The construction can easily be inferred from
% Fig.~\ref{fig:modelcheckerladder}.
%Inside the nodes it shows the node's identifier (left of the colon) and its priority.
A model checker ladder game of index 3 results in 12 nodes and is generated by calling
\begin{verbatim}
    ~/pgsolver> bin/modelcheckerladder 3
\end{verbatim}

% \begin{figure}[h]
% \begin{center}
% \pictmodelcheckerladder
% \end{center}
% \caption{The model checker ladder game of index 3.}
% \label{fig:modelcheckerladder}
% \end{figure}

\section{Verification Problems}

\subsection{Fairness of an Elevator System}

We encode a simple fairness verification problem as a parity game. States of a transition system modelling
an \emph{elevator} for $n$ floors are of type
$\{1,\ldots,n\} \times \{\mathtt{o},\mathtt{c}\} \times (\bigcup \{ \mathit{Perm}(S) \mid S \subseteq \{1,\ldots,n\})$.
The first component describes the current position of the elevator as one of the floors. The
second component indicates whether the door is \emph{open} or \emph{closed}. The third component -- a permutation
of a subset of all available floors -- holds the \emph{requests}, i.e.\ those floors that should be served next.
The transitions on these are as follows.
\begin{itemize}
\item At any moment, any request or none can be issued. For simplicity reasons, we assume that at most one floor
      is added to the requests per transition. Note that nondeterministically, no request can be issued, and a
      request for a certain floor that is already contained in the current requests does not change them.
\item If the door is open then it is closed in the next step, the current floor does not change.
\item If it is closed, the elevator moves one floor (up or down) into the direction of the first request. If the
      floor reached that way is among the requested ones, the door is opened and that floor is removed from the
      current requests. Otherwise, the door remains closed.
\end{itemize}
We consider two different implementations of this elevator model: the first one stores requests in FIFO
style, the second in LIFO style. The games $G_n$ (with FIFO), resp.\ $G'_n$ (with LIFO) result from
encoding the model checking problem for this transition system and the CTL$^*$ formula
$\mathtt{A}(\mathtt{GF}\mathit{isPressed} \to \mathtt{GF}\mathit{isAt})$ as a parity game
\cite{Stirling95}.  Proposition $\mathit{isPressed}$ holds in any state s.t.\ the request list contains
the number $n$, and $\mathit{isAt}$ holds in a state where the current floor is $n$. Hence, this
formula requires all runs of the elevator to satisfy the following fairness property: if the top floor
is requested infinitely often then it is being served infinitely often. It can easily be formulated in
the modal $\mu$-calculus using a formula of size $11$ and alternation depth $2$ (of type
$\nu$--$\mu$--$\nu$). Hence the resulting parity games have constant index 3.  Note that $G_n$
encodes a positive instance of the model checking problem whereas $G'_n$ encodes a negative one.
The game $G_4$ is generated by calling
\begin{verbatim}
    ~/pgsolver> bin/elevators 4
\end{verbatim}
and the game $G'_5$ by calling
\begin{verbatim}
    ~/pgsolver> bin/elevators -u 5
\end{verbatim}

\subsection{Synthesising a Traffic Light Controller}

Consider the following problem. Road work is blocking one line of traffic on a two-lined road. There are two traffic lights
controlling the flow of traffic into the narrow part from each side. We want to find a strategy for switching the traffic lights
which ensures that
\begin{itemize}
\item no car can enter the narrow part of road if there is an approaching car in this part already,
\item every car that appears at either end of the road works will eventually be able to pass.
\end{itemize}
This synthesis problem can be modelled as a simple model checking problem for the modal $\mu$-calculus and, hence, as a parity
game problem. Consider the transition system $\mathcal{R}_n$ with states of the form
\begin{displaymath}
(r_0,b_{\mathsf{left}},r_1,r_2\ldots,r_{n-2},b_{\mathsf{right}},r_{n-1},t)
\end{displaymath}
where
\begin{itemize}
\item $b_{\mathsf{left}},b_{\mathsf{right}} \in \{ \mathsf{red},\mathsf{green} \}$ model the two traffic lights,
\item $r_0,\ldots,r_{n-1} \in \{\mathsf{emp},\mathsf{carL},\mathsf{carR}\}$ model segments of the road which, at any moment,
      are either empty or occupied by a car driving into a particular direction, and
\item $t \in \{\mathsf{trLght},\mathsf{env}\}$ is used to indicate whether the next change of state can be
      a switching of the traffic light or a moving of the cars (seen as the \emph{environment} acting against the traffic light).
\end{itemize}
Transitions, labeled with actions, are as follows. First, both traffic light and environment can always choose not to do anything.
\begin{displaymath}
\Transition{(r_0,b_{\mathsf{left}},r_1,r_2\ldots,r_{n-2},b_{\mathsf{right}},r_{n-1},t)}{\mathsf{stay}}{(r_0,b_{\mathsf{left}},r_1,r_2\ldots,r_{n-2},b_{\mathsf{right}},r_{n-1},\overline{t})}
\end{displaymath}
where $\overline{t}$ denotes the actor that is not $t$, i.e.\ $\overline{\mathsf{trLght}} = \mathsf{env}$ etc.

When it is the traffic lights' turn, either light can change colour:
\begin{align*}
&\Transition{(r_0,b_{\mathsf{left}},\ldots,b_{\mathsf{right}},r_{n-1},\mathsf{trLght})}{\mathsf{swLght}}{(r_0,\overline{b_{\mathsf{left}}},\ldots,b_{\mathsf{right}},r_{n-1},\mathsf{env})} \\
&\Transition{(r_0,b_{\mathsf{left}},\ldots,b_{\mathsf{right}},r_{n-1},\mathsf{trLght})}{\mathsf{swLght}}{(r_0,b_{\mathsf{left}},\ldots,\overline{b_{\mathsf{right}}},r_{n-1},\mathsf{env})}
\end{align*}
where $\overline{\mathsf{red}} = \mathsf{green}$ etc.

Finally, when it is the environment's turn, any car that is already present can move forwards and free empty spaces at the sides can
be occupied by cars, modelled by transitions of the form
\begin{displaymath}
\Transition{(r_0,b_{\mathsf{left}},\ldots,b_{\mathsf{right}},r_{n-1},\mathsf{env})}{\mathsf{move}}{(r'_0,b_{\mathsf{left}},\ldots,b_{\mathsf{right}},r'_{n-1},\mathsf{trLght})}
\end{displaymath}
such that one of the following cases holds.
\begin{itemize}
\item $r_0 = \mathsf{emp}$, $r'_0 = \mathsf{carR}$
\item $r_0 = \mathsf{carR} = r'_1$, $b_{\mathsf{left}} = \mathsf{green}$, $r_1 = \mathsf{emp} = r'_0$
\item $\exists i$: $1 \le i \le n-3$, $r_i = \mathsf{carR} = r'_{i+1}$, $r_{i+1} = \mathsf{emp} = r'_i$
\item $r_{n-2} = \mathsf{carR}$, $r'_{n-2} = \mathsf{emp}$
\item $r_{n-1} = \mathsf{emp}$, $r'_{n-1} = \mathsf{carL}$
\item $r_{n-1} = \mathsf{carL} = r'_{n-2}$, $b_{\mathsf{right}} = \mathsf{green}$, $r_{n-2} = \mathsf{emp} = r'_{n-1}$
\item $\exists i$: $2 \le i \le n-2$, $r_i = \mathsf{carL} = r'_{i-1}$, $r_{i-1} = \mathsf{emp} = r'_i$
\item $r_1 = \mathsf{carL}$, $r'_1 = \mathsf{emp}$
\end{itemize}
In all cases, all unmentioned variables remain the same, i.e.\ we have $r'_j = r_j$ for those $j$ that are unaffected by these
conditions.

We use the following propositions to model elementary properties of such states of the form
$(r_0,b_{\mathsf{left}},r_1,\ldots,r_{n-2},b_{\mathsf{right}},r_{n-1},t)$.
\begin{itemize}
\item $\mathsf{green}_{\mathsf{left}}$ and $\mathsf{green}_{\mathsf{right}}$ hold in states in which the left, resp., right traffic
      light is set to green, i.e.\ $b_{\mathsf{left}} = \mathsf{green}$ etc.;
\item $\mathsf{wait}_{\mathsf{left}}$ and $\mathsf{wait}_{\mathsf{right}}$ hold in states in which the leftmost, resp.\ rightmost
      road segment, i.e.\ those that are guarded by the respective traffic lights, are occupied by a car: $r_0 = \mathsf{carR}$ or
      $r_{n-1} = \mathsf{carL}$;
\item $\mathsf{crash}$ holds when a car is given a green light despite the fact that the oncoming traffic has not passed yet:
      \begin{align*}
        &(r_0 = \mathsf{carR} \wedge b_{\mathsf{left}} = \mathsf{green} \wedge \exists i. 1 \le i \le n-2 \wedge r_i = \mathsf{carL}) \\
        \vee & (r_{n-1} = \mathsf{carL} \wedge b_{\mathsf{right}} = \mathsf{green} \wedge \exists i. 1 \le i \le n-2 \wedge r_i = \mathsf{carR})
      \end{align*}
\end{itemize}
The existence of a controller for the traffic lights, ensuring that no car is allowed to enter the narrow part of the road when
a car facing the opposite direction is in it, as well as absence of infinite waiting for the cars is expressed by the following
formula of the modal $\mu$-calculus.
\begin{align*}
\nu X_2.\mu X_1.\nu X_0. \neg\mathsf{crash} \wedge \Big(&\Mudiam{-}(\Mubox{\mathsf{stay}}X_0 \wedge \Mubox{\mathsf{move}}X_1)\ \vee \ \\
&\big( (\mathsf{green}_{\mathsf{left}} \vee \neg\mathsf{wait}_{\mathsf{left}}) \wedge
(\mathsf{green}_{\mathsf{right}} \vee \neg\mathsf{wait}_{\mathsf{right}}) \wedge \Mudiam{-}\Mubox{-}X_2\big)\Big)
\end{align*}
The parity game arising from the product of the road works system $\mathcal{R}_5$ for instance (with $5$ road segments) and the formula above can
be generated by calling
\begin{verbatim}
    ~/pgsolver> bin/roadworks 5
\end{verbatim}
This can be generalised to arbitrary parameters $n \ge 2$. The benchmark family can also be used directly in \pgsolver, for instance
for the road works system $\mathcal{R}_8$, by typing
\begin{verbatim}
    ~/pgsolver> bin/pgsolver -gen roadworksvergm "8" -local stratimprloc2 0
\end{verbatim}
Note that node $0$ represents the model checking problem for the formula above and $\mathcal{R}_n$'s initial state in which both lights
are set to $\mathsf{red}$ and no cars are present.

\section{Particular Problems Encoded as Parity Games}

\subsection{Towers of Hanoi}

The Towers of Hanoi problem can be seen as a reachability game in the graph of game configurations.
The problem of size $n$ has $n$ disks that are to be moved from the first to the third rod.
A problem of size $3$ is generated by calling
\begin{verbatim}
    ~/pgsolver> bin/towersofhanoi 3
\end{verbatim}

\subsection{Language Inclusion Between an NBA and a DBA}

Let $n,m \ge 2$, $\Sigma_n = \{a_1,\ldots,a_n\}$ and consider the language $L_{n,m}$ of all words over the alphabet
$\Sigma_n$ that contain infinitely many occurrences of $(a_i)^m$ for some $i \{ 1,\ldots,n\}$. This language is
accepted by the following NBA $\mathcal{A}_{n,m}$.
\begin{center}
\begin{tikzpicture}[thick,->,initial text={},every state/.style={shape=ellipse}, node distance=2.3cm]
  \node[state,initial]   (0)                    {$0$};
  \node[state]           (1) at ($(0)+(2,2)$)   {$1$};
  \node[state]           (n1) [right of=1]      {$n{+}1$};
  \node[state]           (2n1) [right of=n1]    {$2n{+}1$};
  \node                  (d1) [right of=2n1]    {$\ldots$};
  \node[state,accepting] (m2n1) [right of=d1]   {$(m{-}2)n{+}1$};
  \node[state]           (2) at ($(0)+(2,.5)$) {$2$};
  \node[state]           (n2) [right of=2]      {$n{+}2$};
  \node[state]           (2n2) [right of=n2]    {$2n{+}2$};
  \node                  (d2) [right of=2n2]    {$\ldots$};
  \node[state,accepting] (m2n2) [right of=d2]   {$(m{-}2)n{+}2$};
  \node[state]           (n) at ($(0)+(2,-2)$)  {$n$};
  \node[state]           (2n) [right of=n]      {$2n$};
  \node[state]           (3n) [right of=2n]     {$3n$};
  \node                  (dn) [right of=3n]    {$\ldots$};
  \node[state,accepting] (m1n) [right of=dn]   {$(m{-}1)n$};

  \node (ds1) at ($(0)+(2,-.5)$) {$\vdots$};
  \node (ds2) [right of=ds1] {$\vdots$};
  \node (ds3) [right of=ds2] {$\vdots$};
  \node (ds4) [right of=ds3] {};
  \node ()    [right of=ds4] {$\vdots$};

  \path (0)    edge [out=145,in=125,loop] node [above]                   {$\Sigma_n$} ()
               edge [out=90,in=180]     node [above,sloped]            {$a_1$}      (1)
               edge              node [above,sloped]            {$a_2$}      (2)
               edge [out=270,in=180]             node [above,sloped]            {$a_n$}      (n)
        (1)    edge              node [above]                   {$a_1$}      (n1)
        (n1)   edge              node [above]                   {$a_1$}      (2n1)
        (2n1)  edge              node [above]                   {$a_1$}      (d1)
        (d1)   edge              node [above]                   {$a_1$}      (m2n1)
        (2)    edge              node [above]                   {$a_2$}      (n2)
        (n2)   edge              node [above]                   {$a_2$}      (2n2)
        (2n2)  edge              node [above]                   {$a_2$}      (d2)
        (d2)   edge              node [above]                   {$a_2$}      (m2n2)
        (m2n2) edge [bend left=10]  node [very near start,sloped,below] {$a_2$}      (0)
        (n)    edge              node [above]                   {$a_n$}      (2n)
        (2n)   edge              node [above]                   {$a_n$}      (3n)
        (3n)   edge              node [above]                   {$a_n$}      (dn)
        (dn)   edge              node [below]                   {$a_n$}      (m1n);
%        (m1n)  edge              node [near start,sloped,above] {$a_n$}      (0);

  \draw[->] (m2n1) .. controls ($(m2n1)+(-2.3,-1.4)$) and ($(0)+(1.5,2.2)$) .. (0) node [near start,above] {$a_1$};
  \draw[->] (m1n) .. controls ($(m1n)+(-2.3,1)$) and ($(0)+(2,-2)$) .. (0) node [near start,above] {$a_n$};
\end{tikzpicture}
\end{center}
It is also accepted by the following deterministic B\"uchi automata $\mathcal{B}_{n,m}$.
\begin{center}
\begin{tikzpicture}[thick,->,node distance=2.3cm,initial text={},every state/.style={shape=ellipse}]
  \node[state,initial,accepting] (0)                        {$0$};
  \node[state,accepting]         (1)      [below of=0]      {$1$};
  \node                          (d1)     [below of=1,node distance=1.5cm]      {$\vdots$};
  \node[state,accepting]         (nm1)    [below of=d1,node distance=1.5cm]     {$n{-}1$};
  \node[state]                   (n)      [right of=0]      {$n$};
  \node[state]                   (np1)    [below of=n]      {$n{+}1$};
  \node                          (d2)     [below of=np1,node distance=1.5cm]    {$\vdots$};
  \node[state]                   (2nm1)   [below of=d2,node distance=1.5cm]     {$2n{-}1$};
  \node                          (d3)     [right of=n]      {$\ldots$};
  \node                          (d4)     [right of=np1]    {$\ldots$};
  \node                          (d5)     [right of=d2]     {$\vdots$};
  \node                          (d6)     [right of=2nm1]   {$\ldots$};
  \node[state]                   (mm1n)   [right of=d3]     {$(m{-}1)n$};
  \node[state]                   (mm1np1) [below of=mm1n]   {$(m{-}1)n{+}1$};
  \node                          (d7)     [below of=mm1np1,node distance=1.5cm] {$\vdots$};
  \node[state]                   (mnm1)   [below of=d7,node distance=1.5cm]     {$mn{-}1$};

  \path[->] (0)    edge node [above] {$a_1$} (n)
            (n)    edge node [above] {$a_1$} (d3)
            (d3)   edge node [above] {$a_1$} (mm1n)
            (1)    edge node [below] {$a_2$} (np1)
            (np1)  edge node [above] {$a_2$} (d4)
            (d4)   edge node [above] {$a_2$} (mm1np1)
            (nm1)  edge node [above] {$a_n$} (2nm1)
            (2nm1) edge node [above] {$a_n$} (d6)
            (d6)   edge node [above] {$a_n$} (mnm1);

  \path[->] (0)      edge                       node [sloped,above,near start]      {$a_2$} (np1)
            (n)      edge [bend right]          node [sloped,below]                 {$a_2$} (np1)
            (mm1n)   edge                       node [sloped,above,near start]      {$a_2$} (np1)
            (1)      edge                       node [sloped,above,near end]        {$a_1$} (n)
            (np1)    edge [bend right]          node [sloped,below]                 {$a_1$} (n)
            (mm1np1) edge                       node [sloped,above,near start]      {$a_1$} (n)
            (0)      edge                       node [sloped,above,near end]        {$a_n$} (2nm1)
            (n)      edge [bend right]          node [sloped,above,near start]        {$a_n$} (2nm1)
            (mm1n)   edge [bend right=5,in=170] node [sloped,above,very near start] {$a_n$} (2nm1)
            (nm1)    edge                       node [sloped,above,near start]      {$a_1$} (n)
            (2nm1)   edge [bend right]          node [sloped,below,near start]      {$a_1$} (n)
            (mnm1)   edge [in=-30,out=130]      node [sloped,above,very near start] {$a_1$} (n)
            (1)      edge                       node [sloped,below,near start]      {$a_n$} (2nm1)
            (np1)    edge [bend right]          node [sloped,below,near start]        {$a_n$} (2nm1)
            (mm1np1) edge                       node [sloped,above,near start]      {$a_n$} (2nm1)
            (nm1)    edge [in=220]              node [sloped,above,near start]      {$a_2$} (np1)
            (2nm1)   edge [bend right]          node [sloped,below]                 {$a_2$} (np1)
            (mnm1)   edge                       node [sloped,above,near start]      {$a_2$} (np1);

  \draw[->] (mm1n) .. controls ($(mm1n)+(-.3,1)$) and ($(0)+(.3,1)$) .. (0) node [near start,above] {$a_1$};
  \draw[->] (mm1np1) .. controls ($(mm1np1)+(-.3,-1)$) and ($(1)+(.3,-1)$) .. (1) node [near start,above] {$a_2$};
  \draw[->] (mnm1) .. controls ($(mnm1)+(-.3,-1)$) and ($(nm1)+(.3,-1)$) .. (nm1) node [near start,above] {$a_n$};
\end{tikzpicture}
\end{center}
The synchronous product of $\mathcal{A}_{n,m}$ and $\mathcal{B}_{n,m}$ is a parity game $\mathcal{G}_{n,m}$ in which
every node is owned by player $1$, and the priority of a node $(q,p)$ is given as
\begin{displaymath}
\Omega(q,p) \enspace = \enspace \begin{cases}
2 &,\text{if } p \text{ is accepting,} \\
1 &,\text{if } p \text{ is not accepting and } q \text{ is accepting,} \\
0 &,\text{otherwise.}
\end{cases}
\end{displaymath}
This is the standard encoding of fair simulation as a parity condition \cite{HenzingerKR02,HutagalungLL:LATA13}. This game
encodes the language inclusion problem between an NBA and a DBA. In this case, the game is entirely won by player $0$.

The game $\mathcal{G}_{6,9}$ is generated by
\begin{verbatim}
    ~/pgsolver> bin/langincl 6 9
\end{verbatim}
The second parameter is optional. If it is not given then $m=2$ is chosen by default.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "main"
%%% End:


\section{Results}
\label{sec:result}

%For a CP-even Higgs boson, the mean value of Optimal Observable is expected to be 0 for both signal and background process. So a direct and totally model independent measurement of Higgs CP could be obtained from this with data. Table ~\ref{tab:meanOO} shows the observed mean Optimal Observable value in data and the statistical uncertainties.

%\begin{table}[]
%\centering
%\begin{tabular}{ll}
%\hline
%         & \textless{}OO\textgreater{} \\ \hline \hline
%TT       &   $  0.014 \pm 4.004 $      \\ \hline
%TL       &   $ -0.004 \pm 3.895 $      \\ \hline
%LT       &   $ -0.013 \pm 3.752 $      \\ \hline
%LL       &   $ -0.006 \pm 3.879 $      \\ \hline \hline
%combined &   $ -0.003 \pm 3.763 $      \\ \hline
%\end{tabular}
%\caption{Mean values of Optimal Observable and statistical only uncertainty in 4 categories and their combination. }
%\label{tab:meanOO}
%\end{table}

A precise measurement of CP-mixing parameter $\tilde{d}$ is performed with a maximum likelihood fit described in Section ~\ref{sec:fit}. The parameter of interest $\tilde{d}$ is scanned with step of 0.01 and other nuisance parameters are adjusted within their allowed constraints. Table ~\ref{tab:dtilde_mu_obs} summarized the best fit signal strength and $\tilde{d}$ with statistical and systematic uncertainty. Expected results from MC is shown in Table ~\ref{tab:dtilde_mu_exp}. \\

The expected and observed $\Delta NLL$ curve is shown in figure ~\ref{fig:NLLcurve} as a function of $~\tilde{d}$. In the expected result the signal strength is set to 1, and $\tilde{d}$ is set to 0, corresponding to the best estimate of sensitivity of the analysis based on SM prediction. The contribution from 4 categories are shown with statistical only $\Delta NLL$ curve in Figure ~\ref{fig:NLLcurve_4cate}.

\begin{table}[]
\centering
\small
\begin{tabular}{lcccc}
\toprule
         & $\mu \pm unc.(stat.)$ &  $\tilde{d}\pm unc.(stat.)(68\% interval)$   & 95\% interval of $\tilde{d}$(stat.) & 95\% interval of $\tilde{d}$(stat.+syst.)  \\
\toprule
TT       &  $1.00\pm0.27 (0.25)$  &  $0.00^{+0.039(0.039)}_{-0.039(0.038)}$      &  $ [-0.092, 0.096] $                &  $ [-0.094, 0.099] $                       \\ \hline
TL       &  $1.00\pm0.36 (0.34)$  &  $0.00^{+0.062(0.061)}_{-0.062(0.061)}$      &  $ [-0.272, 0.254] $                &  $ [-0.295, 0.273] $                       \\ \hline
LT       &  $1.00\pm0.38 (0.35)$  &  $0.00^{+0.062(0.061)}_{-0.061(0.060)}$      &  $ [-0.303, 0.315] $                &  $ [-0.329, 0.337] $                       \\ \hline
LL       &  $1.00\pm1.12 (1.12)$  &  $0.00^{+1.407(1.197)}_{-1.293(1.148)}$      &  $ [-4.924, 5.071] $                &  $ [-5.551, 6.023] $                       \\
\bottomrule
combined &  $1.00\pm0.20 (0.17)$  &  $0.00^{+0.027(0.027)}_{-0.027(0.026)}$      &  $ [-0.057, 0.059] $                &  $ [-0.059, 0.060] $                       \\
\bottomrule
\end{tabular}
\caption{Expected results for signal strength and $\tilde{d}$. }
\label{tab:dtilde_mu_exp}
\end{table}

\begin{figure}[h]
  \centering
  \includegraphics[width=.7\textwidth]{figure/nll_allCats.png}
  \caption{Expected $\Delta NLL$ curve for combined result. }
  \label{fig:NLLcurve}
\end{figure}

\begin{figure}[h]
  \centering
  \includegraphics[width=.7\textwidth]{figure/nll_idvCats_syst.png}
  \caption{Statistical only $\Delta NLL$ curve for 4 categories. }
  \label{fig:NLLcurve_4cate}
\end{figure}


%• Results: What were the results? What could be deduced from the results? Uncertainty in
%the results? Do we now know everything?
This section presents the performed experiments, along with their respective results and evaluations. We first present results based on a subset of the datasets in section \ref{sec:evaluation}. We then present predicted energy profiles and total energy profiles for the complete dataset in section \ref{sec:complete},  we then present the same experiments done on the different datasets in section \ref{sec:days_end}. Later, in section \ref{sec:a_b} the learned basis functions are presented and discussed. Lastly, in section \ref{sec:quant} we present a quantitative evaluation by looking at the error and accuracy results.

\subsection{Experimental setup}

The conducted work used the data set provided by Pecan Street, and pre-processed as described in \ref{sec:prep}. We look at time periods in blocks of one week and two weeks while trying to predict the individual device consumption over the time period; given only the whole-home signal. Imperatively, we focus on disaggregating data from homes that are absent from the training set, where 70\% were assigned as the training set and 30\% as the test set; thus, attempting to generalize over the basic category of devices, not just over different uses of the same device in a single house. We fit the parameters $\lambda,\alpha$ for regularization and stepsize  respectively using grid search, namely by chosing the best parameters from the search of a discrete set of empirical values.

Due to insufficient computational power, most of the tests have not been run using enough basis functions. We have chosen to go through with the setup, as we wanted to see temporal difference using this algorithm and not particularly wanted to perfect the setup. We chose to select only 67 houses out of the 331 houses that could have been used for the experiment from the set of 689 houses within the dataset. As we need to have more basis functions than the dimensionality of the data, we have chosen to use more basis functions than houses ($n > m$). We have also excluded a monthly prediction, as it would again cause computational issues. We have however provided one 24-hour prediction with a small subset of all of the datasets using enough basis functions to see that the algorithm can discriminate on all the datasets.

\subsection{Evaluation of algorithm}

\label{sec:evaluation}
Here we will present the results qualitively obtained by the method. First we begin by showing the predictions on a small subset of the data (30 houses), to see that the algorithm can actually discriminate the appliances at hand for all of the datasets that will be investigated. Then we proceed with the weekly prediction shown in figure \ref{fig:normal_168}, which shows the true energy consumed for a week, along with the energy consumption predicted by the algorithms. Next we present the results for a two week prediction, shown in figure \ref{fig:normal_360}. The figures also show two pie charts presenting the percentage use of each appliance, one of which is the true usage and the other shows the predicted usage. Furthermore we show the results obtained when splitting the dataset into two components, one containing the data from weekdays and one consisting out of only hourly readings from weekends.

\pagebreak[4]
\centerline{\textbf{$T=$24 hours and $m=$30 houses and $n=$250 basis functions}}
\begin{figure}[H]
		\centering
		\textbf{Week}\vspace{0.00001in}
		\includegraphics[width=\textwidth,height=8cm]{./figures/normal_250_24}
		%\includegraphics[scale=0.20]{./figures/normal_250_24}
\end{figure}
\begin{figure}[H]
		\centering
		\textbf{Weekdays}\vspace{0.00001in}
		\includegraphics[width=\textwidth,height=8cm]{./figures/days_250_24}
	\end{figure}
\begin{figure}[H]
		\centering
		\textbf{Weekends}\vspace{0.00001in}
		\includegraphics[width=\textwidth,height=8cm]{./figures/end_250_24}
\end{figure}

\begin{figure}[H]
	\caption{The figure shows the true usage (blue) and predicted energy consumption (red) of all of the appliances for all datasets. The left hand plot shows the whole dataset used in predicting the 24 hours. The middle plot shows the weekdays dataset being predicted for 24 hours and the right hand plot shows the prediction for the weekend dataset.}
	\label{fig:subset}
\end{figure}

In all the cases the algorithm has found basis functions and activations to represent an energy consumption profile of all of the appliances. This goes to show that the implementation of the algorithm has been successful and that the algorithms do serve their purpose, more on the evaluation on the different algorithms is done further down in section \ref{sec:quant}. Interesting to note is that the algorithm has found some of the energy profiles of some appliances. Looking at the plot to the bottom left we see that the prediction has actually been proved to be almost in line with the true profile for 10 of the data points (10 hours). We can also see that the algorithm can output completely different profiles by looking at the refrigerator for the weekdays dataset compared to that of the air-condition profile for the week dataset.

\subsubsection{Results from the complete dataset}
\label{sec:complete}
\begin{figure}[H]
	\centering
	\textbf{$T=$168 hours and $m=$67 houses and $n=$80 basis functions}\par\medskip
	\begin{minipage}{.65\textwidth}
		\centering
		%\includegraphics[scale=0.18]{./figures/app_basis}
		\includegraphics[width=\textwidth,height=10cm]{./figures/results/normal_appliances_67_168}
	%	\label{fig:test8}
	\end{minipage}%
	\begin{minipage}{.4 \textwidth}
		\centering
		%\includegraphics[scale=0.18]{./figures/basis}
		\includegraphics[width=\textwidth,height=10cm]{./figures/results/normal_pie_chart_67_168}
	%	\label{fig:test9}
	\end{minipage}
	\caption{Example of one house true energy profile and the predicted energy profile over a one week time period. The plot to the left shows true and predicted energy profiles. The plot to the right shows a pie chart of the total percentage that each appliance true usage and predicted usage.}
	\label{fig:normal_168}
\end{figure}

In most cases, the predicted values are quite poor, and the overall accuracy was 0.29, by the definition in equation \ref{eq:acc}. It seems as though the algorithm has not gotten any type of pattern but rather unique constant energy consumption for each appliance. Both the dishwasher and the refrigerator have a consistent shape of being volatile and almost like noise. One thing to note is the shape of the predicted usage of other appliances, this shape is highly complex due to its peak like behavior and is one shape that is hard to try to learn without using methods such as sparse coding which says that the algorithm can be used for predicting the shapes. Although it has overestimated the usage of other appliances as we can see in the pie charts. However it has completely not learnt that air or furnace has not been used at all, which is a failure in the results, and only the refrigerator has roughly the same amount of percentage usage as the true usage. The "other" appliances can be seen as a good result when representing a complex structure such as a dishwasher usage we have captured the structure of a "on" and "off" behavior, even though we did not use enough basis functions, we can still represent a structure like it. It is however not a good result when predicting each appliance as well as the overall energy usage. It heavily overestimates the usage of "other" appliances as well as assumes a significant higher consumption on both the "other" appliances and the dishwasher.

\begin{figure}[H]
	\centering
	\textbf{$T=$360 hours and $m=$67 houses and $n=$144 basis functions}\par\medskip
	\begin{minipage}{.65\textwidth}
		\centering
		%\includegraphics[scale=0.18]{./figures/app_basis}
		\includegraphics[width=\textwidth,height=10cm]{./figures/results/normal_appliances_144_360}
		\label{fig:test8}
	\end{minipage}%
	\begin{minipage}{.4\textwidth}
		\centering
		%\includegraphics[scale=0.18]{./figures/basis}
		\includegraphics[width=\textwidth,height=10cm]{./figures/results/normal_pie_chart_144_360}
	\end{minipage}
	\caption{Example of one house true energy profile and the predicted energy profile over a two week time period. The plot to the left shows true and predicted energy profiles. The plot to the right shows a piechart of the total percentage that each appliance true usage and predicted usage.}
	\label{fig:normal_360}
\end{figure}

When the algorithm was tested on a two week set of hourly readings, the results were again poor and had a overall accuracy rate of 0.21. The house shows in the plot to the left of the figure \ref{fig:normal_360} has minimal consumption of the dishwasher and refrigerator, but it is visually hard to see as the predicted values are of a magnitude higher. The predicted shapes of the dishwasher and the refrigerator look more or less as a Brownian motion, same as for the prediction of one-week of data but here the predicted values are significantly higher. This behavior could come from the DDSC algorithm where we discriminate the whole signal, and the norm of the activations during this algorithm spikes significantly high, up to 25 000 from a mere 2211, as shown in figure \ref{fig:a_b_ddsc}. This could be that the algorithm overestimates the whole home usage and therefore predicts a higher consumption of the appliances. Furthermore, is that the basis functions are trained to represent the activations trained during this algorithm and that these overestimate some appliances like the dishwasher and the refrigerator seem to have, in both the case for the weekly predictions and of the two week predictions. We can see that all of the appliances are overestimated in their power consumption usage. However, when comparing the predictions for the two tests (week and two weeks) we see that in the later case we see that most of the appliances have been overestimated but in the first case we see that the "other" appliances have been heavily overestimated while both the air and the furnace have been predicted to not be in use at all. This could say that the algorithm can make a better prediction for more appliances when used on a larger dataset. When looking at the pie chart, representing the total percentage use of the predicted versus the true usage, we see from both of the tests, the refrigerator has had the best predicted values. This is probably due to the nature of a refrigerator having a consistent shape, rather than most energy consuming appliance, that have an "on" and "off" behavior.

%% weekdays

\newpage
\subsubsection{Results from weekdays and weekend hourly readings}
\label{sec:days_end}
\begin{figure}[H]
	\centering
	\textbf{168 hours and 67 basis functions \quad 360 hours and 144 basis functions}\par\medskip
	\textbf{Weekday dataset}
	\begin{minipage}{.45\textwidth}
		\centering
		%\includegraphics[scale=0.18]{./figures/app_basis}
		\includegraphics[scale=0.18]{./figures/results/days_appliances_67_168}
	\end{minipage}%
	\begin{minipage}{.45\textwidth}
		\centering
		%\includegraphics[scale=0.18]{./figures/basis}
		\includegraphics[scale=.18]{./figures/results/days_appliances_144_360}
	\end{minipage}
\end{figure}
%%% weekends
\begin{figure}[H]
	\centering
	\textbf{Weekend dataset}
	\begin{minipage}{.45\textwidth}
		\centering
		%\includegraphics[scale=0.18]{./figures/app_basis}
		\includegraphics[scale=0.18]{./figures/results/end_appliances_67_168}
	\end{minipage}%
	\begin{minipage}{.45\textwidth}
		\centering
		%\includegraphics[scale=0.18]{./figures/basis}
		\includegraphics[scale=.18]{./figures/results/end_appliances_144_360}
	\end{minipage}
	\caption{Prediction of the weekday (top plots) and weekend (bottom plots) dataset.}
	\label{fig:days_end}
\end{figure}

The figure \ref{fig:days_end} shows that the predictions have not been successful when it comes to the datasets of weekdays and weekends. It has predicted that only a few appliances use energy. The only successful prediction is the dataset of weekdays for predicting two weeks of consumption. One thing to note is that the prediction of the air-condition for this dataset is the best prediction of all of the tests. It follows the consumption fairly well, and could be a consequence of the usage of air-condition being more homogenous during weekdays than during a whole week. The weekend dataset has the worst prediction of all the datasets, it also preferred to choose one appliance when predicting for two weeks as the week dataset. The prediction failure for the split datasets could be a result of a diminishing of training data, as the splitting of the dataset also made the training set smaller which could be the cause of the bad predictions.

\subsubsection{Basis functions}
\label{sec:a_b}
In addition to the disaggregation results themselves, sparse coding representations of the different device types are interesting in their own right, as they give a good intuition about how the different devices are typically used. The figure \ref{fig:basis_functions} shows a graphical representation of the learned basis functions. In each plot, the gray scale image on the right shows an intensity map of all bases functions learned for that device category, where each column in the image corresponds to a learned basis.

\begin{figure}[H]
	\begin{center}

	\begin{minipage}{.5\textwidth}
		\centering
		%\includegraphics[scale=0.18]{./figures/app_basis}
		\includegraphics[width=\textwidth,height=12cm]{./figures/app_basis}
		\label{fig:test1}
	\end{minipage}%
	\begin{minipage}{.5\textwidth}
		\centering
		%\includegraphics[scale=0.18]{./figures/basis}
		\includegraphics[width=\textwidth,height=12cm]{./figures/basis}
		\label{fig:test2}
	\end{minipage}
	\caption{Example basis functions learned from one device. The plots to the left shows seven example bases, while the image to the right shows all learned basis functions.}
	\label{fig:basis_functions}
	\end{center}
\end{figure}

The plots to the left shows seven examples of basis function for each of the devices. By interpreting the basis functions one can see that refrigerator has a more continuous function applied to it, in contrast to the dishwasher, which has a peak attached to it. This indicates that the functions have captured behaviors, such as "on" and "off" of the refrigerator compared to both the furnace and refrigerator, which in turn we assume do not have "on" and "off" behavior. Kotler et. al. \cite{DDSC} also got basis functions more peaked for refrigerator, which indicate that the basis functions are reasonably representative. They have more heavily peaked functions, which could be from their intense training. It can be said about the furnace, which has some basis that have a peak, which could correspond to a use of the furnace for a temporarily heating of the household. The magnitude of the refrigerator is lower than that of a dishwasher, which says that we have also captured the intensity of power consumption.

The right plots show that the refrigerator is "on" most of the time but with low power as we can see that the plot has mostly grey and some black in it. We can see that the dishwasher has peaked behavior in that some of the basis are almost pure white and some are black. We find interesting behaviors in the representations of the furnace as some of the basis fucntions really do look the same indicating that some furnaces behave similar and in similar magnitude.

\subsection{Quantitative evaluation of the Disaggregation}
\label{sec:quant}

There are a number of components to the final algorithm, and in this section we present quantitative results that evaluate the performance of each of these different algorithms. The most natural metric for evaluating disaggregation performance is the disaggregation error in equation \ref{eq:diserr}, i.e. the overlap of the pie charts of true and predicted percentage energy consumption shown in the figures \ref{fig:normal_168}, \ref{fig:normal_360}. While many of the arguments can be put into the temporal difference, we show that the algorithm has not been able to find a local optimum either by not having a parameter search or training data have not been sufficient. Moreover, the average disaggregation error presented in equation \ref{eq:acc} is not a particularly intuitive metric, and so we also evaluate a total time period accuracy of the prediction system, defined formally as

\begin{equation}
\label{eq:acc}
\text{Accuracy} \vcentcolon=  \frac{\sum_{i,q} \min \left\{ \sum_p ( \mathbf{X}_i)_{pq}, \sum_p ( \mathbf{B}_i,\hat{\mathbf{A}}_i)_{pq} \right\}}{\sum_{p,q} \bar{\mathbf{X}_i}_{p,q}}
\end{equation}

Despite the complex definition, this quantity simply captures the average amount of energy predicted correctly over the time period (i.e., the overlap between the actual and predicted energy).

\begin{figure}[H]
	\centering
	\includegraphics[scale=0.45]{./figures/acc_err_ddsc}
	\caption{Evolution of the training accuracy and error for the DDSC updates. The figure shows the best prediction of all the runs of the algorithm.}
	\label{fig:acc_err_ddsc}
\end{figure}

Figure \ref{fig:acc_err_ddsc} shows the disaggregation performance for the DDSC algorithm \ref{alg:ddsc}. It presents the disaggregation error from equation \ref{eq:diserr} on the left y-axis and the accuracy given in equation \ref{eq:acc} on the right y-axis. Furthermore a linear regression has been done for both the error and accuracy. We note that the accuracy is around 35\% following the fitted line when the 100:th iteration has been done. From the figure we see that for each iteration, the algorithm has difficulty finding an optimal path towards a minimization as seen by the volatile behavior of both the error and accuracy. However, fitting a curve to the values, we see that the accuracy has a positive slope although with regards to a high variance for curve fitting, the plot shows that we cannot fully rely on the implementation due to its behavior. Investigating this further, we took a look at the activation and basis norms of the algorithm. This yielded the following figure.

\begin{figure}[H]

	\centering
	\includegraphics[scale=0.45]{./figures/a_b_norm}
	\caption{Evolution of the Activation and Basis norms for the DDSC updates. The norm of the Activations are seen on the left y-axis and the left y-axis is the Basis norm.}
	\label{fig:a_b_ddsc}
\end{figure}

The NNSC algorithm trains its activations separately for all of the appliances and yielded a norm of 2211 cumulatively for all of the appliances. We can see from the plot that when we start the DDSC algorithm the activation norms go from 2211 to around 25 000, which is probably due to the activations trying to adapt to the whole home energy consumption, which is vastly larger than each appliance. Interesting to note is that the basis norm slightly increases with each iteration, while the activations oscillate around 25 000. The activations trained are not used for the predicting the values for a new dataset, from this iteration we only take out the basis matrix which seems to have adapted itself by changing from a norm of 0.925 to 0.94.


% % Chapter 2: XAFS Simulations
% % Chapter 2: XANES
% \textit{In this section, I can write about XANES to a super in-depth extent, and likely the bulk of this chapter will be about FEFF and FDMNES theoretical calculations}
% \section{Maybe derivation of EXAFS Equation}
% \section{FEFF vs. FDMNES Approaches}
% \section{Theoretical XANES Calculations}
% -------------------------------------------------------------

Before making any predictions, neural networks must first be trained on a large quantity of data. In the context of this thesis, to teach our neural network to predict the mean squared displacement (MSD) from XANES, we must first assemble a collection of training data comprised of XANES spectra, each labeled with a known MSD. Gathering such a large quantity of high-quality experimental data would be impractically time-intensive and expensive. Instead, simulations provide a practical alternative, though even simulating each possible disordered structure is time-intensive. This process has been standard practice in theoretical XAFS work and discussed in section \ref{sec:traditional-disorder}.

We have conducted a significant amount of work in developing a new approach for simulating disordered XANES spectra. A discussion on the development of this new, statistical approach is presented in sections \ref{sec:start-disorder}--\ref{sec:end-disorder}. This new process is based on the statistical averaging of non-disordered structures. Instead of simulating hundreds of defined, disordered structures, we run many XANES simulations of simple, non-disordered structures and generate the disordered spectra via purposeful statistical averaging. In sections \ref{sec:start-disorder}--\ref{sec:end-disorder}, we explain this statistical weighting process in-depth, beginning with the creation of simple, non-disordered spectra for the FEFF input files and culminating in the creation of many possible disordered spectra with known MSDs. Finally, the efficacy and limitations of this approach are discussed in section \ref{sec:pa-feff-vs-gaussian-feff}.

\section{Traditional Particle-Averaged Simulations}
\label{sec:traditional-disorder}
We refer to the traditional method for running FEFF simulations as particle-averaged FEFF. The simulation software, FEFF9 \cite{feff-citation}, only simulates the absorption spectrum for one absorber at a time. For this project, we are interested, at first, in simulating bulk Au. Accordingly, we attempt to remove the surface effects on the spectrum by simulating the absorption of only the first shell atoms and averaging (arithmetic mean) the results. This way, the first shell absorber atoms are surrounded by bulk structure, allowing FEFF to minimize the contribution of surface effects which affect the potential and multiple scatterings differently than the bulk. We made the decision to first simulate bulk Au in order to reduce the number of confounding variables. If the statistical averaging technique works for simulating disordered bulk structures, the next stage would be to expand the process to nanoparticles.

Simulating absorption spectra via FEFF requires the creation of FEFF input files which include various user-defined parameters and the Euclidean coordinates of the structure. Determining how to create these structures is a project in and of itself. The approach taken for this experiment was to start with the perfectly ordered crystal of Au atoms. Then, for each structure, each individual atom is shifted by a random distance in a random direction. For each atom (in a given structure), the direction to be shifted is chosen from a uniform distribution, whereas the distance by which to shift the atom from its original location is chosen from a Gaussian. The standard deviation of the Gaussian from which the shifted distance is drawn differs from structure to structure. Thus, with a narrow width Gaussian, the shifted distances on average tend to be smaller than for a Gaussian with a large width. Therefore, structures with small MSDs tend to be created when the width of the Gaussian for shift distances is narrow, whereas high MSD structures tend to be created when the width of the Gaussian is wide. The code for this script can be found in Appendix \ref{app:gen-train-data}.

Absorption simulation software is far from perfect, especially for XANES. There are different ways to treat the electronic potential and Fermi energies of the structure, none of which work best in all circumstances. FEFF works by simulating Green's function. A more in-depth description of how FEFF works can be found in Appendix B. FEFF includes many user-defined parameters which can be tweaked to alter the resulting function. By comparing the resulting FEFF spectrum to a reference, experimental spectrum, an exhaustive grid search (parameter sweep) can be run to determine the best FEFF parameters for simulating a given structure. Each FEFF input file was run with the following parameters:

\vspace{2em}
\begin{minipage}{\linewidth}
	% Each FEFF input file is run with the following parameters:
	\begin{Verbatim}[samepage=true, numbers=left]
		SCF 4.6 0 30 .5 1
		EDGE    L3
		EXCHANGE    5   0.2 0.5
		S02 1.
		XANES   3.7 0.05    0.1
		FMS 7

		POTENTIALS
		0	79	Au	-1	-1	0.
		1	79	Au	-1	-1	0.
	\end{Verbatim}
	~
	\end{minipage}
\noindent An explanation for the meaning behind these parameters can be found in Appendix section \ref{app:feff-cards}.

While particle averaging is the traditional method for simulating XANES via FEFF, the method is computationally intensive for large structures with many absorbers. One advantage of developing a statistical averaging method would be the ability to create an infinite number of disordered XANES spectra from a limited number of simulations. For particle averaging, to create 1000 disordered structures requires 13,000 simulations\footnote{1000 structures $ \times $ 13 absorbers per structure = 13,000 simulations}, a process that necessitates several days of computation time on a dedicated distributed computing cluster.

\begin{figure}[h!]
	\centering
	\includegraphics[width=.7\linewidth]{Chapters/Figures/Bulk_experimental_vs_pa_comparison.png}
	\caption[Simulation vs. Experimental 3]{Comparing the bulk foil (red) measurement to a simulated large, bulk-like nanoparticle with the same disorder. The FEFF-simulated version underestimates the magnitude of the oscillations at lower energies.}
	\label{fig:avg-experimental-vs-simulation2}
\end{figure}

\section{Statistical-Averaged Simulations}
To expedite the process of simulating XANES spectra of disordered structures, we have developed a new methodology build on a statistical averaging of a few easily simulated structures.

\subsection{Generating Distortion Not Disorder} \label{sec:start-disorder}
Instead of creating structures with a range of \textit{disorder}, we begin by generating structures with a range of \textit{distortion}. Whereas \textit{disorder} refers to a stochastic displacement of atoms from their original positions characterized by MSD and the width $ \sigma^2 $ of a radial distribution function, \textit{distortion} refers to isotropic expansion or contraction of the subject. Equivalently, we define distortion as a radial shift in all atomic positions away from (or towards) the center atomic absorber.

% Figure created in distortion-visualizations.ipynb
\begin{figure}[h]
	\centering
	\includegraphics[width=\linewidth]{Chapters/Figures/2d_distortion_example.png}
	\caption[2D Distortion]{Each point represents one of the 12 nearest neighbor atoms surrounded the center of an Au cluster projected onto the $xy$\nobreakdash-plane. The four corner points actually represent two atoms each because of the projection. The blue atoms represent the original coordinates, and the red atoms represent the radially shifted coordinates. The center absorber atom is purple since its original position is the same as its distorted position.}
	\label{fig:2d-distortion}
\end{figure}

A 2-dimensional projection of this isotropic distortion is presented in Figure \ref{fig:2d-distortion}. Though the figure only shows the $xy$\nobreakdash-plane projection of the first 12 nearest neighbors, the actual structure consists of either 55 atoms to simulate nanoparticles, or the first four shells (561 atoms) to simulate bulk materials. Both structures were created with a lattice constant of 4.0782~\AA~to match that of bulk Au \cite{gold-a-value-data}. In reality, the nearest-neighbor distances for Au nanoparticles are likely smaller than for the bulk structure; this can be accounted for later on in the averaging process since the original coordinates will only be one structure out of many. The important part is that the BCC crystal structure is correct.

We generate a total of 91 FEFF input files with different levels of distortion. Each file contains the same center absorber located at $(0,0,0)$ with all the Euclidean distances from the center expanded or contracted radially. All the first shell atomic coordinates are shifted on the range of $ -0.45 $~\AA~to~$ +0.45 $~\AA~in increments of $ 0.01 $~\AA. For example, the FEFF input file with the greatest inward shift contains all first nearest neighbor atoms shifted $ 0.45 $~\AA~radially inwards towards the center absorber, and the FEFF input file with the largest outwards shift has the first nearest neighbor coordinates shifted $ 0.45 $~\AA~radially outwards away from the center absorber. The atoms in the outer shells are scaled accordingly to preserve the crystal structure according to equation \ref{eq:distortionator}

\begin{equation}
	\label{eq:distortionator}
	\vb*{\rho}_{shifted}^{(i)} = \vb*{\rho_0}^{(i)} \left( \dfrac{a + \delta}{a} \right)
\end{equation}
where $ \vb*{\rho}_0^{(i)} $ is the vector from the center absorber to the original (lattice) position of atom \textit{i}, $ a $ is the lattice constant of Au, and $ \delta \in [-0.45,~0.45] $ and is the distance the atoms in the first shell will be shifted.

% alpha = (df[df.rho > 0].rho.min() + delta)/df[df.rho > 0].rho.min()
% df_temp['rho'] *= alpha

Running the 91 simulations (one for each of the distorted structures) takes approximately 30~minutes. Were we to generate thousands more or employ RMC or MD, this process could take days or weeks of computation time. We plot the resulting XANES spectra from the FEFF simulations in Figure \ref{fig:feff-results}.

\begin{figure}[h]
	\centering
	\includegraphics[width=\linewidth]{Chapters/Figures/newplot.png}
	\caption[FEFF Simulations Results]{Each spectrum represents the FEFF simulation results for a different distorted structure. For each spectrum, the crystal structure and center absorber remain constant, the only parameter that varies is the euclidean distance from the center to the other coordinates.}
	\label{fig:feff-results}
\end{figure}

\subsection{Generating Disorder via Probability Distribution Averaging}

One way to characterize system disorder is with the Gaussian standard deviation, $ \sigma $, of the radial distribution function. The idea of our statistical averaging method is to emulate this width by weighting the simulated XANES spectra according to this distribution. An illustration of this relative weighting is depicted in Figure \ref{fig:gaussian-weighting-hist} as a histogram with $ \sigma=0.1 $~\AA. Each histogram bin represents a simulated XANES spectrum with a different isotropic displacement. For example, the bin at $ \Delta\rho=0.0 $~\AA~represents the simulated XANES spectrum with no distortion, and the bin at $ \Delta\rho=-0.2 $~\AA~represents the simulated XANES spectrum with all the atomic coordinates shifted isotropically inwards towards the center absorber by $ 0.2 $~\AA. The height of each bin, $ f(\Delta\rho) $, represents the relative contribution of each simulated XANES spectrum towards the resulting weighted spectrum. For visual clarity, Figure \ref{fig:gaussian-weighting-hist} depicts only 40 bins; the actual weighting includes 91 bins ranging from $ -0.45 $~\AA~to~$ +0.45 $~\AA.

% figure created in playground.ipynb
% !htb
\begin{figure}[h!]
	\centering
	\includegraphics[width=\linewidth]{Chapters/Figures/gaussian-weighting-hist.png}
	\caption[Simulated Spectrum Gaussian Weighting]{A Gaussian distribution probability density function can be used to calculate the relative weight of each FEFF-generated XANES spectrum towards one simulated, disordered spectrum. Each bin (red bar) represents a FEFF-generated spectrum; the $x$-axis is the isotropic shift of the first nearest neightbor atomic positions, and the $y$-axis is the relative weight factor.}
	\label{fig:gaussian-weighting-hist}
\end{figure}

The disordered, Gaussian-averaged XANES spectrum, $ \left\langle \mu(E) \right\rangle $, using the histogram weighting of the Gaussian in Figure \ref{fig:gaussian-weighting-hist} is calculate via equation (\ref{eqn:gaussian-averaging}):

\begin{equation}
	\label{eqn:gaussian-averaging}
	\left\langle \mu(E) \right\rangle  = \frac{1}{S} \sum_{\Delta\rho=-.45}^{+.45} g\left(\Delta \rho \mid \mu=0, \sigma=0.1\right) \mu(E \mid \Delta\rho)
\end{equation}

\noindent
In the above equation, $ \Delta\rho $ is the isotropic radial displacement of each atom from its original position, $\mu(E \mid \Delta\rho) $ is the simulated FEFF spectrum for the given $ \Delta\rho $ configuration, and $ S $ represents a standardization factor included to negate the effect of the changing Gaussian height as a function of the variance, $ \sigma^2 $. With the inclusion of $ S $, only the relative height of each bin matters for producing the averaged XANES spectrum. This standardization factor is defined in Equation (\ref{eqn:gaussian-standardization}):

\begin{equation}
	\label{eqn:gaussian-standardization}
	S = \sum_{\Delta\rho=-.45}^{+.45} g\left(\Delta \rho \mid \mu=0, \sigma=0.01\right)
\end{equation}

\noindent
In both equations (\ref{eqn:gaussian-averaging}) and (\ref{eqn:gaussian-standardization}), the function $ g $ is just the typical Gaussian distribution probability density function (Equation \ref{eqn:gaussian}):

\begin{equation}
	\label{eqn:gaussian}
	g(x) = \frac{1}{{\sigma \sqrt {2\pi } }}e^{{{ - \left( {x - \mu } \right)^2 } \mathord{\left/ {\vphantom {{ - \left( {x - \mu } \right)^2 } {2\sigma ^2 }}} \right. \kern-\nulldelimiterspace} {2\sigma ^2 }}}
\end{equation}

The above example only generates one (simulated) disordered XANES spectrum and does so via weighting of a Gaussian distribution with mean and variance equal to $ 0 $ and $ 0.01 $, respectively. To simulate systems with different degrees of disorder, we can vary the shape of the probability density function. With a Gaussian distribution, we can only vary the mean and variance; to simulate even more conditions, however, we can instead use the multivariate skew normal (skew-norm) distribution, $ f(x) $ \cite{skewnorm_Azzalini_1999} \cite{2020SciPy-NMeth}, written in equation (\ref{eqn:skew-norm}).

\begin{equation}
	\label{eqn:skew-norm}
	f(x)=2\phi (x)\Phi (\alpha x)
\end{equation}

\noindent
where $ \phi(x) $ is the Gaussian PDF:
\begin{equation}
	\label{eqn:skew-norm-pdf}
	\phi (x)={\frac  {1}{{\sqrt  {2\pi }}}}e^{{-{\frac  {x^{2}}{2}}}}
\end{equation}

\noindent
and $ \Phi (x) $ is the Gaussian CDF:
\begin{equation}
	\label{eqn:skew-norm-cdf}
	\Phi (x)=\int _{{-\infty }}^{{x}}\phi (t)\ dt
\end{equation}

%------------WIKIPEDIA EQUATION VERSION -------------
% \begin{equation}
% 	\label{eqn:skew-norm-cdf}
% 	\Phi (x)=\int _{{-\infty }}^{{x}}\phi (t)\ dt={\frac  {1}{2}}\left[1+\operatorname {erf}\left({\frac  {x}{{\sqrt  {2}}}}\right)\right]
% \end{equation}
% \noindent
% and erf is Gauss' error-function

% \begin{equation}
% 	\label{eqn:skew-norm-cdf-erf}
% 	{\displaystyle \operatorname {erf} \left(z\right)={\frac {2}{\sqrt {\pi }}}\int _{0}^{z}e^{-t^{2}}\,dt}
% \end{equation}

\noindent
Equation (\ref{eqn:skew-norm}) includes the shape parameter, $ \alpha $, which has the nice property of producing a right-skewed distribution when positive and a left-skewed distribution when negative. When $ \alpha=0 $, the distribution simply produces the typical Gaussian distribution (\ref{eqn:gaussian}). Utilizing equation (\ref{eqn:skew-norm}), we can vary $ \mu, \sigma,  $ and $ \alpha $ to alter the first four moments of the function: the mean, standard deviation, skew, and kurtosis. Eighteen possible skew-norm weighting functions are plotted in Figure \ref{fig:skew-norm-options}, however, 1000+ unique combinations of weightings would be required to produce the neural network's training data.

\begin{figure}[h!]
	\centering
	\includegraphics[width=\linewidth]{Chapters/Figures/skewnorm_options.png}
	\caption[Simulated Disordered Spectrum Weightings]{Eighteen skew-norm distributions plotted with all possible combinations of ${\sigma \in \{.08, .145\} }$, $ \mu \in \{-.1, 0, .1\} $, and $ \alpha \in \{-5,0,5\} $. Each represents a possible way to produce a simulated, disordered spectrum from many FEFF-simulated, distorted spectra}
	\label{fig:skew-norm-options}
\end{figure}

The disorder of the skew-norm-generated, disordered spectrum is characterized by the mean squared displacement of each atom from its original position ($ \Delta\rho $ ), weighted in the same manner as the spectra. Note, this is different than the standard deviation of the Gaussian used to create it. The weighted mean squared displacement, $ MSD $, is calculated via as follows:

% original weighting, no longer used
% \begin{equation}
% 	\label{eqn:weighted-MSD}
% 	MSD  = \frac{1}{S} \sum_{\Delta\rho=-.45}^{+.45} f\left(\Delta \rho \mid \mu, \sigma^2, \alpha \right)
% \end{equation}
% and the $ MSD $  of each individual FEFF spectrum is equal to the isotropic distortion, $ \Delta\rho $.

\begin{align}
	\label{eqn:updated-weighted-MSD}
	S &= \sum_{\Delta\rho=-.45}^{+.45} f\left(\Delta \rho \mid \mu, \sigma^2, \alpha \right) \\
	\mu_{weighted} &= \frac{1}{S} \sum_{\Delta\rho=-.45}^{+.45} \Delta\rho \left( f ( \Delta \rho \mid \mu, \sigma^2, \alpha ) \right) \\
	MSD &= \frac{1}{S} \sum_{\Delta\rho=-.45}^{+.45} \Delta \rho \left( f ( \Delta \rho \mid \mu, \sigma^2, \alpha ) - \mu_{weighted} \right) ^2
\end{align}

\noindent Here, $ f $ is the skew-norm function from equation (\ref{eqn:skew-norm}). The code for this equation can be found in Appendix \ref{appendix:gaussianator}, written in Python and optimized with NumPy \cite{numpy}.

\subsection{Simulation vs. Experimental Data} \label{sec:end-disorder}

To test our FEFF simulation parameters, as well as the validity of the Gaussian-weighted disorder technique, we compare the simulation data to experimental data \cite{au-nanowires-silca-wang} \cite{crooks-55nm-au-exp} \cite{jing-au-nanoparticle-exp}. In Figure \ref{fig:avg-experimental-vs-simulation}, both experimental and simulation spectra for bulk-like and nanoparticle scenarios are plotted. EXAFS fitting was used to characterize the disorder in the experimental measurements. For the bulk foil (unpublished data), this parameter was found to be $ \sigma^2=0.0081(5)~\text{\AA}^2 $, and for the 8~nm disordered particle, $ \sigma^2=0.0102(8)~\text{\AA}^2 $.  One simulated disordered spectrum was weighted according to the Gaussian $ N(0, 0.09) $ to represent the disordered nanoparticle, and the other was weighted according to the Gaussian $ N(0, 0.038)  $ to represent the bulk. These weightings correspond to MSD values that match the measured $ \sigma^2 $ values for the experimental data.

\begin{figure}[h]
	\centering
	\includegraphics[width=.75\linewidth]{Chapters/Figures/updated_bulk_8nm_disorder_experimental_theory_comparison.png}
	\caption[Simulation vs. Experimental XANES: Disorder Comparison]{Comparing the bulk foil (red) measurement to the 8~nm disordered nanoparticle (green) measurement is an analog to comparing the simulated, non disordered FEFF spectrum (blue) to the simulated disordered spectrum (orange).}
	\label{fig:avg-experimental-vs-simulation}
\end{figure}

In Figure \ref{fig:avg-experimental-vs-simulation}, the bulk Au foil spectrum is above the 8~nm nanoparticle spectrum (more absorption) until the peak around 11937~eV, where the nanoparticle's absorption becomes higher. The two spectra criss-cross again over the next two peaks, changing which material absorbs more at a given energy range. This change is more easily seen in Figure \ref{fig:avg-experimential-vs-simulation-difference}, which plots the difference between the bulk material and the nanoparticle absorption for both the experimental measurements and the simulations. The experimental and simulation difference-spectra follow the same trend with the exception of the peak around 11947~eV.
% The two spectrum switch again at the peak around 11943~eV so the bulk foil's absorption nlevel is higher again. Beyond this peak, the two

\begin{figure}[h!]
	\centering
	\includegraphics[width=\linewidth]{Chapters/Figures/experimental_vs_simulation_delta.png}
	\caption[Bulk-nanoparticle difference: Simulation vs. Experimental data]{The difference between the nanoparticle spectrum and the bulk spectrum are plotted for the same data as in Figure \ref{fig:avg-experimental-vs-simulation}. It is easier to see where the bulk and the nanoparticle absorption crisscross by plotting the difference.}
	\label{fig:avg-experimential-vs-simulation-difference}
\end{figure}

Figures \ref{fig:avg-experimental-vs-simulation} and \ref{fig:avg-experimential-vs-simulation-difference} are not meant to be perfect comparisons of simulations vs. experimental data. For one, the experimental data includes a comparison between a bulk spectrum to a nanoparticle. By contrast, both the simulation spectra are from identically sized 55 atom  Au clusters. Still, much of the disorder trends are coded in the simulation approach.

To test if nanoparticle size information is also coded in our Gaussian-averaged simulations, we compare different size nanoparticle simulations to experimental data in Figure \ref{fig:avg-experimental-vs-simulation2}. We first simulated two different size nanoparticle gold clusters, one with 13 Au atoms and one with 55. As expected, including more atoms in the simulation produces more bulk-like spectrum characteristics, such as larger amplitude peaks.

\begin{figure}[h]
	\centering
	\includegraphics[width=.7\linewidth]{Chapters/Figures/Bulk_55atom_experimental_theory_comparison.png}
	\caption[Simulation vs. Experimental XANES: Size Comparison]{Comparing the bulk foil (red) measurement to the 55 atom nanoparticle (green) measurement is an analog to comparing the 13 atom simulated spectrum (blue) to the 55 atom simulated spectrum (orange).}
	\label{fig:avg-experimental-vs-simulation2}
\end{figure}

These preliminary indications suggest the statistical approach may provide useful insights given the similarity in trends; however, this does not yet provide any indication as to whether the statistical averaged simulations are equivalent to the particle average simulations, nor do they tell us whether these spectra would work as training data for predicting the mean squared disorder from experimental spectra. This broader discussion is the topic of the next section.

\section{Particle-Averaged FEFF vs. Skewnorm-Averaged Structures} \label{sec:pa-feff-vs-gaussian-feff}

While it is important to see that the skew-norm-averaging methodology maintains the systematic changes in XANES spectra as disorder increases (as seen in section \ref{sec:end-disorder}), it is more important to compare this methodology to the widely-used particle-averaged methodology (seen in section \ref{sec:traditional-disorder}). Unfortunately, this is where the efficacy of the statistical methodology breaks down and the limitations of the method are revealed. As seen in figures \ref{fig:pa-vs-sknm-feff} and \ref{fig:pa-vs-sknm-feff-bigmsd}, the particle averaged FEFF spectra and the skew-norm averaged spectra are distinctly different. We showcase two examples using skew-norm averaged, one for a bulk-like nanoparticle with low-disorder (figure \ref{fig:pa-vs-sknm-feff}) and one for bulk-like nanoparticle with high-disorder (\ref{fig:pa-vs-sknm-feff-bigmsd}). Averaging with a Gaussian instead of the skew-norm produced the same problematic results. This is likely a result of the false assumption that the linear combinations of $ \mu(E) $ calculated on ordered structures with different lattice parameters contribute equivalently to that of actual disordered structures.

Because of the discrepancy in spectral shape between particle-averaged and skew-norm averaged FEFF simulations for structures with the same disorder, the statistical-based methodology work was abandoned for this thesis. This does not mean, however, that the skew-norm approach is without merit. Preliminary work has shown it is possible to create identical spectra through selective weighting of the distorted (non-disordered) spectra. One current limitation, however, is that the shape of the weightings required to produce these identical spectra remains unpredictable. Sometimes the weightings resemble Gaussian distribution similar to the radial distribution function; however, this is not always the case. Sometimes jagged, multimodal weightings can produce very similar spectra. While it is in theory possible in experimental data for wildly different RDFs to have the same MSD value, we expect these strangely shaped distributions to be exceedingly unlikely in nature (from an entropic, configurational perspective), and for disorder in bond lengths to be generally Gaussian in shape. Further work to understand the relationship between different distorted spectral weightings, FEFF simulations, and the mean squared disorder of the structure may provide insight into the contribution of atomic displacement in a XANES spectrum for disordered structures. Consequently, for the remainder of this thesis, particle-averaged FEFF spectra were used as the training data for the neural network.

\begin{figure}[!h]
	\centering

	\includegraphics[width=.75\linewidth]{Chapters/Figures/PA-vs-skewnorm-newvals.png}
	\caption[Particle-Averaged vs. Skewnorm-Averaged FEFF Low-Disorder]{The particle Averaged FEFF (PA) and Skewnorm-Averaged FEFF (PA) for low-disorered bulk-like Au nanoparticles are plotted above. The systematic difference reveal a flawed assumption in the skew-norm-averaged methodology}
	\label{fig:pa-vs-sknm-feff}
\end{figure}

\begin{figure}[!h]
	\centering

	\includegraphics[width=.75\linewidth]{Chapters/Figures/PA-vs-skewnorm-newvals-large-msd.png}
	\caption[Particle-Averaged vs. Skewnorm-Averaged FEFF High-Disorder]{The particle Averaged FEFF (PA) and Skewnorm-Averaged FEFF (SN) for particles high-disordered bulk-like Au nanoparticles are plotted above. The systematic differences between the particle-averaged FEFF and the statistical averaged methods are less significant for particles with a high degree of disorder. The persistent differences, however, suggest a false assumption in the statistical averaging methodology.}
	\label{fig:pa-vs-sknm-feff-bigmsd}
\end{figure}


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

\pagebreak

\section{Related Work}
\label{sec:relWork}

Providing end-to-end guarantees in distributed networked systems has a long history in the context of the Internet. Notable developments are the resource reservation protocol (RSVP) that combines flow specification, resource reservation, admission control, and packet scheduling to achieve end-to-end quality of service~(QoS) \cite{zhang1993rsvp}. Network calculus \cite{cruz1991calculus} provides some of the necessary theoretical concepts to determine bounds on buffer sizes and delay in communication networks.
Extension toward hard real-time computing and communication systems is known as real-time calculus \cite{thiele2000Realtime}.
The analysis of distributed hard real-time systems also has a long history~\cite{tindell1994Holistic}, and so do compositional analysis frameworks (MAST~\cite{gonzalezharbour2001MAST}, SymTA/S \cite{henia2005System} and MPA~\cite{wandeler2006System}).

Early works on real-time communication in sensor networks consider classical non-deterministic routing protocols~\cite{lu2002RAP,stankovic2003Realtime,he2003SPEED}, thus providing only soft guarantees.
Stankovic et al. \cite{stankovic2003Realtime} even argue that specific message delivery orderings, such as those useful to apply established dependability techniques~\cite{ferrari2013Virtus}, are impossible to guarantee in a multi-hop low-power wireless network.
More recently, standards like WirelessHART~\cite{wirelessHART} have been analyzed to provide communication guarantees~\cite{saifullah2015EndtoEnd,saifullah2010RealTime}.
But~\cite{saifullah2010RealTime} is based on NP-hard multiprocessor scheduling and requires a global network view, which limits its adaptability to dynamic changes in the system~\cite{akerberg2011Measurements}.
It is however possible to integrate the wireless protocol with the rest of the system to avoid interference by jointly schedule transmissions in the network and all other tasks in the system, as we demonstrate in \cref{ch:ttw}.
Other wireless real-time protocols have been described recently~\cite{odonovan2013GINSENG,watteyne2017Teaching}. However, the integration of these protocols into a methodology to provide end-to-end real-time guarantees between \emph{application interfaces} is unsolved.

\squarepar{%
  Recently, a game-changing approach to wireless multi-hop communication using synchronous transmissions has been described~\cite{ferrari2011Glossy,ferrari2012LWB,zimmerling2013modeling}.
  It avoids the computation of multi-hop routing paths and per-node communication schedules based on, for example, neighbor lists and link qualities, because the protocol logic is independent of such volatile network state.
  Experiments on several large-scale testbeds show that the approach is highly adaptive and achieves an end-to-end packet reliability higher than 99.9\,\%~\cite{ferrari2011Glossy,ferrari2012LWB}.
  Furthermore, the few packet losses can be considered statistically independent~\cite{zimmerling2013modeling}, which eases the design of \CPS controllers that can deal with intermittent observations~\cite{sinopoli2004Kalman}.%
}